home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / OL.LZH / PROCS.LZH / ISPF.ICN < prev    next >
Text File  |  1991-07-13  |  3KB  |  90 lines

  1. ############################################################################
  2. #
  3. #    Name:    ispf.icn
  4. #
  5. #    Title:    Permit communication between Icon and ISPF (MVS and CMS only)
  6. #
  7. #    Author: Alan Beale
  8. #
  9. #    Date:    April 8, 1990
  10. #
  11. ############################################################################
  12.  
  13. #  The functions ispqry, ispexec, ispcopy and isprepl must be installed
  14. #  in the extcall module of iconx for these procedures to do anything useful.
  15. #
  16. #     These procedures provide an interface between Icon and ISPF:
  17. #
  18. #     ISPQry()        returns &null if ISPF services are available, or
  19. #                     fails if not
  20. #
  21. #     ISPExec(cmd)    Sends an ISPEXEC command to ISPF.  Returns the
  22. #                     ISPF return code if less than 12.  Otherwise,
  23. #                     causes run-time error 500, and prints an error
  24. #                     message if errors are not trapped.  If errors
  25. #                     are trapped, the message is in &errorvalue.
  26. #
  27. #     ISPVcopy(var)   Returns the value of a variable in the ISPF
  28. #                     "function pool", or fails if the named variable
  29. #                     is not defined.  ISPF errors are handled as by
  30. #                     ISPExec.
  31. #
  32. #     ISPVrepl(var,val) Stores a new value in an ISPF variable (or
  33. #                     creates the variable if it does not exist).
  34. #                     Returns 0 if successful.  ISPF errors are handled
  35. #                     as by ISPExec.
  36. #
  37. # The first time ISPF is called, CONTROL ERRORS RETURN is established.
  38. # This can be overridden if desired by a call to ISPExec for that
  39. # purpose.
  40. #
  41. ############################################################################
  42. #
  43. #  Requires:  CMS of MVS
  44. #
  45. ############################################################################
  46.  
  47. procedure ISPQry()     # detect presence or absence of ISPF
  48.    return callout("ispqry")
  49. end
  50.  
  51. procedure ISPExec(cmd)    # transmit an ISPEXEC request to ISPF
  52.    local result 
  53.  
  54.    result := callout("ispexec", cmd)
  55.    if type(result) == "string" then {
  56.       if result[1+:4] ~== "ISPF" then result := "ISPF error: "||result
  57.       if &error = 0 then write(&errout, result)
  58.       runerr(500, result)
  59.    }
  60.    else return result
  61. end
  62.  
  63. procedure ISPVcopy(var)     # get value of an ISPF "function" variable
  64.    local result
  65.  
  66.    if not (result := callout("ispcopy", var||" ")) then fail
  67. #
  68. #   Note: ispcopy returns either "=value", if the variable was found,
  69. #         or "!msg" if an ISPF error occurred other than "variable not
  70. #         defined" (which is a failure condition).
  71. #
  72.    if result[1] == "=" then return result[2:0]
  73.    result = result[2:0]
  74.    if result[1+:4] ~== "ISPF" then result := "ISPF error: "||result
  75.    if &error = 0 then write(&errout, result)
  76.    runerr(500, result)
  77. end
  78.  
  79. procedure ISPVrepl(var,value)   # assign to an ISPF variable
  80.    local result
  81.  
  82.    result := callout("isprepl", var||" ", value)
  83.    if type(result) == "string" then {
  84.       if result[1+:4] ~== "ISPF" then result := "ISPF error: "||result
  85.       if &error = 0 then write(&errout, result)
  86.       runerr(500, result)
  87.    }
  88.    else return result
  89. end
  90.