home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / vxcliser.zip / VXREXX.2 / VREDISP.VRM < prev    next >
Text File  |  1994-12-23  |  5KB  |  175 lines

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