home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / vxdemo.zip / DISPATCH.$$$ / VREDISP.VRM next >
Text File  |  1993-09-15  |  4KB  |  153 lines

  1. /* Custom mainline for macro */
  2.  
  3.     signal on SYNTAX name _VRESyntax
  4.     signal _VREMain
  5.  
  6. _VRESyntax:
  7.     parse source . . _VRESourceSpec
  8.     call VRMessage "", "Syntax error in" _VRESourceSpec "line" SIGL, "Error!"
  9.     exit 32000
  10.  
  11. _VREMain:
  12. /*:VRX         Main
  13. */
  14. /*
  15.     codeString = VREDisp( <parent>, <object>, <dest> )
  16.  
  17.     Generate a VX-REXX code string.
  18.  
  19.     <parent>    The parent window for any dialogs.  
  20.                 If the parent is non-empty the operating    
  21.                 environment is assumed to be VRXEdit.
  22.                 Otherwise the environment variable
  23.                 VXREXX is expected to point at the 
  24.                 VX-REXX directory.
  25.     
  26.     <object>    The object to use in VRGet, VRSet, and
  27.                 VRMethod.  If the empty string is passed
  28.                 the general code dialog is used rather 
  29.                 than the object specific dialog.
  30.  
  31.     <dest>      The destination for the code string.
  32.                 If empty, the code string is simply
  33.                 returned.  If "CLIPBOARD", the code
  34.                 string is inserted into the OS/2 
  35.                 clipboard.  Otherwise it is assumed to
  36.                 be the handle of a VX-REXX section
  37.                 editor and the code is inserted into
  38.                 the editor.
  39.  
  40.     Returns the code string or the empty string.
  41. */
  42. Main:
  43.  
  44. /*  Uncomment to debug
  45.     call VRRedirectSTDIO "on"
  46.     trace ?r
  47. */
  48.     signal on novalue
  49.  
  50.     parse arg parent, object, destination
  51.  
  52.     codeString = ""
  53.  
  54. /*  Set VRXEdit and VRXPath
  55. */    
  56.     ok = GetEnvironment( parent )
  57.     if ok = 0 then signal quit
  58.  
  59. /*  General case 
  60. */
  61.     if object = "" then do
  62.         ret = VREDispG( parent, VRXEdit, VRXPath )
  63.         parse VAR ret type ';' value
  64.         if type = "" then signal quit
  65.         if type = "OBJECT" then do
  66.             object = value
  67.         end
  68.         objName = ""
  69.     end
  70.  
  71. /*  Object specific case
  72. */
  73.     if object \= "" then do
  74.         ret = VREDispO( parent, VRXEdit, VRXPath, object )
  75.         parse VAR ret type ';' value 
  76.         if ret = "" then signal quit
  77.         objName = ""
  78.         if VRXEdit = 1 then do
  79.            objName = VRGet( object, "Name" )
  80.         end
  81.     end
  82.  
  83. /*  Call the string generating macro
  84. */
  85.     if type \= "MACRO" then signal quit
  86.  
  87.     parse VAR value macroname ";" parms
  88.     fname = VRXPath || "SYSTEM\" || macroname || ".VRM"
  89.     interpret 'codeString = "' || fname || '"( parent, objName, parms )'
  90.     if codeString = "" then signal quit
  91.  
  92.     if translate(destination) = "CLIPBOARD" then do
  93.     call VRMethod "Application", "PutClipboard", codeString || "0d0a"x
  94.     end
  95.     else if destination \= "" then do
  96.     call VRSEInsertBlock destination, codeString
  97.     call VRSEActivate destination
  98.     end
  99.  
  100. quit:
  101.  
  102. return codeString
  103.  
  104. /*  VREDispG    Call the external VREDispG
  105. */
  106. VREDispG: procedure
  107.     parse arg parent, edit, path
  108.     interpret 'string = "' || path || 'VREDISPG.VRM"( parent, edit, path )'
  109. return string
  110.  
  111. /*  VREDispO    Call the external VREDispO
  112. */
  113. VREDispO: procedure
  114.     parse arg parent, edit, path, object
  115.     interpret 'string = "' || path || 'VREDISPO.VRM"( parent, edit, path, object )'
  116. return string
  117. /*:VRX         GetEnvironment
  118. */
  119. GetEnvironment: procedure expose VRXEdit VRXPath
  120.  
  121.     parse arg parent
  122.  
  123.     ok = 0
  124.  
  125. /*  Assume if we have a parent that we are executing
  126.     within VRXEdit.  Otherwise assume we are not 
  127.     (e.g. we are executing from an external editor).
  128. */
  129.     VRXEdit = (parent \= "")
  130.  
  131. /*  Set the path to the VXREXX home directory.  
  132.     This is VREPath() within VRXEdit, and the environment
  133.     variable VXREXX otherwise.
  134. */
  135.     if VRXEdit = 1 then do
  136.         VRXPath = VREPath()
  137.         ok = 1
  138.     end
  139.     else do
  140.         VRXPath = value( "VXREXX",,"OS2ENVIRONMENT" ) || '\'
  141.         file = VRXPath || "VRXEDIT.EXE" 
  142.         file = stream( file, 'c', 'query exists' )
  143.         if file \= "" then do
  144.             ok = 1
  145.         end
  146.         else do            
  147.             call VRMessage parent, "The OS/2 environment variable VXREXX is not set to the VX-REXX directory.", "Error"
  148.         end
  149.     end
  150.  
  151. return ok
  152.  
  153.