June 2018 Update

This commit is contained in:
Ingy döt Net 2018-06-22 20:57:24 +00:00
parent ba8067c3b7
commit 22f33d4004
5278 changed files with 84726 additions and 14379 deletions

View file

@ -1,17 +1,19 @@
/*REXX pgm reads a file & prints the longest [widest] record(s)/line(s).*/
!.='' /*initialize stemmed array to nul*/
fileID='LONGEST1.TXT' /*point to the input file. */
m=0
do while min(lines(fileID),1); _=linein(fileID); w=length(_)
say 'input =' _ /*display the input to terminal. */
!.w=!.w || '0a'x || _ /*build a stemmed array element. */
m=max(m,w) /*find the maximum width so far. */
end /*while min(lines(... */
do j=m for m /*handle the case of no input. */
say center(' longest record(s): ',79,'')
say substr(!.m,2)
say center(' list end ',79,'')
exit /*stick a fork in it, we're done.*/
end /*j*/
/*REXX program reads a file and displays the longest [widest] record(s) [line(s)]. */
signal on notReady /*when E-O-F is reached, jump/branch. */
iFID= 'LONGEST.TXT' /*the default file identifier for input*/
parse arg fid . /*obtain optional argument from the CL.*/
do #=1 to length(fid); iFID=fid /*Specified? Then use what's given. */
end /*#*/
!= /*the maximum width (so far). */
do forever; _=linein(iFID); ?=_ /*read a line from the input file. */
t=0 /*don't do the initialization next time*/
do #=t for t; !=?; ?=; $=. || _; end /*just do 1st time.*/
do #=length(!' ') to length(?) for 1; $=; end /*found widest rec.*/
do #=length(!) to length(?) for 1; $=$'a0d'x || _; end /*append it to $. */
/* [↑] variable # isn't really used.*/
!=left(., max( length(!), length(?) ) ) /*!: is the max length record, so far.*/
end /*forever*/
/* [↓] comes here when file gets E─O─F*/
notReady: do j=length(!) to length(!) for length(!) /*handle the case of no input*/
say substr($, 2) /*display (all) the longest records. */
end /*j*/ /*stick a fork in it, we're all done. */

View file

@ -1,18 +1,44 @@
/*REXX pgm reads a file & prints the longest [widest] record(s)/line(s).*/
!.='' /*initialize stemmed array to nul*/
fileID='LONGEST2.TXT' /*point to the input file. */
signal on notready /*when E-O-F is reached, jump. */
m=0 /*maximum width line so far. */
do forever; _=linein(fileID); w=length(_) /*read a line. */
say 'input =' _ /*display the input to terminal. */
!.w=!.w || '0a'x || _ /*build a stemmed array element. */
m=max(m,w) /*find the maximum width so far. */
end /*forever*/
notready: do j=m for m /*handle the case of no input. */
say center(' longest record(s): ',79,'')
say substr(!.m,2)
say center(' list end ',79,'')
exit /*stick a fork in it, we're done.*/
end /*j*/
/* REXX ***************************************************************
* 27.10.2010 Walter Pachl
**********************************************************************/
Parse Arg fid
If fid='' Then Do
"ALLOC FI(IN) DA('N561985.PRIV.V100(LL)') SHR REUSE"
'EXECIO * DISKR IN (STEM L. FINIS' /* read all lines */
'FREE FI(IN)'
End
Else Do
Do i=1 By 1 While lines(fid)>0
l.i=linein(fid)
End
l.0=i-1
End
maxl = 0 /* initialize maximum length */
Do i=1 To l.0 /* loop through all lines */
linl=length(l.i) /* length of current line */
Select
When linl>maxl Then Do /* line longer than preceding */
maxl=linl /* initialize maximum length */
mem.0=1 /* memory has one entry */
mem.1=l.i /* the current line */
lin.1=i /* its line number */
End
When linl=maxl Then Do /* line as long as maximum */
z=mem.0+1 /* new memory index */
mem.z=l.i /* the current line */
lin.z=i /* its line number */
mem.0=z /* memory size */
End
Otherwise /* line is shorter than max. */
Nop /* ignore */
End
End
If mem.0>0 Then Do
Say 'Maximum line length='maxl
Say ' Line Contents'
Do i=1 To mem.0
Say right(lin.i,5) mem.i
End
End
Else
Say 'No lines in input file or file does not exist'