Fixed length records: Difference between revisions

Content added Content deleted
(→‎{{header|Lua}}: added Lua solution)
m (→‎{{header|REXX}}: changed whitespace and comments.)
Line 1,204: Line 1,204:


=={{header|REXX}}==
=={{header|REXX}}==
<lang rexx>/*REXX pgm reads fixed-length 80 byte records; reverses each record, displays to term. */
<lang rexx>/*REXX pgm reads fixed─length 80 byte records; reverses each record, displays to term. */
iFID= 'FIXEDLEN.TXT' /*the file's filename (used for input).*/
iFID= 'FIXEDLEN.TXT' /*the file's filename (used for input).*/
call charin iFID, 1, 0 /*open the file, point rec pointer to 1*/
call charin iFID, 1, 0 /*open the file, point rec pointer to 1*/
/* [+] just to be safe, position file.*/
/* [+] just to be safe, position file.*/
do j=1 while chars(iFID)>=80 /*read data records of LRECL ≡ eighty. */
do j=1 while chars(iFID) >= 80 /*read data records of LRECL ≡ eighty. */
@.j= charin(iFID, , 80) /*read a data record of eighty bytes. */
@.j= charin(iFID, , 80) /*read a data record of eighty bytes. */
end /*j*/
end /*j*/
#= j - 1 /*adjust # of records (J is 1 too high)*/
#= j - 1 /*adjust # of records (J is 1 too high)*/
do k=1 for # /* [+] process all the records read. */
do k=1 for # /* [] process all the records read. */
say reverse(@.k) /* reverse a record and write to term. */
say reverse(@.k) /* reverse a record and write to term. */
end /*k*/ /*stick a fork in it, we're all done. */</lang>
end /*k*/ /*stick a fork in it, we're all done. */</lang>
{{out|output|text=&nbsp; when using the default input file:}}
{{out|output|text=&nbsp; when using the default input file:}}
{{out}}
{{out}}