Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
On INREC, IFTHEN in WHEN=INIT to set a four-byte extension to zero. Four IFTHENs to test the field for non-blank and extend the record by one byte for each column with a value of one if non-blank.
Use OUTFIL reporting functions with REMOVECC, use TRAILER2 for some TOTs and BUILD to drop of the four excess bytes.
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
If you can type out a request like that, you can type out the code yourself. Really, which part was difficult? Probably the TRAILER2, so find examples of that (the manual, here, internet search).
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
Yes, mistah kurtz, very good point.
I spent more time coding and de-mangling than thinking about it, because I half-suspect that the columns will turn out not to be fixed-position and that, along with the lines of dashes magically appearing, led me to expect a request for code, rather than hints :-)
It is well worth understanding, and CHANGE doesn't seem to get the use it deserves. Anyone want to have a go at explaining exactly what that single OVERLAY statement does?
Joined: 28 Jan 2012 Posts: 316 Location: Room: TREE(3). Hilbert's Hotel
This is really great! The single OVERLAY is by default populating the string '0000' in the 51st column and the subsequent CHANGE statements are looking up for spaces and setting the value to 1 if it does not find the match.
CHANGE syntax:
Code:
input field start position,input field length,CHANGE=(output field length,find value,set value if find a match),NOMATCH=(set value if does not match)
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
Correct mistah kurtz.
All in one shot it:
Sets four bytes from position 51 to zero
In position 51, for one byte, it will change that value to zero where there are spaces at position 1,3 otherwise it will be "1" at that position
This is repeated for the remaining three byte groups and one-byte positions from 52 to 54.
Note that the OVERLAY allows re-use of a position whose value has already changed in the OVERLAY. You can't do that with BUILD (you can use CHANGE in BUILD, of course).