home *** CD-ROM | disk | FTP | other *** search
/ Amiga Elysian Archive / AmigaElysianArchive.iso / prog / arexx / trexx.lha / T.rexx < prev    next >
Encoding:
OS/2 REXX Batch file  |  1990-06-11  |  2.2 KB  |  90 lines

  1. /*******************************************************************
  2.  
  3. 1]             T.rexx:
  4.  
  5. 1]             Rexx version of MORE (sort of)
  6.  
  7. 1]                          ARexx example by Tom Beale
  8.  
  9. ********************************************************************/
  10. arg filename depth .
  11.  
  12. page  = 0
  13. if datatype(depth) ~= 'NUM' then depth = 20
  14. /*
  15. 1]   -------------------------------------- Try and Open File
  16. 1]                                          If not Succeessful, Print
  17. 1]                                          Help Screen
  18. */
  19. RCode = open('t',filename,'R')
  20. if RCode ~= 1 then do
  21.    say ''
  22.    say '  t.rexx by Tom Beale'
  23.    say ''
  24.    say '  Usage: rx t <filename> [lines]'
  25.    say ''
  26.    say '       The lines paramater is optional and sets the '
  27.    say '       number of lines that will be displayed per'
  28.    say '       screen (default 20).'
  29.    say ''
  30.    say '  Options at MORE Prompt:'
  31.    say ''
  32.    say '       <return> next screen'
  33.    say ''
  34.    say '              - previous screen'
  35.    say ''
  36.    say '              r redraw current screen'
  37.    say ''
  38.    say '              q quit'
  39.    say ''
  40.    exit
  41. end
  42. /*
  43. 1]   -------------------------------------- Read the File into an Array
  44. */
  45. say 'Reading File ...'
  46. do a = 1 to 100000
  47.    line.a = readln('t')
  48.    endofit = a
  49.    if eof('t') then leave
  50. end
  51. /*
  52. 1]   ------------------------------------- Clear Screen if File Will Take
  53. 1]                                         More Than One Screen
  54. */
  55. if (endofit>depth) then say d2c(12)    
  56. /*
  57. 1]   ------------------------------------- Our Main Loop
  58. */
  59. do forever
  60.    do a = 1 to depth                       
  61.       l = (page*depth) + a
  62.       if l > endofit then exit               /* Exit if End of File */
  63.       say line.l      
  64.    end
  65.  
  66.    /*
  67. 1]   ----------------------------- Set Up 'More' Prompt
  68.    */
  69.    say ' '
  70.    howfar = (l/endofit)*100-1
  71.    parse var howfar howfar '.' .
  72.    prmt = '---- MORE ------' howfar'% (<return>,-,r,q) '
  73.    ret = writech(stdout,prmt)
  74.    /*
  75. 1]   ----------------------------- Get User Response
  76.    */
  77.    pull pause
  78.    select
  79.       when substr(pause,1,1)='Q' then exit
  80.       when substr(pause,1,1)='-' then do
  81.          page=page-1
  82.       end
  83.       when substr(pause,1,1)='R' then nop
  84.       otherwise page=page+1
  85.    end 
  86.    if page<0 then page=0
  87.    say d2c(12)
  88. end
  89. exit
  90.