home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 339.lha / DispMod / rexx / data_entry.rexx < prev    next >
OS/2 REXX Batch file  |  1990-02-07  |  4KB  |  185 lines

  1. /* dispex.rexx - test dispmod */
  2. options results
  3. pack = 0
  4. BELL = '07'x
  5. ESC = '1B'x
  6. CR = '0D'x
  7. CLS = '0C'x
  8. connected = 0
  9. multiline = 0
  10. maxfield = 15
  11. inline = ''
  12. titlebar = 'Data Entry'
  13. con.0 = '     INPUT INHIBITED'
  14. con.1 = '     CONNECTED'
  15. separator = '--------------------------------------------------------------------------------'
  16. keepgoing = TRUE
  17.  
  18. if ~exists('datafile') then do
  19.   call open(x,'datafile','w')
  20.   call close(x)
  21.   end
  22. ports = showlist('p')
  23.  
  24. if pos('ROBBS_disp', ports) = 0 then address command run dispmod
  25.  
  26. address command waitforport 'ROBBS_disp'
  27.  
  28. ports = showlist('p')
  29. if pos('ROBBS_disp', ports) = 0 then
  30.     exit(100)
  31.  
  32. address 'ROBBS_disp'
  33.  
  34. call openport('ROBBS_ctrl')
  35.  
  36. title titlebar '     INPUT INHIBITED'
  37.  
  38. call clearall
  39. call initscreen
  40.  
  41. connect 'ROBBS_ctrl SEND'
  42. connected = 1
  43. title titlebar con.connected
  44.  
  45. status
  46. say result
  47.  
  48. fld = 1
  49. crsr field.1.row field.1.col+length(field.1.string)
  50.  
  51. do while keepgoing = TRUE
  52.     packet = getpkt('ROBBS_ctrl')
  53.     do while packet = '00000000'x
  54.         call waitpkt('ROBBS_ctrl')
  55.         packet = getpkt('ROBBS_ctrl')
  56.     end
  57.     arg0 = getarg(packet)
  58.     arg1 = getarg(packet,1)
  59.     call reply(packet,0)
  60.  
  61.     select
  62.         when arg0 = 'SEND' then do
  63.             if pos(arg1,CR) > 0 then do
  64.                 text substr(arg1,pos(arg1,CR))
  65.                 field.fld.contents = inline || substr(arg1,pos(arg1,CR))
  66.                 fld = fld+1
  67.                 if fld > maxfield then fld = 1
  68.                 crsr field.fld.row field.fld.col+length(field.fld.string)
  69.                 inline = ''
  70.                 end
  71.             else do
  72.                 text arg1
  73.                 inline = inline || arg1
  74.                 end
  75.             end
  76.         when arg0 = 'FKEY' then call Fkey(arg1+1)
  77.         when arg0 = 'HELP' then say BELL || 'Help key hit.'
  78.         otherwise nop
  79.     end
  80. end
  81.  
  82. call delay(50)
  83. die
  84.  
  85. do while pos('ROBBS_disp', ports) > 0
  86.  call delay(5)
  87.  ports = showlist('p')
  88. end
  89. say 'All Done.'
  90.  
  91. exit(0)
  92.  
  93.  
  94. fkey:
  95.     parse arg x
  96.     if x ~= 10 then do
  97.         select
  98.             when x = 1 then do
  99.                 call open(dbfile,'datafile','A')
  100.                 writeln(dbfile,'ENTRY')
  101.                 do i=1 to maxfield
  102.                     if index(field.i.contents,'08'x) >0 then call remdel
  103.                     writeln(dbfile,field.i.contents)
  104.                     end
  105.                 call close(dbfile)
  106.                 call clearall
  107.                 call initscreen
  108.                 end
  109.             when x = 5 then do
  110.                 field.fld.contents = inline
  111.                 fld = fld-1
  112.                 if fld = 0 then fld = maxfield
  113.                 crsr field.fld.row field.fld.col+length(field.fld.string)
  114.                 inline = ''
  115.             end
  116.             otherwise nop
  117.         end
  118.     end
  119.     else
  120.         keepgoing = FALSE 
  121.     return(0)
  122.  
  123. initscreen:
  124.     text CLS
  125.     crsr 2 25; text 'Data Entry Example'
  126.     crsr 3 1; htext separator
  127.     field.1.row  =  5; field.1.col =  1; field.1.string = 'Name: '
  128.     field.2.row  =  5; field.2.col = 40; field.2.string = 'Age: '
  129.     field.3.row  =  7; field.3.col =  1; field.3.string = 'Address: '
  130.     field.4.row  =  8; field.4.col =  1; field.4.string = '       : '
  131.     field.5.row  =  9; field.5.col =  1; field.5.string = '       : '
  132.     field.6.row  = 10; field.6.col =  1; field.6.string = '       : '
  133.     field.7.row  =  7; field.7.col = 40; field.7.string = 'Telephone - home: '
  134.     field.8.row  =  8; field.8.col = 40; field.8.string = '          - work: '
  135.     field.9.row  = 14; field.9.col =  1; field.9.string = 'Comments: '
  136.     field.10.row = 15; field.10.col = 1; field.10.string = '        : '
  137.     field.11.row = 16; field.11.col = 1; field.11.string = '        : '
  138.     field.12.row = 17; field.12.col = 1; field.12.string = '        : '
  139.     field.13.row = 18; field.13.col = 1; field.13.string = '        : '
  140.     field.14.row = 19; field.14.col = 1; field.14.string = '        : '
  141.     field.15.row = 20; field.15.col = 1; field.15.string = '        : '
  142.  
  143.     do i=1 to 15
  144.         crsr field.i.row field.i.col; text field.i.string || field.i.contents
  145.     end
  146.  
  147.     crsr 21 1; htext separator
  148.     text 'F1: Add Data to file    F5: Previous Field   F6: Next Field'
  149.     crsr field.1.row field.1.col+length(field.1.string)
  150.     fld = 1
  151.  
  152. return 0
  153.  
  154. stat:
  155.     parse arg x
  156.     crsr 23 1; text '9b4b'x || x
  157. return 0
  158.  
  159. query
  160. stat:
  161.     parse arg x
  162.     crsr 23 1; getline '9b4b'x || x
  163. return 0
  164.  
  165. clearall:
  166.     do i=1 to maxfield
  167.         field.i.contents = ''
  168.         end
  169. return 0
  170.  
  171. remdel:
  172.     temp = field.i.contents
  173.     do forever
  174.         dele = index(temp,'08'x)
  175.         if dele > 0 then do
  176.             temp = left(temp,dele-2) || substr(temp,dele+1)
  177.         end
  178.         else do
  179.             field.i.contents = temp
  180.             leave
  181.         end
  182.     end
  183. return 0
  184.  
  185.