This commit is contained in:
Ingy döt Net 2013-04-10 21:29:02 -07:00
parent 764da6cbbb
commit db842d013d
19005 changed files with 197040 additions and 7 deletions

View file

@ -0,0 +1,17 @@
/*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*/

View file

@ -0,0 +1,18 @@
/*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*/

View file

@ -0,0 +1,44 @@
/* 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'