home *** CD-ROM | disk | FTP | other *** search
/ Merciful 1 / Merciful - Disc 1.iso / software / r / rexx_plus_compiler / rexxpluscompiler2.dms / in.adf / Examples / examples.zoo / shift.txed < prev    next >
Encoding:
Text File  |  1991-11-01  |  1.4 KB  |  65 lines

  1. /* shift:                    */
  2. /*       is used to shift the lines in the      */
  3. /*       block to the left or right by n bytes  */
  4. trace o
  5.    parse arg direct count . rows . cols .
  6.    options results
  7.    if rows = '' 
  8.    then do
  9.      'STATUS R'
  10.      'MACRO 10 shift' direct count result
  11.      'MARK 1'
  12.      return
  13.      end
  14.    else do
  15.      'STATUS T'
  16.      tab = result
  17.      'MACRO 10 shift' direct count
  18.      'COPY'
  19.      if rc = 0 
  20.      then do
  21.        if rows = '' then return(-1)
  22.        'STATUS R'
  23.        parse value result with . rowe . cole .
  24.        if rows > rowe
  25.        then do
  26.          row  = rows
  27.          rows = rowe
  28.          rowe = row
  29.          end
  30.        do t = rows to rowe
  31.          'JUMP' t
  32.          'STATUS L'
  33.          linesve = result
  34.          if rc ~= 0 then leave
  35.          'DLINE'
  36.      p = 1
  37.      do forever
  38.         p = pos('09'x,linesve)
  39.         if p = 0 then leave
  40.         i = (tab - (p//tab))+1
  41.         linesve = delstr(linesve,p,1)
  42.         i = copies(" ",i)
  43.         linesve = insert(i,linesve,p-1)
  44.         end
  45.          if direct = '>'
  46.          then do
  47.            shift = substr(' ',1,count) 
  48.            'I *N'shift''linesve'*N'
  49.            'UP 2'
  50.            'DLINE'
  51.            end
  52.          else do
  53.            shift = linesve''substr(' ',1,count+1)
  54.            shift = substr(shift,count+1)
  55.        shift = strip(shift,'t')
  56.            'I *N'shift'*N'
  57.            'UP 2'
  58.            'DLINE'
  59.            end
  60.          end
  61.       end
  62.     end
  63.     'CMD 0'
  64.     return
  65.