home *** CD-ROM | disk | FTP | other *** search
- /*******************************************************************
-
- 1] T.rexx:
-
- 1] Rexx version of MORE (sort of)
-
- 1] ARexx example by Tom Beale
-
- ********************************************************************/
- arg filename depth .
-
- page = 0
- if datatype(depth) ~= 'NUM' then depth = 20
- /*
- 1] -------------------------------------- Try and Open File
- 1] If not Succeessful, Print
- 1] Help Screen
- */
- RCode = open('t',filename,'R')
- if RCode ~= 1 then do
- say ''
- say ' t.rexx by Tom Beale'
- say ''
- say ' Usage: rx t <filename> [lines]'
- say ''
- say ' The lines paramater is optional and sets the '
- say ' number of lines that will be displayed per'
- say ' screen (default 20).'
- say ''
- say ' Options at MORE Prompt:'
- say ''
- say ' <return> next screen'
- say ''
- say ' - previous screen'
- say ''
- say ' r redraw current screen'
- say ''
- say ' q quit'
- say ''
- exit
- end
- /*
- 1] -------------------------------------- Read the File into an Array
- */
- say 'Reading File ...'
- do a = 1 to 100000
- line.a = readln('t')
- endofit = a
- if eof('t') then leave
- end
- /*
- 1] ------------------------------------- Clear Screen if File Will Take
- 1] More Than One Screen
- */
- if (endofit>depth) then say d2c(12)
- /*
- 1] ------------------------------------- Our Main Loop
- */
- do forever
- do a = 1 to depth
- l = (page*depth) + a
- if l > endofit then exit /* Exit if End of File */
- say line.l
- end
-
- /*
- 1] ----------------------------- Set Up 'More' Prompt
- */
- say ' '
- howfar = (l/endofit)*100-1
- parse var howfar howfar '.' .
- prmt = '---- MORE ------' howfar'% (<return>,-,r,q) '
- ret = writech(stdout,prmt)
- /*
- 1] ----------------------------- Get User Response
- */
- pull pause
- select
- when substr(pause,1,1)='Q' then exit
- when substr(pause,1,1)='-' then do
- page=page-1
- end
- when substr(pause,1,1)='R' then nop
- otherwise page=page+1
- end
- if page<0 then page=0
- say d2c(12)
- end
- exit
-