Longest string challenge: Difference between revisions

m
→‎read file until not ready: elided the need for the variable named ONE.
m (→‎read file until not ready: added a colon to a template text.)
m (→‎read file until not ready: elided the need for the variable named ONE.)
Line 1,745:
<br>no arrays or lists are used, &nbsp; and
<br>no additions or subtractions are used.
<lang rexx>/*REXX program reads a file and displays the longest [widest] record(s) [line(s)]. */
parse arg iFID . /*obtain optional argument from the CL.*/
if iFID=='' | iFID=="," then iFID= 'LONGEST.TXT' /*Not specified? Then use the default.*/
signal on notReady /*when E-O-F is reached, jump/branch. */
one=1 /*used to cause 1st time initialization*/
m=0 /*the maximum width (so far). */
do foreverrec=1; _=linein(iFID); w=length(_) /*read a line from the input file. */
one=0 do y=rec to 1; m=w; w=0; $=y || _; end /*don't do the initial record nextfirst timeinitialization.*/
do yn=onem for one1; m=w; w=0; $=y || _; end /*initializefor 1stsmaller timerecords. */
do nz=mn to w for 1; $=; end end /*forfound smallerlongest recordsrecord.*/
do zx=nm to w for 1; $=;$'a0d'x || _; end end /*foundappend arecord to longest rec$. */
do x=m to w for 1; $=$'a0d'x || _; end /*append record to $. */
m=max(m, w) /*M: is the maximum length record. */
end /*forever*/