home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / cpicsamp.zip / runpuppy.cmd < prev   
OS/2 REXX Batch file  |  1995-02-22  |  31KB  |  742 lines

  1. /*       this is a REXX shell                                        */
  2. /* *******************************************************************/
  3. /*                                                                   */
  4. /* MODULE NAME:              RUNPUPPY                                */
  5. /*                                                                   */
  6. /* MODULE TYPE:              CPI-C REXX EXEC                         */
  7. /*                                                                   */
  8. /* Source Library:           $WKS.APPC.CNTL                          */
  9. /*                                                                   */
  10. /* MODULE AUTHORIZATION:     NONE                                    */
  11. /*                                                                   */
  12. /* ABENDS:                   NONE                                    */
  13. /*                                                                   */
  14. /* FUNCTION:                This is an exec that supports cpi-c calls*/
  15. /*                          in the TSO/E and the OS/2 environments.  */
  16. /*                          It accepts a conversation from CPI-C if  */
  17. /*                          one is outstanding, passes the first     */
  18. /*                          receive buffer to the previous envrionmen*/
  19. /*                          to be executed, traps the results, and   */
  20. /*                          sends them back to the requestor.  If    */
  21. /*                          there is no conversation to be accepted, */
  22. /*                          the invocations parms are used to        */
  23. /*                          allocate a conversation with the partner */
  24. /*                          requested, send the remainder of the     */
  25. /*                          invocation parms as a command to be      */
  26. /*                          issued remotely, receives the results,   */
  27. /*                          and displays them in the current env.    */
  28. /*                                                                   */
  29. /*                          The TPNAME can be overriden in the exec. */
  30. /*                                                                   */
  31. /*                                                                   */
  32. /* PARAMETERS:              a) none -- accept a conversation and     */
  33. /*                                     act accordingly               */
  34. /*                          b) symdest//tpname/ cmdstring            */
  35. /*                                                                   */
  36. /*                                                                   */
  37. /*                                                                   */
  38. /*                          example:                                 */
  39. /*                                                                   */
  40. /*                           %runpuppy runblk time                   */
  41. /*                                                                   */
  42. /*                                                                   */
  43. /*                           %runpuppy runl499/USA.xxxxxSPEAK HI */
  44. /*                                                                   */
  45. /*                                                                   */
  46. /*                                                                   */
  47. /* INTERNAL TABLES:         none                                     */
  48. /*                                                                   */
  49. /* CALLED MODULES:          the CPICOMM environment modules:         */
  50. /*                             CMINIT CMALLC CMSEND CMRECV etc.      */
  51. /*                                                                   */
  52. /*                                                                   */
  53. /* CALLING MODULES/Env(s):  Tsobatch                                 */
  54. /*                          Tso                                      */
  55. /*                          Batch                                    */
  56. /*                          NCCF exec                                */
  57. /*                          Boole exec                               */
  58. /*                          Tsobatch under ASCH init(s)              */
  59. /*                                                                   */
  60. /*                          OS/2 attach manager (rel 2.1)            */
  61. /*                                                                   */
  62. /* PROGRAM FLOW:            This is a "State" driven process:        */
  63. /*                                                                   */
  64. /*                          State:       activity:                   */
  65. /*                                                                   */
  66. /*                          reset        cmaccp or cminit            */
  67. /*                          initialize   cmallc                      */
  68. /*                          send         cmsend "ISSUE" CMDSTRING    */
  69. /*                          receive      cmrecv and display          */
  70. /*                                                                   */
  71. /* COPYRIGHT:               Kirk Sticken                             */
  72. /*                          September 15, 1993                       */
  73. /*                                                                   */
  74. /* AUTHOR:                  KIRK STICKEN                             */
  75. /*                          DALLAS ,  TEXAS   75024                  */
  76. /*                                                                   */
  77. /*                                                                   */
  78. /* MODIFICATION RECORD:     NEW PROGRAM 09-15-93 KIRK STICKEN        */
  79. /*                          09/27/93 added retry on alloc rc=2       */
  80. /*                          06/09/94 added auto-define process $wks  */
  81. /*                                                                   */
  82. /*                                                                   */
  83. /*                                                                   */
  84. /*                                                                   */
  85. /* *******************************************************************/
  86.  tracetype="normal"
  87.  select
  88.    when tracetype="normal" then trace normal
  89.    when tracetype="inter"  then trace inter
  90.    when tracetype="all"    then trace all
  91.    otherwise nop
  92.  end
  93.                                        /* conversation_type           */
  94.  cm_basic_conversation           = 0
  95.  cm_mapped_conversation          = 1
  96.                                        /* data_received               */
  97.  cm_no_data_received             = 0
  98.  cm_data_received                = 1
  99.  cm_complete_data_received       = 2
  100.  cm_incomplete_data_received     = 3
  101.                                        /* deallocate_type             */
  102.  cm_deallocate_sync_level        = 0
  103.  cm_deallocate_flush             = 1
  104.  cm_deallocate_confirm           = 2
  105.  cm_deallocate_abend             = 3
  106.                                        /* error_direction             */
  107.  cm_receive_error                = 0
  108.  cm_send_error                   = 1
  109.                                        /* fill                        */
  110.  cm_fill_ll                      = 0
  111.  cm_fill_buffer                  = 1
  112.                                        /* prepare_to_recieve_type     */
  113.  cm_prep_to_receive_sync_level   = 0
  114.  cm_prep_to_receive_flush        = 1
  115.  cm_prep_to_receive_confirm      = 2
  116.                                        /* receive_type                */
  117.  cm_receive_and_wait             = 0
  118.  cm_receive_immediate            = 1
  119.                                        /* request_to_send_received    */
  120.  cm_request_to_send_not_received = 0
  121.  cm_request_to_send_received     = 1
  122.                                        /* return_code                 */
  123.  cm_ok                           = 0
  124.  cm_allocate_failure_no_retry    = 1
  125.  cm_allocate_failure_retry       = 2
  126.  cm_conversion_type_mismatch     = 3
  127.  cm_security_not_valid           = 6
  128.  cm_sync_lvl_not_supported_pgm   = 8
  129.  cm_tpn_not_recognized           = 9
  130.  cm_tp_not_available_no_retry    = 10
  131.  cm_tp_not_available_retry       = 11
  132.  cm_deallocated_abend            = 17
  133.  cm_deallocated_normal           = 18
  134.  cm_parameter_error              = 19
  135.  cm_product_specific_error       = 20
  136.  cm_program_error_no_trunc       = 21
  137.  cm_program_error_purging        = 22
  138.  cm_program_error_trunc          = 23
  139.  cm_program_parameter_check      = 24
  140.  cm_program_state_check          = 25
  141.  cm_resource_failure_no_retry    = 26
  142.  cm_resource_failure_retry       = 27
  143.  cm_unsuccessful                 = 28
  144.  cm_deallocated_abend_svc        = 30
  145.  cm_deallocated_abend_timer      = 31
  146.  cm_svc_error_no_trunc           = 32
  147.  cm_svc_error_purging            = 33
  148.  cm_svc_error_trunc              = 34
  149.                                        /* return_control              */
  150.  cm_when_session_allocated       = 0
  151.  cm_immediate                    = 1
  152.                                        /* send_type                   */
  153.  cm_buffer_data                  = 0
  154.  cm_send_and_flush               = 1
  155.  cm_send_and_confirm             = 2
  156.  cm_send_and_prep_to_receive     = 3
  157.  cm_send_and_deallocate          = 4
  158.                                        /* status_received             */
  159.  cm_no_status_received           = 0
  160.  cm_send_received                = 1
  161.  cm_confirm_received             = 2
  162.  cm_confirm_send_received        = 3
  163.  cm_confirm_dealloc_received     = 4
  164.  
  165.                                        /* sync_level                  */
  166.  cm_none                         = 0
  167.  cm_confirm                      = 1
  168.  
  169.  TBC= "000102030405060708090A0B0C0D0E0F"X ||,  /* 00  */
  170.       "101112131415161718191A1B1C1D1E1F"X ||,  /* 10  */
  171.       "202122232425262728292A2B2C2D2E2F"X ||,  /* 20  */
  172.       "303132333435363738393A3B3C3D3E3F"X ||,  /* 30  */
  173.       "404142434445464748494A4B4C4D4E4F"X ||,  /* 40  */
  174.       "505152535455565758595A5B5C5D5E5F"X ||,  /* 50  */
  175.       "606162636465666768696A6B6C6D6E6F"X ||,  /* 60  */
  176.       "707172737475767778797A7B7C7D7E7F"X ||,  /* 70  */
  177.       "808182838485868788898A8B8C8D8E8F"X ||,  /* 80  */
  178.       "909192939495969798999A9B9C9D9E9F"X ||,  /* 90  */
  179.       "A0A1A2A3A4A5A6A7A8A9AAABACADAEAF"X ||,  /* A0  */
  180.       "B0B1B2B3B4B5B6B7B8B9BABBBCBDBEBF"X ||,  /* B0  */
  181.       "C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF"X ||,  /* C0  */
  182.       "D0D1D2D3D4D5D6D7D8D9DADBDCDDDEDF"X ||,  /* D0  */
  183.       "E0E1E2E3E4E5E6E7E8E9EAEBECEDEEEF"X ||,  /* E0  */
  184.       "F0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF"X      /* F0  */
  185.  EBC= "00010203372D2E2F1605250B0C0D0E0F"X ||,  /* 00  */
  186.       "101112133C3D322618193F271C1D1E1F"X ||,  /* 10  */
  187.       "405A7F7B5B6C507D4D5D5C4E6B604B61"X ||,  /* 20  */
  188.       "F0F1F2F3F4F5F6F7F8F97A5E4C7E6E6F"X ||,  /* 30  */
  189.       "7CC1C2C3C4C5C6C7C8C9D1D2D3D4D5D6"X ||,  /* 40  */
  190.       "D7D8D9E2E3E4E5E6E7E8E9BAE0BBB06D"X ||,  /* 50  */
  191.       "79818283848586878889919293949596"X ||,  /* 60  */
  192.       "979899A2A3A4A5A6A7A8A9C04FD0A107"X ||,  /* 70  */
  193.       "68DC5142434447485253545756586367"X ||,  /* 80  */
  194.       "719C9ECBCCCDDBDDDFECFC70B180BFFF"X ||,  /* 90  */
  195.       "4555CEDE49699A9BABAF5FB8B7AA8A8B"X ||,  /* A0  */
  196.       "2B2C092128656264B4383134334AB224"X ||,  /* B0  */
  197.       "22172906202A46661A35083936303A9F"X ||,  /* C0  */
  198.       "8CAC7273740A757677231514046A783B"X ||,  /* D0  */
  199.       "EE59EBEDCFEFA08EAEFEFBFD8DADBCBE"X ||,  /* E0  */
  200.       "CA8F1BB9B6B5E19D90BDB3DAFAEA3E41"X      /* F0  */
  201.  ASC= "00010203DC09C37FCAB2D50B0C0D0E0F"X ||,  /* 00  */
  202.       "10111213DBDA08C11819C8F21C1D1E1F"X ||,  /* 10  */
  203.       "C4B3C0D9BF0A171BB4C2C5B0B1050607"X ||,  /* 20  */
  204.       "CDBA16BCBBC9CC04B9CBCEDF1415FE1A"X ||,  /* 30  */
  205.       "20FF838485A0C68687A4BD2E3C282B7C"X ||,  /* 40  */
  206.       "268288898AA18C8B8DE121242A293BAA"X ||,  /* 50  */
  207.       "2D2FB68EB7B5C78F80A5DD2C255F3E3F"X ||,  /* 60  */
  208.       "9B90D2D3D4D6D7D8DE603A2340273D22"X ||,  /* 70  */
  209.       "9D616263646566676869AEAFD0ECE7F1"X ||,  /* 80  */
  210.       "F86A6B6C6D6E6F707172A6A791F792CF"X ||,  /* 90  */
  211.       "E67E737475767778797AADA8D1EDE8A9"X ||,  /* A0  */
  212.       "5E9CBEFAB8F5F4ACABF35B5DEEF9EF9E"X ||,  /* B0  */
  213.       "7B414243444546474849F0939495A2E4"X ||,  /* C0  */
  214.       "7D4A4B4C4D4E4F505152FB968197A398"X ||,  /* D0  */
  215.       "5CF6535455565758595AFDE299E3E0E5"X ||,  /* E0  */
  216.       "30313233343536373839FCEA9AEBE99F"X      /* F0  */
  217.  
  218.  state="reset"
  219.  cm_rc.0 ="cm_ok                         "
  220.  cm_rc.1 ="cm_allocate_failure_no_retry  "
  221.  cm_rc.2 ="cm_allocate_failure_retry     "
  222.  cm_rc.3 ="cm_conversion_type_mismatch   "
  223.  cm_rc.6 ="cm_security_not_valid         "
  224.  cm_rc.8 ="cm_sync_lvl_not_supported_pgm "
  225.  cm_rc.9 ="cm_tpn_not_recognized         "
  226.  cm_rc.10="cm_tp_not_available_no_retry  "
  227.  cm_rc.11="cm_tp_not_available_retry     "
  228.  cm_rc.17="cm_deallocated_abend          "
  229.  cm_rc.18="cm_deallocated_normal         "
  230.  cm_rc.19="cm_parameter_error            "
  231.  cm_rc.20="cm_product_specific_error     "
  232.  cm_rc.21="cm_program_error_no_trunc     "
  233.  cm_rc.22="cm_program_error_purging      "
  234.  cm_rc.23="cm_program_error_trunc        "
  235.  cm_rc.24="cm_program_parameter_check    "
  236.  cm_rc.25="cm_program_state_check        "
  237.  cm_rc.26="cm_resource_failure_no_retry  "
  238.  cm_rc.27="cm_resource_failure_retry     "
  239.  cm_rc.28="cm_unsuccessful               "
  240.  cm_rc.30="cm_deallocated_abend_svc      "
  241.  cm_rc.31="cm_deallocated_abend_timer    "
  242.  cm_rc.32="cm_svc_error_no_trunc         "
  243.  cm_rc.33="cm_svc_error_purging          "
  244.  cm_rc.34="cm_svc_error_trunc            "
  245.  hadparms="Y"
  246.  arg destname cmdline
  247.  tpn=""
  248.  if pos("/",destname)>0 then ,
  249.    do
  250.      i=pos("/",destname)
  251.      tpn=substr(destname,i+1)
  252.      destname=substr(destname,1,i-1)
  253.    end
  254.  if length(cmdline)=0 then cmdline="DIR"
  255.  if length(destname)=0 then ,
  256.    do
  257.      destname="RUNBLK"
  258.      hadparms="N"
  259.    end
  260.  wk=0
  261.  allocates=0
  262.  rck=0
  263.  wk=0
  264.  wrc=0
  265.  cminitk=0
  266.  sendfl="n"
  267.  rcvfl="n"
  268.  oldenv=address()
  269.  address cpicomm
  270.  qk=queued()
  271.  do i=1 to qk
  272.    pull
  273.  end
  274.  wt=time(r)
  275.  do until state="done"
  276.    select
  277.      when tracetype="normal" then nop
  278.      when tracetype="inter"  then push substr(state"..........",1,10) ,
  279.                                       date() time(r)
  280.      when tracetype="all"    then push substr(state"..........",1,10) ,
  281.                                       date() time(r)
  282.      otherwise nop
  283.    end
  284.    select
  285.      when state="send" then ,
  286.        do
  287.          if sendfl="Y" ,
  288.           & rcvfl="Y"   then state="dealloc"
  289.          else ,
  290.            if rcvfl="Y" then ,
  291.              do
  292.                wk=wk+1
  293.                if wk=rck then ,
  294.                  sendfl="Y"
  295.                text="RESULT:"txrcv.wk
  296.                textl=length(text)
  297.                if oldenv="CMD" ,
  298.                | oldenv="PMREXX" then ,
  299.                  text=translate(text,EBC,TBC)
  300.               "cmsend convid text textl rts_rcvd return_code"
  301.                if return_code=cm_ok then ,
  302.                  if rts_rcvd = cm_req_to_send_received then
  303.                    state="receive"
  304.                  else nop
  305.                else state="error"
  306.              end
  307.            else ,
  308.              do
  309.                text="ISSUE" cmdline
  310.                textl=length(text)
  311.                if oldenv="CMD" ,
  312.                | oldenv="PMREXX" then ,
  313.                  text=translate(text,EBC,TBC)
  314.                sendfl="Y"
  315.               "cmsend convid text textl rts_rcvd return_code"
  316.                if return_code=cm_ok then ,
  317.                  if rts_rcvd = cm_req_to_send_received then
  318.                    state="receive"
  319.                  else state="receive"
  320.                else state="error"
  321.              end
  322.        end
  323.      when state="receive" then ,
  324.        do
  325.          textl=500
  326.          rcvfl="Y"
  327.         "cmrcv convid text  textl       data_rcvd" ,
  328.                      "textl status_rcvd rts_rcvd" ,
  329.                      "return_code"
  330.          select
  331.            when   status_rcvd=cm_send_received ,
  332.                 & data_rcvd=cm_no_data_received ,
  333.                   then                 state="send"
  334.            when   status_rcvd=cm_send_received  ,
  335.                 & data_rcvd=cm_data_received ,
  336.                   then                 state="send"
  337.            when   status_rcvd=cm_send_received  ,
  338.                 & data_rcvd=cm_complete_data_received ,
  339.                   then                 state="send"
  340.            when   status_rcvd=cm_send_received  ,
  341.                 & data_rcvd=cm_incomplete_data_received ,
  342.                   then                 state="send-pending"
  343.            when   status_rcvd=cm_confirm_received ,
  344.                   then                 state="confirm"
  345.            when   status_rcvd=cm_confirm_send_received ,
  346.                   then                 state="confirm-send"
  347.            when   status_rcvd=cm_confirm_dealloc_received ,
  348.                   then                 state="confirm-dealloc"
  349.            otherwise nop
  350.          end
  351.          select
  352.            when data_rcvd=cm_no_data_received then nop
  353.            when data_rcvd=cm_data_received      ,
  354.               | data_rcvd=cm_complete_data_received      ,
  355.               | data_rcvd=cm_incomplete_data_received then ,
  356.              do
  357.                rck=rck+1
  358.                txrcv.rck=substr(text,1,textl)
  359.                if oldenv="CMD" ,
  360.                 | oldenv="PMREXX" then ,
  361.                  txrcv.rck=translate(txrcv.rck,ASC,TBC)
  362.                select
  363.                  when tracetype="normal" then say txrcv.rck
  364.                  when tracetype="all"    then ,
  365.                       say "flm000i rcvd:("txrcv.rck")"
  366.                  when tracetype="inter"  then ,
  367.                       say "flm000i rcvd:("txrcv.rck")"
  368.                  otherwise say txrcv.rck
  369.                end
  370.  
  371.  
  372.                if word(txrcv.rck,1)="ISSUE" then ,
  373.                  do
  374.                    wt1=delword(txrcv.rck,1,1)
  375.                    wt1=translate(wt1,"'","""")
  376.                    address value oldenv
  377.                    if oldenv="TSO" then ,
  378.                      do
  379.                       "execio 0 diskw sysprint (finis)"
  380.                       "execio 0 diskw vtocout (finis)"
  381.                        zz=outtrap("rslt.","*")
  382.                      end
  383.                    else ,
  384.                      if oldenv="CMD" ,
  385.                       | oldenv="PMREXX" then ,
  386.                        wt1=wt1 "> c:\tmp\runpuppy.rof"
  387.                      else  nop
  388.                    wt1
  389.                    wrc=rc
  390.                    if oldenv="TSO" then ,
  391.                      do
  392.                        zz=outtrap("OFF")
  393.                        do kk=1 to rslt.0
  394.                          rck=rck+1
  395.                          txrcv.rck=rslt.kk
  396.                        end
  397.                       "execio * diskr sysprint" ,
  398.                           "(stem sysprint. finis)"
  399.                        do kk=1 to sysprint.0
  400.                          rck=rck+1
  401.                          txrcv.rck=strip(sysprint.kk)
  402.                        end
  403.                       "execio * diskr vtocout" ,
  404.                           "(stem vtocout. finis)"
  405.                        do kk=1 to vtocout.0
  406.                          rck=rck+1
  407.                          txrcv.rck=strip(vtocout.kk)
  408.                        end
  409.                        rck=rck+1
  410.                        txrcv.rck="rc="wrc
  411.                        address cpicomm
  412.                      end
  413.                    else ,
  414.                      if oldenv="CMD" ,
  415.                       | oldenv="PMREXX" then ,
  416.                        do
  417.                          of="c:\tmp\runpuppy.rof"
  418.                          if exist(of) then ,
  419.                            do
  420.                              DO WHILE LINES(of) <> 0
  421.                                oBuffer = LineIn(of)
  422.                                rck=rck+1
  423.                                txrcv.rck=oBuffer
  424.                              END
  425.                            end
  426.                          address cpicomm
  427.                          rck=rck+1
  428.                          txrcv.rck="rc="wrc
  429.                        end
  430.                      else nop
  431.                  end
  432.              end
  433.            otherwise nop
  434.          end
  435.          if return_code=cm_ok then nop
  436.          else  state="error"
  437.        end
  438.      when state="dealloc" then ,
  439.        do
  440.         "cmdeal convid return_code"
  441.          if return_code=cm_ok then state="done"
  442.          else state="error"
  443.        end
  444.      when state="confirm" then ,
  445.        do
  446.         "cmcfmd convid return_code"
  447.          if return_code=cm_ok then state="receive"
  448.          else state="error"
  449.        end
  450.      when state="confirm-send" then ,
  451.        do
  452.         "cmcfmd convid return_code"
  453.          if return_code=cm_ok then state="send"
  454.          else state="error"
  455.        end
  456.      when state="confirm-dealloc" then ,
  457.        do
  458.         "cmcfmd convid return_code"
  459.          if return_code=cm_ok then state="done"
  460.          else state="error"
  461.        end
  462.      when state="send-pending" then ,
  463.        do
  464.          textl=500
  465.         "cmrcv convid text  textl       data_rcvd" ,
  466.                      "textl status_rcvd rts_rcvd" ,
  467.                      "return_code"
  468.          select
  469.            when data_rcvd=cm_no_data_received then ,
  470.               state="send"
  471.            when data_rcvd=cm_data_received      ,
  472.               | data_rcvd=cm_complete_data_received      ,
  473.               | data_rcvd=cm_incomplete_data_received then ,
  474.              do
  475.                rck=rck+1
  476.                txrcv.rck=substr(text,1,textl)
  477.                if oldenv="CMD" ,
  478.                 | oldenv="PMREXX" then ,
  479.                  txrcv.rck=translate(txrcv.rck,ASC,TBC)
  480.                select
  481.                  when tracetype="normal" then say txrcv.rck
  482.                  when tracetype="all"    then ,
  483.                       say "flm000i rcvd:("txrcv.rck")"
  484.                  when tracetype="inter"  then ,
  485.                       say "flm000i rcvd:("txrcv.rck")"
  486.                  otherwise say txrcv.rck
  487.                end
  488.                if word(txrcv.rck,1)="ISSUE" then ,
  489.                  do
  490.                    wt1=delword(txrcv.rck,1,1)
  491.                    wt1=translate(wt1,"'","""")
  492.                    address value oldenv
  493.                    if oldenv="TSO" then ,
  494.                      do
  495.                       "execio 0 diskw sysprint (finis)"
  496.                       "execio 0 diskw vtocout (finis)"
  497.                        zz=outtrap("rslt.","*")
  498.                      end
  499.                    else ,
  500.                      if oldenv="CMD" ,
  501.                      | oldenv="PMREXX" then ,
  502.                        wt1=wt1 "> c:\tmp\runpuppy.rof"
  503.                      else  nop
  504.                    wt1
  505.                    wrc=rc
  506.                    if oldenv="TSO" then ,
  507.                      do
  508.                        zz=outtrap("OFF")
  509.                        do kk=1 to rslt.0
  510.                          rck=rck+1
  511.                          txrcv.rck=rslt.kk
  512.                        end
  513.                       "execio * diskr sysprint" ,
  514.                           "(stem sysprint. finis)"
  515.                        do kk=1 to sysprint.0
  516.                          rck=rck+1
  517.                          txrcv.rck=strip(sysprint.kk)
  518.                        end
  519.                       "execio * diskr vtocout" ,
  520.                           "(stem vtocout. finis)"
  521.                        do kk=1 to vtocout.0
  522.                          rck=rck+1
  523.                          txrcv.rck=strip(vtocout.kk)
  524.                        end
  525.                        rck=rck+1
  526.                        txrcv.rck="rc="wrc
  527.                        address cpicomm
  528.                      end
  529.                    else ,
  530.                      if oldenv="CMD" ,
  531.                      | oldenv="PMREXX" then ,
  532.                        do
  533.                          of="c:\tmp\runpuppy.rof"
  534.                          if exist(of) then ,
  535.                            do
  536.                              DO WHILE LINES(of) <> 0
  537.                                oBuffer = LineIn(of)
  538.                                rck=rck+1
  539.                                txrcv.rck=oBuffer
  540.                              END
  541.                            end
  542.                          address cpicomm
  543.                          rck=rck+1
  544.                          txrcv.rck="rc="wrc
  545.                        end
  546.                      else nop
  547.                  end
  548.              end
  549.            otherwise nop
  550.          end
  551.          if return_code=cm_ok then nop
  552.          else state="error"
  553.        end
  554.      when state="error" then ,
  555.        do
  556.          if return_code=cm_deallocated_normal then nop
  557.          else ,
  558.            do
  559.              say "error rc="return_code cm_rc.return_code
  560.              say "state footprints"
  561.            end
  562.          state="done"
  563.        end
  564.      when state="reset" then ,
  565.        do
  566.          cminitk=cminitk+1
  567.          if oldenv="TSO" then ,
  568.            do
  569.             "cmaccp convid return_code"
  570.              if return_code=cm_ok then state="receive"
  571.              else ,
  572.                do
  573.                  sym_dest_name=destname
  574.                 "cminit convid sym_dest_name return_code"
  575.                  select
  576.                    when tracetype="normal" then nop
  577.                    when tracetype="all"    then ,
  578.                         say "init rc" ,
  579.                             return_code ,
  580.                             "for" sym_dest_name
  581.                    when tracetype="inter"  then ,
  582.                         say "init rc" ,
  583.                             return_code ,
  584.                             "for" sym_dest_name
  585.                    otherwise ,
  586.                         say "init rc" ,
  587.                             return_code ,
  588.                             "for" sym_dest_name
  589.                  end
  590.                  if return_code = cm_ok then ,
  591.                    do
  592.                      state="initialize"
  593.                      if length(tpn)>0 then ,
  594.                        do
  595.                          tpnl=length(tpn)
  596.                         "cmstpn convid tpn tpnl return_code"
  597.                          if return_code=cm_ok then nop
  598.                          else ,
  599.                            do
  600.                              say "flt000i tpn error="return_code
  601.                              state="error"
  602.                            end
  603.                        end
  604.                    end
  605.                  else state="error"
  606.                end
  607.            end
  608.          else ,
  609.            do
  610.              if hadparms="N" then ,
  611.                do
  612.                 "cmaccp convid return_code"
  613.                  if return_code=cm_ok then state="receive"
  614.                  else state="error"
  615.                end
  616.              else ,
  617.                do
  618.                  sym_dest_name=destname
  619.                 "cminit convid sym_dest_name return_code"
  620.                  select
  621.                    when tracetype="normal" then nop
  622.                    when tracetype="all"    then ,
  623.                         say "init rc" ,
  624.                             return_code ,
  625.                             "for" sym_dest_name
  626.                    when tracetype="inter"  then ,
  627.                         say "init rc" ,
  628.                             return_code ,
  629.                             "for" sym_dest_name
  630.                    otherwise ,
  631.                         say "init rc" ,
  632.                             return_code ,
  633.                             "for" sym_dest_name
  634.                  end
  635.                  if return_code = cm_ok then ,
  636.                    do
  637.                      state="initialize"
  638.                      if length(tpn)>0 then ,
  639.                        do
  640.                          tpnl=length(tpn)
  641.                         "cmstpn convid tpn tpnl return_code"
  642.                          if return_code=cm_ok then nop
  643.                          else ,
  644.                            do
  645.                              say "flt000i tpn error="return_code
  646.                              state="error"
  647.                            end
  648.                        end
  649.                    end
  650.                  else ,
  651.                    if cminitk<2 then ,
  652.                      do
  653.                        modename="LU62MVS "
  654.                        key=substr(destname"        ",1,8)
  655.                        if length(tpn)>1 then nop
  656.                        else ,
  657.                        tpn="USA.xxxxxx.RUNPUPPY"
  658.                        s.sym_dest_name=key
  659.                        s.partner_LU_name="APPCMVS"
  660.                        s.TP_name = tpn
  661.                        s.mode_name=modename
  662.                        s.TP_name_type=0
  663.                        s.conversation_security_type=1
  664.                        s.security_user_id="@boole8"
  665.                        s.security_password="xxxxxxxx"
  666.                        SIDEL=124
  667.                       "XCMSSI key s sidel cmrc"
  668.                      end
  669.                    else ,
  670.                      state="error"
  671.                end
  672.            end
  673.        end
  674.      when state="initialize" then ,
  675.        do
  676.         "cmallc convid return_code"
  677.          if return_code = cm_ok then state="send"
  678.          else ,
  679.            if return_code=cm_allocate_failure_retry ,
  680.             | return_code=cm_program_parameter_check then ,
  681.              do
  682.                allocates=allocates+1
  683.                if allocates>1 then state="error"
  684.                else nop
  685.              end
  686.            else state="error"
  687.        end
  688.      otherwise state="error"
  689.    end
  690.  end
  691.  address oldenv
  692.  if substr(txrcv.rck,1,10)="RESULT:rc=" then ,
  693.    do
  694.      wt1=substr(txrcv.rck,11)
  695.      num1=word(wt1,1)
  696.      wrc=num1+00
  697.    end
  698.  k=0
  699.  qk=queued()
  700.  do i=1 to qk
  701.    pull wt1
  702.    parse value wt1 with state dd mmm yyyy int
  703.    if k=0 then ,
  704.      do
  705.        k=1
  706.        stab.1=state
  707.        scnt.1=1
  708.        sint.1=int
  709.      end
  710.    else ,
  711.      do
  712.        found="N"
  713.        do j=1 to k
  714.          if stab.j=state then ,
  715.            do
  716.              found="Y"
  717.              scnt.j=1 + scnt.j
  718.              sint.j=int +sint.j
  719.            end
  720.        end
  721.        if found="N" then ,
  722.          do
  723.            k=k+1
  724.            stab.k=state
  725.            scnt.k=1
  726.            sint.k=int
  727.          end
  728.      end
  729.    say "..." format(1-i,4,0) wt1
  730.  end
  731.  do i=1 to k
  732.    avg=sint.i/scnt.i
  733.    say stab.i "average" avg
  734.  end
  735.  exit wrc
  736. EXIST:
  737.     parse arg fname
  738.     IF LENGTH(STREAM(fname,'C','QUERY EXISTS')) > 0
  739.         THEN RC = 1
  740.         ELSE RC = 0
  741. RETURN RC
  742.