Re: COBOL is dynamic (depends)



Frank Swarbrick wrote:
Years ago for a project I had to deal with some messages that were
something like the following:

Field 1 - 4 alphanumeric characters
Field 2 - 2 numeric characters
Field 3 - either 16, or 33 or 49 characters in length, where if the
first character is a 'U' the length is 33, if the first character is
a 'T' the length is 49, otherwise the length is 16
Field 4 - 4 numeric characters
Field 5 - zero to 49 characters with the length being specified by
field 4. Field 6 - 1 character end of message delimiter ('!')

I ended up with a solution that, while it didn't make me happy, works
and isn't *too* complicated and ugly.

I saw this code again yesterday and thought that I should be able to
make it simpler, more flexible, and easier to understand.

Your solution is simple, compact, and easy to understand.

You're lucky to have a compiler that permits field names after an ODO. For
those of us with conforming compilers, your solution can't be used. If faced
with the same problem, I'd have to march an index down the input record
moving individual bytes to their prescribed destinations.


.



Relevant Pages

  • Re: Querying for postcodes within an address against another maste
    ... we add 1 to we have the position of the first character after the comma. ... so mid defaults to all the characters from the ... Postcodes in separate fields. ...
    (microsoft.public.access.queries)
  • Re: Entourage 2004 - Missing Characters
    ... capitalizing the first character of every new line? ... No missing characters. ... contents into an Entourage plain text message, sent it to myself, opened the ...
    (microsoft.public.mac.office.entourage)
  • Re: Funny gaming moments
    ... fully to life at all. ... That beats the two characters from my games that are tied for shortest ... My very first character was killed about six or ... there was a foaming tankard waiting for Narek; ...
    (rec.games.frp.dnd)
  • Re: How to start/stop a script at certain time?
    ... Well, it takes up less amount of characters, but only if you have a LOT ... typing the commands on a console. ... quotes as the first character. ... I asumed that it would be run as root anyway. ...
    (alt.os.linux.suse)
  • Re: create database 2bad - - Fails?
    ... The first character must be one of the following: ... in addition to letter characters from other languages. ... create database ...
    (microsoft.public.sqlserver.programming)