home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l360 / 3.ddi / APPC.@EM / BATTAPPC.CBL < prev    next >
Encoding:
Text File  |  1991-04-08  |  29.4 KB  |  647 lines

  1.       $set mf ans85 noosvs
  2.       *******************************************************************
  3.       *                                                                 *
  4.       *                                                                 *
  5.       *                  (C) Micro Focus Ltd. 1990                      *
  6.       *                                                                 *
  7.       *                         BATTAPPC.CBL                            *
  8.       *                                                                 *
  9.       *      COBOL Advanced Program to Program (APPC) Demonstration     *
  10.       *                                                                 *
  11.       *                         Battleships                             *
  12.       *                    communications module                        *
  13.       *                                                                 *
  14.       *******************************************************************
  15.  
  16.       *******************************************************************
  17.       *        BATTAPPC - links two battleships games using APPC        *
  18.       *                                                                 *
  19.       *  This program is called by BATTLEL & BATTLER to communicate     *
  20.       *  between one another.                                           *
  21.       *                                                                 *
  22.       *  The communications that take place are:                        *
  23.       *        - to bring up a link between the two programs            *
  24.       *        - to take down a link                                    *
  25.       *        - to send coordinates to a program                       *
  26.       *        - to receive coordinates from a program                  *
  27.       *        - to send a damage report to a program                   *
  28.       *        - to receive a damage report from a program              *
  29.       *                                                                 *
  30.       *  The method of communication is entirey transparent to the      *
  31.       *  users of the game.  So long as the same interface is used,     *
  32.       *  this module could be replaced by one which used a different    *
  33.       *  communications protocol.                                       *
  34.       *                                                                 *
  35.       *  The interface consists of two parameters.  The first parameter *
  36.       *  is the operation code - indicating which function to perform.  *
  37.       *  The second parameter is a buffer area which is used to pass    *
  38.       *  information between the communicating programs.                *
  39.       *                                                                 *
  40.       *  The result of any operation is returned to the calling program *
  41.       *  in the RETURN-CODE system variable.  A zero value indicates    *
  42.       *  success and a non-zero value indicates some error  - In this   *
  43.       *  example program, the error handling is very simple - in that   *
  44.       *  the programs will stop if any error is received.  You may,     *
  45.       *  however, decide to provide more intelligent error handling, in *
  46.       *  which the user of the game may be given alternative courses of *
  47.       *  action when such an error occurs.                              *
  48.       *                                                                 *
  49.       *******************************************************************
  50.        Special-names.
  51.            call-convention 3 is api.
  52.  
  53.        Working-Storage Section.
  54.        copy "appc.cpy".
  55.        copy "acssvc.cpy".
  56.  
  57.       *-----------------------------------------------------------------
  58.       * Working variables
  59.       *-----------------------------------------------------------------
  60.        01  tp-name                     pic x(64) value spaces.
  61.        78  tp-name-len                 value 64.
  62.        01  tp-id                       pic x(8) value spaces.
  63.        01  lu-alias                    pic x(8) value spaces.
  64.        01  plu-alias                   pic x(8) value spaces.
  65.        01  conv-id                     pic x(4) value spaces.
  66.        01  mode-name                   pic x(8) value spaces.
  67.        78  mode-name-len               value 8.
  68.  
  69.        01  what-received               pic 9(4) comp-x.
  70.        01  request-to-send-received    pic 9(2) comp-x.
  71.        01  state-flag                  pic 9(2) comp-x.
  72.            88 Sending-State            value 1.
  73.            88 Receiving-State          value 0.
  74.  
  75.        01  data-buffer-length          pic 9(4) comp-5.
  76.        01  data-buffer-ptr             usage pointer.
  77.        01  data-buffer-address
  78.            redefines data-buffer-ptr.
  79.            03 data-buffer-offset       pic 9(4) comp-5.
  80.            03 data-buffer-selector     pic 9(4) comp-5.
  81.        01  alloc-flags                 pic 9(4) comp-5 value 1.
  82.        01  key-char pic x.
  83.  
  84.  
  85.       *-----------------------------------------------------------------
  86.       * following items used for constructing error message
  87.       *-----------------------------------------------------------------
  88.        01  bin-dword.
  89.            03 bin-dword-msw            pic 9(4) comp-x.
  90.            03 bin-dword-lsw            pic 9(4) comp-x.
  91.        01  bin-val.
  92.            03 bin-val-1                pic 9(2) comp-x.
  93.            03 bin-val-2                pic 9(2) comp-x.
  94.  
  95.        01  hex-idx-1                   pic 9(2) comp-x.
  96.        01  hex-idx-2                   pic 9(2) comp-x.
  97.        01  hex-disp                    pic x(4).
  98.        01  hex-string                  pic x(16)
  99.                                       value "0123456789ABCDEF".
  100.        01  clear-char                  pic x value " ".
  101.        01  clear-attr                  pic 9(2) comp-x value 7.
  102.        01  screen-pos                  pic 9(4) comp-x value h"0100".
  103.        01  error-msg.
  104.            03 filler                   pic x(25)
  105.                                       value 'APPC/ACSSVC Error Verb=x"'.
  106.            03 error-1                  pic x(4).
  107.            03 filler                   pic x(17)
  108.                                       value '" Primary Code=x"'.
  109.            03 error-2                  pic x(4).
  110.            03 filler                   pic x(19)
  111.                                       value '" Secondary Code=x"'.
  112.            03 error-3                  pic x(4).
  113.            03 error-4                  pic x(4).
  114.            03 filler                   pic x value '"'.
  115.  
  116.       *-----------------------------------------------------------------
  117.       *  interface paramters
  118.        LINKAGE SECTION.
  119.       *-----------------------------------------------------------------
  120.        01 Comm-Code                    Pic 9(2) Comp.
  121.        01 Comm-Buffer                  Pic x(12).
  122.  
  123.       *-----------------------------------------------------------------
  124.        01 Shared-Segment-Buffer        Pic x(12).
  125.       *    This is a special linkage item - not used as a parameter -
  126.       *    but as a buffer whose address is set to a shared unnamed
  127.       *    segment, allocated later on.  This type of memory is
  128.       *    required by some APPC verbs - see later for details
  129.       *
  130.       *-----------------------------------------------------------------
  131.  
  132.  
  133.       *=================================================================
  134.       *
  135.       *---------------------Call Interface------------------------------
  136.        PROCEDURE DIVISION using
  137.                                    by value Comm-Code
  138.                                    by reference Comm-Buffer.
  139.       *-----------------------------------------------------------------
  140.       *=================================================================
  141.  
  142.  
  143.       *-----------------------------------------------------------------
  144.        Evaluate-Operation.
  145.       *    work out which high level operation to perform
  146.       *
  147.       *-----------------------------------------------------------------
  148.            Evaluate Comm-Code
  149.                When 1      Perform Bring-Up-Link
  150.                When 2      Perform Take-Down-Link
  151.                When 3      Perform Send-Coords
  152.                When 4      Perform Receive-Coords
  153.                When 5      Perform Send-Report
  154.                When 6      Perform Receive-Report
  155.                When other  move 1 to Return-Code
  156.            End-Evaluate
  157.            move 0 to Return-Code
  158.            Exit Program.
  159.  
  160.       *-----------------------------------------------------------------
  161.        Error-Exit.
  162.       *  quick exit in case of error during APPC
  163.       *
  164.       *-----------------------------------------------------------------
  165.            move 1 to Return-Code
  166.            Exit Program.
  167.  
  168.       *-----------------------------------------------------------------
  169.        Bring-Up-Link.
  170.       *    High level function to initiate a communication between
  171.       *    two transaction programs playing the game.
  172.       *
  173.       *    The verbs issued to start a conversation are  different
  174.       *    for each program - only one end may start the communication
  175.       *    with a MC-ALLOCATE verb - this is received at the other end
  176.       *    by a RECEIVE-ALLOCATE verb.
  177.       *
  178.       *    The LU-ALIAS, partner LU-ALIAS, MODE-NAME and TP-NAME which
  179.       *    are defined in the configuration profile for this
  180.       *    communication are placed in variables for various verbs to
  181.       *    use.  These names must match up with those defined in the
  182.       *    configuration currently active - switch to the
  183.       *    communications Manager session and check to see that the
  184.       *    correct profile is loaded.
  185.       *
  186.       *    Some fields passed in the Verb Control Block have to be
  187.       *    defined in EBCDIC - all of these fields are converted from
  188.       *    ASCII using a special utility routine provided as part
  189.       *    of the Communications Manager software (ie. ACSSVC.DLL)  -
  190.       *    this is done initially and the converted fields are saved in
  191.       *    temporary variables for later use.
  192.       *
  193.       *    The other verbs (seen in capitals) are used to request
  194.       *    resources of APPC before a conversation starts (TP-STARTED)
  195.       *    and is only required on the MC-ALLOCATE side.  The other
  196.       *    verb (ie MC-FLUSH) causes the allocation request to be sent
  197.       *    to the remote machine immediately - this is because send
  198.       *    buffers are not normally sent off until a buffer becomes
  199.       *    full - so as to minimise on transmissions.  The MC-FLUSH
  200.       *    verb is useful in this situation if you want a remote
  201.       *    program to connect immediately.
  202.       *
  203.       *    Comm-buffer is used to tell this module which program is
  204.       *    calling it - so that it can decide which set of verbs to
  205.       *    issue.
  206.       *
  207.       *-----------------------------------------------------------------
  208.            If Comm-Buffer = "PLAYER1"
  209.       *            local end
  210.       *            initialise configuration names
  211.                move 'DEMOPLU1' to plu-alias
  212.                move 'DEMOLU1 ' to lu-alias
  213.                move 'DEMOMODE' to mode-name
  214.                move 'BATTLE  ' to tp-name
  215.       *            convert to EBCDIC
  216.                Perform Convert-Tp-Name
  217.                Perform Convert-Mode-Name
  218.       *            issue APPC verbs to request resources and send
  219.       *            immediate an allocation request to the remote machine
  220.                Perform TP-STARTED
  221.                Perform MC-ALLOCATE
  222.                Perform MC-FLUSH
  223.            Else
  224.       *            remote end
  225.       *            initialise configuration name
  226.                move 'BATTLE  ' to Tp-Name
  227.       *            convert to EBCDIC
  228.                Perform Convert-Tp-Name
  229.       *            issue APPC verb to receive allocation request
  230.                Perform RECEIVE-ALLOCATE
  231.            End-If
  232.       *       allocate a buffer to be used by send and receive verbs
  233.            Perform Allocate-Shared-Memory.
  234.  
  235.       *-----------------------------------------------------------------
  236.        Allocate-Shared-Memory.
  237.       *    Send and receive verbs: MC-SEND-DATA and MC-RECEIVE-AND-WAIT
  238.       *    require the data buffer used as one of their parameters to
  239.       *    be an unnamed shared segment - this is allocated with
  240.       *    the DosAllocSeg api call with alloc-flag = 1
  241.       *
  242.       *-----------------------------------------------------------------
  243.            move zero to Data-Buffer-Offset
  244.            move Length of Comm-Buffer to Data-Buffer-Length
  245.            move 1 to Alloc-Flags
  246.       *        for COBOL/2 Toolset, do next statement
  247.       *        call "cobolapi"
  248.            call "__DosAllocSeg" using
  249.                            by value Alloc-Flags
  250.                            by reference Data-Buffer-Selector
  251.                            by value Data-Buffer-Length
  252.            If RETURN-CODE not = zero
  253.                Go to Error-Exit
  254.            End-If.
  255.  
  256.  
  257.       *-----------------------------------------------------------------
  258.        Take-Down-Link.
  259.       *    This high level routine stops a conversation and releases
  260.       *    resources used by the conversation.
  261.       *
  262.       *    The conversation is stopped at the sending end, ie the
  263.       *    machine at which the last send verb was issued,  with
  264.       *    the verb MC-DEALLOCATE.
  265.       *
  266.       *    The MC-DEALLOCATE verb is issued with type FLUSH which
  267.       *    performs the same function as MC-FLUSH before the
  268.       *    deallocation is sent - causing any unsent buffers to be
  269.       *    transmitted.
  270.       *
  271.       *    The MC-RECEIVE-AND-WAIT is the verb issued at the receiving
  272.       *    end, ie the machine at which the last receive verb was
  273.       *    issued.  This verb waits until the deallocation signal
  274.       *    arrives from the sending end.
  275.       *
  276.       *    The TP-ENDED verb is used to release resources at both
  277.       *    ends of the terminated conversation.
  278.       *
  279.       *-----------------------------------------------------------------
  280.            If Sending-State
  281.                Perform MC-DEALLOCATE
  282.            Else
  283.                Perform MC-RECEIVE-AND-WAIT
  284.            End-If
  285.            Perform TP-ENDED.
  286.  
  287.  
  288.       *-----------------------------------------------------------------
  289.        Send-Coords.
  290.       *    This high level operation sends coordinates contained in
  291.       *    the buffer to be sent to the remote machine and then makes
  292.       *    ready to receive a damage report from it.
  293.       *
  294.       *    MC-SEND-DATA causes the contents of the buffer to be sent
  295.       *    to the particular LU defined.
  296.       *
  297.       *    After successful completion of MC-SEND-DATA , the
  298.       *    conversation is placed in receive state by the
  299.       *    MC-PREPARE-TO-RECEIVE verb - this is in readiness to receive
  300.       *    the damage report of the coordinates specified.
  301.       *
  302.       *    The MC-PREPARE-TO-RECEIVE also flushes the send buffer so
  303.       *    that nothing is left before any receive verbs take place.
  304.       *
  305.       *-----------------------------------------------------------------
  306.            set address of Shared-Segment-Buffer to Data-Buffer-Ptr
  307.            move Comm-Buffer to Shared-Segment-Buffer
  308.            Perform MC-SEND-DATA
  309.            Perform MC-PREPARE-TO-RECEIVE.
  310.  
  311.       *-----------------------------------------------------------------
  312.        Receive-Report.
  313.       *    The damage report is received using the verb
  314.       *    MC-RECEIVE-AND-WAIT.  This verb waits indefinitely for the
  315.       *    remote machine to send data.  When something is received
  316.       *    a check is made that the data received is complete - if you
  317.       *    are sending large amounts of information, data may be
  318.       *    contained in several buffers and the 'what-received' verb
  319.       *    contains a code to indicate if the buffer is complete or
  320.       *    not.  This routine performs a loop issuing the verb until
  321.       *    the last buffer arrives.
  322.       *
  323.       *-----------------------------------------------------------------
  324.            move zero to what-received
  325.            perform until what-received = ap-data-complete
  326.                Perform MC-RECEIVE-AND-WAIT
  327.            end-perform
  328.            set address of Shared-Segment-Buffer to Data-Buffer-Ptr
  329.            move Shared-Segment-Buffer to Comm-Buffer.
  330.  
  331.  
  332.       *-----------------------------------------------------------------
  333.        Receive-Coords.
  334.       *    The coordinates are received using the MC-RECEIVE-AND-WAIT
  335.       *    verb.  The buffer is received followed by a signal from the
  336.       *    remote machine that it is ready to receive - so that the
  337.       *    local end can send the damage report.  The signal passed to
  338.       *    the MC-RECEIVE-AND-WAIT verb is contained in the
  339.       *    'what-received' field.
  340.       *
  341.       *-----------------------------------------------------------------
  342.            move zero to what-received
  343.            perform until what-received = ap-send
  344.                Perform MC-RECEIVE-AND-WAIT
  345.            end-perform
  346.            set address of Shared-Segment-Buffer to Data-Buffer-Ptr
  347.            move Shared-Segment-Buffer to Comm-Buffer.
  348.  
  349.  
  350.       *-----------------------------------------------------------------
  351.        Send-Report.
  352.       *    This sends the buffer using an MC-SEND-DATA verb followed
  353.       *    by MC-FLUSH to transmit the buffer.
  354.       *
  355.       *-----------------------------------------------------------------
  356.            set address of Shared-Segment-Buffer to Data-Buffer-Ptr
  357.            move Comm-Buffer to Shared-Segment-Buffer
  358.            Perform MC-SEND-DATA
  359.            Perform MC-FLUSH.
  360.  
  361.  
  362.       *=================================================================
  363.       *=================================================================
  364.       *-----------------------------------------------------------------
  365.       *    The conversion routines below use a service utility called
  366.       *    the Common Services Programming Interface.  It provides:
  367.       *       -  ASCII/EBCDIC conversion in both directions
  368.       *       -  traces API verbs and data
  369.       *       -  provides translation tables for specified code pages
  370.       *       -  records messages in CM message log
  371.       *       -  sends network management messages to a network
  372.       *            management service
  373.       *
  374.       *    Here we only use it for ASCII-EBCDIC using the CONVERT verb
  375.       *
  376.       *-----------------------------------------------------------------
  377.       * ASCII-EBCDIC conversion routines
  378.  
  379.        Convert-Mode-Name.
  380.            move all x"00" to VCB
  381.            move sv-convert to opcode-cvt
  382.            move sv-ascii-to-ebcdic to direction-cvt
  383.            move sv-a to char-set-cvt
  384.            move mode-name-len to len-cvt
  385.            set src-ptr-cvt to address of mode-name
  386.            set targ-ptr-cvt to address of mode-name
  387.            perform Execute-Acssvc-Verb
  388.            perform Check-Error.
  389.  
  390.        Convert-Tp-Name.
  391.            move all x"00" to VCB
  392.            move sv-convert to opcode-cvt
  393.            move sv-ascii-to-ebcdic to direction-cvt
  394.            move sv-ae to char-set-cvt
  395.            move tp-name-len to len-cvt
  396.            set src-ptr-cvt to address of tp-name
  397.            set targ-ptr-cvt to address of tp-name
  398.            perform Execute-Acssvc-Verb
  399.            perform Check-Error.
  400.  
  401.       *-----------------------------------------------------------------
  402.       *
  403.       * The following routines define the call interfaces to the
  404.       * various APPC verbs required above
  405.       *
  406.       *
  407.       *-----------------------------------------------------------------
  408.  
  409.       *-----------------------------------------------------------------
  410.        Receive-Allocate.
  411.       *    wait receipt of allocation request from local machine
  412.       *    and then start a new transaction program
  413.       *
  414.       *    The VCB should always be initialized with low values before
  415.       *    any fields are loaded.  The verb returns a tp-id and a
  416.       *    conv-id which are to be used by subsequent verbs during the
  417.       *    conversation.
  418.       *
  419.       *    LU-Alias, PLU-Alias and mode name of the session are also
  420.       *    returned.
  421.       *
  422.       *    A check on the return codes should always be made after
  423.       *    issuing a verb.  In this case an error causes an immediate
  424.       *    return to the calling program to occur.
  425.       *
  426.       *-----------------------------------------------------------------
  427.            move all x"00" to VCB
  428.            move ap-receive-allocate to opcode-ral
  429.            move tp-name to tp-name-ral
  430.            set Receiving-State to True
  431.            perform Execute-Appc-Verb
  432.            perform Check-Error
  433.            move tp-id-ral to tp-id
  434.            move conv-id-ral to conv-id
  435.            move lu-alias-ral to lu-alias
  436.            move plu-alias-ral to plu-alias
  437.            move mode-name-ral to mode-name.
  438.  
  439.       *-----------------------------------------------------------------
  440.        MC-Receive-and-Wait.
  441.       *    wait for data or signal to be sent.  The 'what-received'
  442.       *    field is returned by this call and indicates the type of
  443.       *    information sent eg. data buffer or a signal to start
  444.       *    sending data.
  445.       *
  446.       *    The buffer that the data is sent to MUST be a shared,
  447.       *    unnamed segment of memory.  This is allocated using the
  448.       *    DosAllocSeg function call (with flags=1).
  449.       *
  450.       *-----------------------------------------------------------------
  451.            set Receiving-State to True
  452.            move all x"00" to VCB
  453.            move ap-m-receive-and-wait to opcode-mrw
  454.            move ap-mapped-conversation to opext-mrw
  455.            move tp-id to tp-id-mrw
  456.            move conv-id to conv-id-mrw
  457.            set dptr-mrw to Data-Buffer-Ptr
  458.            move Data-Buffer-Length to max-len-mrw
  459.            perform Execute-Appc-Verb
  460.            If prim-rc-mda not = h"0009"
  461.       *            if primary return code = h"0009"
  462.       *              don't treat as error - returned when receiving
  463.       *              deallocation signal from MC-DEALLOCATE verb
  464.                perform check-error
  465.            End-If
  466.            move what-rcvd-mrw to what-received
  467.            move rts-rcvd-mrw to request-to-send-received.
  468.  
  469.  
  470.       *-----------------------------------------------------------------
  471.        MC-Allocate.
  472.       *    send an allocaton request to a remote machine to start a
  473.       *    conversation.  This verbs requires certain names defined in
  474.       *    the configuration profile.
  475.       *
  476.       *-----------------------------------------------------------------
  477.            move all x"00" to VCB
  478.            move ap-m-allocate to opcode-mal
  479.            move ap-mapped-conversation to opext-mal
  480.            move 1 to opext-mal
  481.            move tp-id to tp-id-mal
  482.            move ap-confirm-sync-level to sync-lvl-mal
  483.            move ap-when-session-allocated to rtn-ctl-mal
  484.            move plu-alias to plu-alias-mal
  485.            move mode-name to mode-name-mal
  486.            move tp-name to tp-name-mal
  487.            move ap-none to security-mal
  488.            set Sending-State to True
  489.            perform Execute-Appc-Verb
  490.            perform Check-Error
  491.            move conv-id-mal to conv-id.
  492.  
  493.       *-----------------------------------------------------------------
  494.        MC-Send-Data.
  495.       *    send a buffer to the remote machine.  The buffer MUST be
  496.       *    a shared unnamed segment of memory.  This is allocated using
  497.       *    the DosAllocSeg function call (with flags=1).
  498.       *
  499.       *-----------------------------------------------------------------
  500.            set Sending-State to True
  501.            move all x"00" to VCB
  502.            move ap-m-send-data to opcode-msd
  503.            move ap-mapped-conversation to opext-msd
  504.            move tp-id to tp-id-msd
  505.            move conv-id to conv-id-msd
  506.            move data-buffer-length to dlen-msd
  507.            set dptr-msd to data-buffer-ptr
  508.            perform Execute-Appc-Verb
  509.            perform Check-Error
  510.            move rts-rcvd-msd to request-to-send-received.
  511.  
  512.       *-----------------------------------------------------------------
  513.        MC-Deallocate.
  514.       *    close a conversation
  515.       *
  516.       *-----------------------------------------------------------------
  517.            set Sending-State to True
  518.            move all x"00" to VCB
  519.            move ap-m-deallocate to opcode-mda
  520.            move ap-mapped-conversation to opext-mda
  521.            move tp-id to tp-id-mda
  522.            move conv-id to conv-id-mda
  523.            move ap-flush to dealloc-type-mda
  524.            perform Execute-Appc-Verb
  525.            perform Check-Error.
  526.  
  527.       *-----------------------------------------------------------------
  528.        MC-Flush.
  529.       *    cause any unsent data to be transmitted immediately
  530.       *
  531.       *-----------------------------------------------------------------
  532.            move all x"00" to VCB
  533.            move ap-m-flush to opcode-fls
  534.            move ap-mapped-conversation to opext-fls
  535.            move tp-id to tp-id-fls
  536.            move conv-id to conv-id-fls
  537.            perform Execute-Appc-Verb
  538.            perform Check-Error.
  539.  
  540.       *-----------------------------------------------------------------
  541.        MC-Prepare-To-Receive.
  542.       *    cause a change of conversation state from send to receive -
  543.       *    this must be done before a MC-SEND-DATA verb can be issued
  544.       *    by the remote end - when it is in receive state.  This verb
  545.       *    causes the local end to go into receive state.
  546.       *
  547.       *-----------------------------------------------------------------
  548.            set Receiving-State to True
  549.            move all x"00" to VCB
  550.            move ap-m-prepare-to-receive to opcode-ptr
  551.            move ap-mapped-conversation to opext-ptr
  552.            move tp-id to tp-id-ptr
  553.            move conv-id to conv-id-ptr
  554.            move ap-flush to ptr-type-ptr
  555.            perform Execute-Appc-Verb
  556.            perform Check-Error.
  557.  
  558.       *-----------------------------------------------------------------
  559.        TP-Started.
  560.       *    allocate resources for conversation
  561.       *
  562.       *-----------------------------------------------------------------
  563.            move all x"00" to VCB
  564.            move ap-tp-started to opcode-tps
  565.            move lu-alias to lu-alias-tps
  566.            move tp-name to tp-name-tps
  567.            perform Execute-Appc-Verb
  568.            perform Check-Error
  569.            move tp-id-tps to tp-id.
  570.  
  571.       *-----------------------------------------------------------------
  572.        TP-Ended.
  573.       *    release resources used by earlier conversation
  574.       *
  575.       *-----------------------------------------------------------------
  576.            move all x"00" to VCB
  577.            move ap-tp-ended to opcode-tpe
  578.            move tp-id to tp-id-tpe
  579.            perform Execute-Appc-Verb.
  580.  
  581.       *-----------------------------------------------------------------
  582.        Execute-Appc-Verb.
  583.       *    interface to appc/acssvc uses load-time dynamic linking
  584.       *    two methods may be employed:
  585.       *        - to specify IMPORTS statements in .DEF file
  586.       *        - to use ACS.LIB link library
  587.       *
  588.       *    (both methods are used in BATTLE.CMD)
  589.       *
  590.       *-----------------------------------------------------------------
  591.            call "__APPC" using by reference vcb.
  592.  
  593.       *-----------------------------------------------------------------
  594.        Execute-Acssvc-Verb.
  595.       *
  596.       *-----------------------------------------------------------------
  597.            call "__ACSSVC" using by reference vcb.
  598.  
  599.       *-----------------------------------------------------------------
  600.        Check-Error.
  601.       *    if any error on the primary return code - convert error
  602.       *    to hex display, display error, wait for key and exit program
  603.       *
  604.       *-----------------------------------------------------------------
  605.            if prim-rc-vcb not = 0
  606.                move opcode-vcb to bin-val
  607.                perform bin-to-hexdisp
  608.                move hex-disp to error-1
  609.                move prim-rc-vcb to bin-val
  610.                perform bin-to-hexdisp
  611.                move hex-disp to error-2
  612.                move sec-rc-vcb to bin-dword
  613.                move bin-dword-msw to bin-val
  614.                perform bin-to-hexdisp
  615.                move hex-disp to error-3
  616.                move bin-dword-lsw to bin-val
  617.                perform bin-to-hexdisp
  618.                move hex-disp to error-4
  619.                call "cbl_clear_scr"
  620.                    using clear-char
  621.                          clear-attr
  622.                call "cbl_set_csr_pos" using screen-pos
  623.                display error-msg
  624.                display "press any key to continue"
  625.                call "cbl_read_kbd_char"
  626.                    using key-char
  627.                go to Error-Exit
  628.            end-if.
  629.  
  630.       *-----------------------------------------------------------------
  631.        Bin-to-Hexdisp.
  632.       *    converts bin-val - a binary word value into a displayable
  633.       *    hex value that can be inserted into the error message string
  634.       *
  635.       *-----------------------------------------------------------------
  636.            divide bin-val-1 by 16
  637.                giving hex-idx-1 remainder hex-idx-2
  638.            add 1 to hex-idx-1 hex-idx-2
  639.            move hex-string(hex-idx-1:1) to hex-disp(1:1)
  640.            move hex-string(hex-idx-2:1) to hex-disp(2:1)
  641.            divide bin-val-2 by 16
  642.                giving hex-idx-1 remainder hex-idx-2
  643.            add 1 to hex-idx-1 hex-idx-2
  644.            move hex-string(hex-idx-1:1) to hex-disp(3:1)
  645.            move hex-string(hex-idx-2:1) to hex-disp(4:1).
  646.  
  647.