home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / rxhll.zip / HOST.REX < prev    next >
OS/2 REXX Batch file  |  1993-10-28  |  6KB  |  230 lines

  1. /* #include Host.rex */
  2.  
  3. /**
  4. *** ┌──────────────────────────────────────────────────────────────────────┐
  5. *** │                            Host Routines                             │
  6. *** └──────────────────────────────────────────────────────────────────────┘
  7. **/
  8.  
  9.  
  10. HostLogon: procedure
  11.    /**
  12.    ***  This will logon to IBMLink.  This call should be replaced with
  13.    ***  'HostIBMLinkLogon' but was kept here to support the older code.
  14.    **/
  15.  
  16.    parse arg arguments
  17.  
  18.    say '"HostLogon" calls should be replaced with "HostIBMLinkLogon" calls.'
  19.    call HostIBMLinkLogon arguments
  20.    return
  21.  
  22.  
  23. HostLogoff: procedure
  24.    /**
  25.    ***  This will logon to IBMLink.  This call should be replaced with
  26.    ***  'HostIBMLinkLogoff' but was kept here to support the older code.
  27.    **/
  28.  
  29.    parse arg arguments
  30.  
  31.    say '"HostLogoff" calls should be replaced with "HostIBMLinkLogoff" calls.'
  32.    call HostIBMLinkLogoff arguments
  33.    return
  34.  
  35.  
  36. HostEnterXY: procedure expose Host.
  37.    /**
  38.    ***  This will position the cursor at a row and column and press the
  39.    ***  Enter key.
  40.    **/
  41.  
  42.    parse arg x, y .
  43.    rcode = HostCursorXY(x,y)
  44.    code = hllapi('Sendkey', '@E')
  45.    rcode = hllapi('Wait')
  46.    return code
  47.  
  48.  
  49. HostCursorXY: procedure expose Host.
  50.    /**
  51.    ***  This will position the cursor at the proper row and column
  52.    **/
  53.    parse arg x, y .
  54.  
  55.    Position = hllapi('Convert_pos', Host.Session, x, y)
  56.    code = hllapi('Set_cursor_pos', Position)
  57.    return code
  58.  
  59.  
  60. HostGetCursorPos: procedure expose x y Host.
  61.    /**
  62.    ***  This will return the current cursor position in the global variables
  63.    ***  x & y
  64.    **/
  65.  
  66.    Position = hllapi( 'Query_cursor_pos' )
  67.    xy = hllapi( 'Convert_pos', Host.Session, Position )
  68.    parse var xy x y
  69.    return
  70.  
  71.  
  72. HostPageDown: procedure expose Screen. Host.
  73.    /**
  74.    ***  This will page down to the next screen and refresh the Screen.
  75.    ***  stem variable with the new screen.
  76.    **/
  77.  
  78.    code = hllapi('Sendkey', '@8')
  79.    rc = hllapi('Wait')
  80.    call HostScreenToStem
  81.    return
  82.  
  83. HostPageUp: procedure expose Screen. Host.
  84.    /**
  85.    ***  This will page up to the previous screen and refresh the Screen.
  86.    ***  stem variable with the new screen.
  87.    **/
  88.  
  89.    code = hllapi('Sendkey', '@7')
  90.    rc = hllapi('Wait')
  91.    call HostScreenToStem
  92.    return
  93.  
  94.  
  95. HostScreenToStem: procedure expose Host. Screen.
  96.    /**
  97.    ***  This will get the current screen and break it into the stem
  98.    ***  variable called Screen.
  99.    **/
  100.  
  101.    call HostGetScreenSize
  102.    PresSpace = hllapi('Copy_PS_to_str', 1, (Screen.Rows * Screen.Cols))
  103.  
  104.    do i = 1 to Screen.Rows
  105.       Screen.i = left(PresSpace, Screen.Cols)
  106.       PresSpace = substr(PresSpace, Screen.Cols+1)
  107.    end
  108.    return
  109.  
  110.  
  111. HostGetScreenSize: procedure expose Host. Screen.
  112.    /**
  113.    ***  This will fill the stem variable with the number of rows and
  114.    ***  columns in the current screen.
  115.    **/
  116.  
  117.    SessionStatus = hllapi('Query_session_status', Host.Session)
  118.    Screen.Rows = c2d(reverse(substr(SessionStatus, 12, 2)))
  119.    Screen.Cols = c2d(reverse(substr(SessionStatus, 14, 2)))
  120.    return
  121.  
  122.  
  123. HostError: procedure expose Host.
  124.    /**
  125.    ***  This will handle unexpected response errors from the host session
  126.    **/
  127.  
  128.    arg code .
  129.  
  130.    select
  131.       when code = 1001 then say 'Host could not process QUERY TIME command.'
  132.       when code = 1002 then say 'Can''t synch time on this host operating system.'
  133.       when code = 1003 then say 'Don''t know how to logon to this host operating system.'
  134.       when code = 1004 then say 'Invalid security type.'
  135.       otherwise             say 'Unexpected response from host.'
  136.    end /* select */
  137.    call HapiDisconnect
  138.    exit
  139.  
  140.  
  141. HostWaitFor: procedure expose Host.
  142.    /**
  143.    ***  This will wait for a certain string to appear on the screen.  Some
  144.    ***  applications will unlock the keyboard while processing (e.g. most
  145.    ***  VM applictions), so the HLLAPI code can't just wait for keyboard
  146.    ***  unlock.  This will check for a particular character string before
  147.    ***  returning.  If the string doesn't appear within the number of
  148.    ***  seconds passed, it will return a '-1' return code.
  149.    **/
  150.  
  151.    parse arg MaxSeconds, SearchString
  152.  
  153.    sleeps = 0
  154.    do until pos <> 0
  155.       pos=hllapi('Search_ps', SearchString, 1)
  156.       call SysSleep 1
  157.       sleeps = sleeps + 1
  158.  
  159.       if sleeps >= MaxSeconds then
  160.          return -1
  161.    end /* until */
  162.    return 0
  163.  
  164.  
  165. HostLoadUploadFile: procedure expose Upload.
  166.    /**
  167.    ***  This will read an entire file into storage by placing each line
  168.    ***  into a stem variable called Upload.  It will also translate the
  169.    ***  "@" symbols to "@@" to keep the HLLAPI code from interpreting
  170.    ***  the "@" as a command.
  171.    **/
  172.  
  173.    parse arg File
  174.  
  175.    i = 1
  176.    UploadFile = open(File, 'READ')
  177.    do while(lines(UploadFile) > 0)
  178.       Upload.i = MapSymbol(linein(UploadFile), "@", "@@")
  179.       i = i + 1
  180.    end /* while */
  181.    code = Close(UploadFile)
  182.    Upload.0 = i - 1
  183.    return
  184.  
  185.  
  186. HostPA2: procedure expose Screen. Host.
  187.    /**
  188.    ***  This will press PA2 and refresh the Screen. stem variable with the
  189.    ***  new screen.
  190.    **/
  191.  
  192.    code = hllapi('Sendkey', '@y')
  193.    rc = hllapi('Wait')
  194.    call HostScreenToStem
  195.    return
  196.  
  197.  
  198. HostLogonClMenu: procedure expose Host.
  199.    /**
  200.    ***  This will check to see if the session is at the Quality logo
  201.    ***  or the CLMenu screen or the "Press Enter..." one-liner screen.
  202.    ***  Upon exit, you will be placed at the CL/Menu screen.
  203.    **/
  204.  
  205.    pos = hllapi('Search_ps','CLM095I - PRESS ENTER OR PF KEY TO GET CL/MENU DISPLAY',1)
  206.    if pos <> 0 then
  207.       do
  208.       rc=hllapi('Sendkey', '@E')
  209.       rc=hllapi('Wait')
  210.       end
  211.  
  212.    pos = hllapi('Search_ps','To start, enter MENU ====>',1)
  213.    if pos <> 0 then
  214.       do
  215.  
  216.       /* Enter the menu command */
  217.  
  218.       call HapiClear
  219.       rc=hllapi('Sendkey', 'MENU@E')
  220.       rc=hllapi('Wait')
  221.       end
  222.  
  223.    /* Wait for the CL/Menu main screen to appear.  If it doesn't after */
  224.    /* a few retries, bomb out.                                         */
  225.  
  226.    code = HostWaitFor(10, '/L - LOGON TO VTAM APPLICATION')
  227.    if code = -1 then
  228.       call HostError
  229.    return
  230.