home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / REXXSAMP.ZIP / REXXDIR.CMD < prev    next >
OS/2 REXX Batch file  |  1989-12-05  |  3KB  |  75 lines

  1. /*    */
  2. /*     Prompted DIR listing with scrolling
  3.  
  4.        Usage: REXXDIR filename screen_size
  5.        Where: filename is any valid OS/2 filename
  6.             : Screen_size is the size of the virtual screen
  7.  
  8.        I used DOS compatability file types.
  9. */
  10. arg  filename  screen_size .        /* get arguments   */
  11. file_out = 'REXXDIR.TXT'            /* set up the work file   */
  12. /*   check the filename */
  13. r_c = 0
  14. if length(filename) > 12 or length(filename) < 1
  15. then do
  16.      say 'The filename ('filename') is invalid'
  17.      r_c = 1
  18.      end
  19. /* check the screen size value   */
  20.  
  21.  
  22. if  datatype(screen_size,'W') = 0        /* Is it a whole number ? */
  23.         then do
  24.              say 'The screen size ('screen_size') is invalid'
  25.              r_c = 1
  26.              end
  27. if screen_size < 2                       /* we need some lines   */
  28.         then do
  29.              say 'The screen size ('screen_size') is too low, invalid'
  30.              r_c = 1
  31.              end
  32.  
  33. /* if r_c does not equal zero, there was an error. Display the
  34.    lines 4 to end as help.
  35.    I like this method as it keeps my help files honest.
  36.    Not that I ever need ......
  37. */
  38. if r_c <> 0                          /* any problems ? 1 = yes 0 = No */
  39. then do
  40.        say ; say ;
  41.        do line = 4 while substr(sourceline(line),1,2) <> '*/'
  42.        say sourceline(line)
  43.        end
  44.        return
  45.   end
  46. screen_size = screen_size - 2          /* I need 2 lines    */
  47.  
  48. /* real work starts here */
  49. /* REXX treats any variable with a '.' as an array, subscripted by
  50.    whatever follows the '.'   2 dimensional matrices are 2 periods
  51.    etc. This variable "FILE_LINE" is subscripted by X_POS to start
  52.    and later by YY. It doesn't matter what variable you use as a
  53.    subscript.
  54. */
  55.  
  56. 'dir '||filename|| ' > 'file_out      /* pipe the DIR to a file */
  57.  x_pos = 1
  58. do x_pos = 1 while lines(file_out)             /* read the file    */
  59.       file_line.x_pos = linein(file_out)       /* and store in an  */
  60.       end                                      /* array */
  61.  
  62. cls
  63. x_pos = x_pos - 1                            /* do loop is 1 high */
  64. do XX = 1 to x_pos by screen_size            /* outer loop */
  65.      disp_lines = xx + screen_size           /* show how many ? */
  66.      if disp_lines > x_pos                   /* but only if enough */
  67.         then disp_lines = x_pos              /* loop thru */
  68.      do yy = xx to disp_lines
  69.                  say file_line.yy
  70.                  end
  71.        say 'Press [ENTER] to continue'
  72.        pull answer                        /* get a response using PULL */
  73.        cls
  74.   end
  75.