home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 30 fixes_v / 30-fixes_v.zip / vxrx20a.zip / VREDISP.VRM < prev    next >
Text File  |  1994-02-17  |  5KB  |  162 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.00 )then do
  8.         call VRMessage "", "This program requires VX-REXX version 2.00 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, "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. /*  General case 
  69. */
  70.     if object = "" then do
  71.         ret = VREDispG( parent, VRXEdit, VRXPath )
  72.         parse VAR ret type ';' value
  73.         if type = "" then signal quit
  74.         if type = "OBJECT" then do
  75.             object = value
  76.         end
  77.         objName = ""
  78.     end
  79.  
  80. /*  Object specific case
  81. */
  82.     if object \= "" then do
  83.         ret = VREDispO( parent, VRXEdit, VRXPath, object )
  84.         parse VAR ret type ';' value 
  85.         if ret = "" then signal quit
  86.         objName = ""
  87.         if VRXEdit = 1 then do
  88.            objName = VRGet( object, "Name" )
  89.         end
  90.     end
  91.  
  92. /*  Call the string generating macro
  93. */
  94.     if type \= "MACRO" then signal quit
  95.  
  96.     parse VAR value macroname ";" parms
  97.     fname = VRXPath || "SYSTEM\" || macroname || ".VRM"
  98.     interpret 'codeString = "' || fname || '"( parent, objName, parms )'
  99.     if codeString = "" then signal quit
  100.  
  101.     if translate(destination) = "CLIPBOARD" then do
  102.     call VRMethod "Application", "PutClipboard", codeString || "0d0a"x
  103.     end
  104.     else if destination \= "" then do
  105.     call VRSEInsertBlock destination, codeString
  106.     call VRSEActivate destination
  107.     end
  108.  
  109. quit:
  110.  
  111. return codeString
  112.  
  113. /*  VREDispG    Call the external VREDispG
  114. */
  115. VREDispG: procedure
  116.     parse arg parent, edit, path
  117.     interpret 'string = "' || path || 'VREDISPG.VRM"( parent, edit, path )'
  118. return string
  119.  
  120. /*  VREDispO    Call the external VREDispO
  121. */
  122. VREDispO: procedure
  123.     parse arg parent, edit, path, object
  124.     interpret 'string = "' || path || 'VREDISPO.VRM"( parent, edit, path, object )'
  125. return string
  126. /*:VRX         GetEnvironment
  127. */
  128. GetEnvironment: procedure expose VRXEdit VRXPath
  129.  
  130.     parse arg parent
  131.  
  132.     ok = 0
  133.  
  134. /*  Assume if we have a parent that we are executing
  135.     within VRXEdit.  Otherwise assume we are not 
  136.     (e.g. we are executing from an external editor).
  137. */
  138.     VRXEdit = (parent \= "")
  139.  
  140. /*  Set the path to the VXREXX home directory.  
  141.     This is VREPath() within VRXEdit, and the environment
  142.     variable VXREXX otherwise.
  143. */
  144.     if VRXEdit = 1 then do
  145.         VRXPath = VREPath()
  146.         ok = 1
  147.     end
  148.     else do
  149.         VRXPath = value( "VXREXX",,"OS2ENVIRONMENT" ) || '\'
  150.         file = VRXPath || "VRXEDIT.EXE" 
  151.         file = stream( file, 'c', 'query exists' )
  152.         if file \= "" then do
  153.             ok = 1
  154.         end
  155.         else do            
  156.             call VRMessage parent, "The OS/2 environment variable VXREXX is not set to the VX-REXX directory.", "Error"
  157.         end
  158.     end
  159.  
  160. return ok
  161.  
  162.