home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / rxcp290.zip / cp29web.cmd < prev    next >
OS/2 REXX Batch file  |  1996-01-30  |  2KB  |  78 lines

  1. /* Rexx Program */
  2.  
  3. env = "OS2ENVIRONMENT"
  4. Parse Arg Argv
  5. argc = words(argv)
  6.  
  7. len = value("CONTENT_LENGTH",,env)
  8. post_string = charin(,,len)  /* read only the number specified in CONTENT_LENGTH */
  9.  
  10. nf = ParseQueryString(post_string)
  11. do i = 1 to nf
  12.    if Parms.Tag.i = 'HCODE' Then
  13.       hcode = Parms.XVal.i 
  14.    if Parms.Tag.i = 'MODULE' Then
  15.       module = Parms.XVal.i
  16.    if Parms.Tag.i = 'FUNCTION' Then
  17.       func = Parms.Xval.i
  18.    if Parms.Tag.i = 'LEVEL' Then
  19.       level = Parms.Xval.i 
  20. end
  21.  
  22. call RxFuncAdd 'RxLoadFuncsCP290', 'RxCP290', 'RxLoadFuncsCP290'
  23. call RxLoadFuncsCP290                      /* Load RxCP290 Routines           */
  24. CP290 = ''                                 /* Initialize Com Port Handle Var  */ 
  25. rc = RxInitCP290('COM2', 'CP290')          /* Initialize Com Port             */
  26. ret = RxDirCmdCP290(CP290, level, func, hcode, module) /* Issue a direct command */
  27. ret = 0
  28. do while ret < 5
  29.    ret = RxCmdUploadCP290(CP290, 'report')  /* Get the Report upon completion  */
  30. end
  31. RxCloseCP290(CP290)                        /* Close Communications            */
  32. Say "Content-type: text/html"
  33. Say
  34. Say "<Head><Title>Demonstration of CGI -> X10 Interface</Title></Head>"
  35. Say "<Body><H1>Results of Command</H1>"
  36. if ret > 5 then
  37.    do
  38.      Say 'Module 'report.1 report.3.1' is now 'report.2
  39.    end
  40. else
  41.      say "Communications Error"
  42. exit
  43.  
  44. /* Do not modify below this line --  Important parsing code... */
  45.  
  46. ParseQueryString: procedure expose Parms. NFields
  47.   Parse arg P
  48.   i = 1
  49.   do while ((P \= '') & (i < 10))
  50.      Parse var P Parms.Text.i '&' rest
  51.      Parse var Parms.Text.i Parms.Tag.i '=' Parms.KeyVal.i
  52.      Parms.Tag.i = translate( Parms.Tag.i)
  53.      Parms.XVal.i=DecodeKeyVal( Parms.KeyVal.i)
  54.      P = rest
  55.      i = i + 1
  56.   end
  57.   NFields = i - 1
  58.   return NFields
  59.  
  60. DecodeKeyVal: procedure
  61.   parse arg Code
  62.   Text=''
  63.   Code=translate(Code, ' ', '+')
  64.   rest='%'
  65.   do while (rest\='')
  66.      Parse var Code T '%' rest
  67.      Text=Text || T
  68.      if (rest\='') then
  69.       do
  70.         ch = left( rest,2)
  71.         c=X2C(ch)
  72.         Text=Text || c
  73.         Code=substr( rest, 3)
  74.       end
  75.   end
  76.   return Text
  77.  
  78.