home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / vxdemo.zip / SYSTEM.$$$ / VRFILEDI.VRM < prev    next >
Text File  |  1993-09-01  |  7KB  |  267 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 < 1.01 )then do
  8.         call VRMessage "", "This program requires VX-REXX version 1.01 to run", "Error!"
  9.         _VREReturnValue = 32000
  10.         signal _VRELeaveMain
  11.     end
  12.  
  13.     signal on SYNTAX name _VRESyntax
  14.     signal _VREMain
  15.  
  16. _VRESyntax:
  17.     parse source . . _VRESourceSpec
  18.     call VRMessage "", "Syntax error in" _VRESourceSpec "line" SIGL, "Error!"
  19.     _VREReturnValue = 32000
  20.     signal _VRELeaveMain
  21.  
  22. _VREMain:
  23. /*:VRX         Main
  24. */
  25. /*  Main
  26. */
  27. Main:
  28. /*  Process the arguments.
  29.     Get the parent window.
  30. */
  31.     parse source . calledAs .
  32.     parent = ""
  33.     argCount = arg()
  34.     argOff = 0
  35.     if( calledAs \= "COMMAND" )then do
  36.         if argCount >= 1 then do
  37.             parent = arg(1)
  38.             argCount = argCount - 1
  39.             argOff = 1
  40.         end
  41.     end
  42.     InitArgs.0 = argCount
  43.     if( argCount > 0 )then do i = 1 to argCount
  44.         InitArgs.i = arg( i + argOff )
  45.     end
  46.     drop calledAs argCount argOff
  47.  
  48. /*  Load the windows
  49. */
  50.     call VRInit
  51.     parse source . . spec
  52.     _VREPrimaryWindowPath = ,
  53.         VRParseFileName( spec, "dpn" ) || ".VRW"
  54.     _VREPrimaryWindow = ,
  55.         VRLoad( parent, _VREPrimaryWindowPath )
  56.     drop parent spec
  57.     if( _VREPrimaryWindow == "" )then do
  58.         call VRMessage "", "Cannot load window:" VRError(), ,
  59.             "Error!"
  60.         _VREReturnValue = 32000
  61.         signal _VRELeaveMain
  62.     end
  63.  
  64. /*  Process events
  65. */
  66.     call Init
  67.     signal on halt
  68.     do while( \ VRGet( _VREPrimaryWindow, "Shutdown" ) )
  69.         _VREEvent = VREvent()
  70.         interpret _VREEvent
  71.     end
  72. _VREHalt:
  73.     _VREReturnValue = Fini()
  74.     call VRDestroy _VREPrimaryWindow
  75. _VRELeaveMain:
  76.     call VRFini
  77. exit _VREReturnValue
  78.  
  79. VRLoadSecondary: procedure
  80.     name = arg( 1 )
  81.  
  82.     window = VRLoad( VRWindow(), VRWindowPath(), name )
  83.     call VRMethod window, "CenterWindow"
  84.     call VRSet window, "Visible", 1
  85.     call VRMethod window, "Activate"
  86. return window
  87.  
  88. /*:VRX         Comments
  89. */
  90. Comments:
  91. /*  
  92.     VRFileDi: Generate a prototype for the VRFileDialog function
  93.  
  94.     Usage:  call VRFileDi <Parent>
  95.  
  96.     Where:  Parent is the parent window for the dialog
  97.         
  98. */
  99. return
  100.  
  101. /*:VRX         Error
  102. */
  103. Error: procedure
  104.     field = arg( 1 )
  105.     error = arg( 2 )
  106.     call VRMessage VRWindow(), error, "Error"
  107.     call VRMethod field, "SetFocus"
  108. return
  109.  
  110. /*:VRX         Fini
  111. */
  112. Fini:
  113.     window = VRWindow()
  114.     call VRSet window, "Visible", 0
  115.     drop window
  116. return Prototype
  117.  
  118. /*:VRX         Halt
  119. */
  120. Halt:
  121.     signal _VREHalt
  122. return
  123.  
  124. /*:VRX         Init
  125. */
  126. Init:
  127.  
  128.     Prototype = ""
  129.     call VRSet "DType", "Value", "Open"
  130.  
  131.     window = VRWindow()
  132.     call VRMethod window, "CenterWindow"
  133.     call VRSet window, "Visible", 1
  134.     call VRMethod window, "Activate"
  135.     drop window
  136. return
  137.  
  138. /*:VRX         PB_1_Click
  139. */
  140. PB_1_Click:
  141.  
  142.     parent = 'VRWindow()'
  143.  
  144.     title = VRGet( "Title", "Value" )
  145.     if VRGet( "Quotes1", "Set" ) then do
  146.         title = '"' || title || '"'
  147.     end
  148.  
  149.     dtype = '"' || VRGet( "DType", "Value" ) || '"'
  150.  
  151.     ipath = VRGet( "IPath", "Value" )
  152.     if VRGet( "Quotes2", "Set" ) & ipath \= "" then do
  153.         ipath = '"' || ipath || '"'
  154.     end
  155.  
  156.     itype = VRGet( "IType", "Value" )
  157.     if VRGet( "Quotes3", "Set" ) & itype \= "" then do
  158.         itype = '"' || itype || '"'
  159.     end
  160.  
  161.     drives = ""
  162.     gdrivelist = VRGet( "Quotes4", "Set" )
  163.     if gdrivelist then do
  164.         drivelist = VRGet( "Drivelist", "Value" )
  165.         sepchar = Left( drivelist, 1 )
  166.         i = 0
  167.         interpret "parse var drivelist '" || sepchar || "' drivelist"
  168.         do while drivelist \= ""
  169.             interpret "parse var drivelist item '" || sepchar || "' drivelist"
  170.             if item \= "" then do
  171.                 if length( item ) \= 2 | lastpos( ":", item ) \= 2 then do
  172.                     call Error "Drive list", "Each item in the Drive list must be a drive letter followed by a colon."
  173.                     Prototype = ""
  174.                     return
  175.                 end
  176.                 i = i + 1
  177.                 Prototype = Prototype || 'Drives.' || i ||,
  178.                             ' = "' || item || '"' || "0d0a"x
  179.             end
  180.         end
  181.         if i > 0 then do
  182.             Prototype = Prototype || "Drives.0 = " ||,
  183.                         i || '0d0a'x || '0d0a'x
  184.             drives = '"Drives."'
  185.         end
  186.     end
  187.     else do
  188.         drivelist = VRGet( "Drivelist", "Value" )
  189.         if drivelist \= "" then do
  190.             if Lastpos( ".", drivelist ) \= length( drivelist ) then do
  191.                 call Error "Drive list", "The drive list must be a stem variable, followed by a period."
  192.                 return
  193.             end
  194.         end
  195.         drives = '"' || drivelist || '"'
  196.     end
  197.  
  198.     types = ""
  199.     gtypelist = VRGet( "Quotes5", "Set" )
  200.     if gtypelist then do
  201.         typelist = VRGet( "Typelist", "Value" )
  202.         sepchar = Left( typelist, 1 )
  203.         i = 0
  204.         interpret "parse var typelist '" || sepchar || "' typelist"
  205.         do while typelist \= ""
  206.             interpret "parse var typelist item '" || sepchar || "' typelist"
  207.             if item \= "" then do
  208.                 i = i + 1
  209.                 Prototype = Prototype || 'Types.' || i ||,
  210.                             ' = "' || item || '"' || "0d0a"x
  211.             end
  212.         end
  213.         if i > 0 then do
  214.             Prototype = Prototype || "Types.0 = " ||,
  215.                         i || '0d0a'x || '0d0a'x
  216.             types = '"Types."'
  217.         end
  218.     end
  219.     else do
  220.         typelist = VRGet( "Typelist", "Value" )
  221.         if typelist \= "" then do
  222.             if Lastpos( ".", typelist ) \= length( typelist ) then do
  223.                 call Error "Type list", "The type list must be a stem variable, followed by a period."
  224.                 return
  225.             end
  226.         end
  227.         types = '"' || typelist || '"'
  228.     end
  229.  
  230.     Prototype = Prototype || 'FileName = VRFileDialog( ' || parent ||,
  231.                 ', ' || title || ', ' || dtype ||,
  232.                 ', ' || ipath || ', ' || itype ||,
  233.                 ', ' || drives || ', ' || types || ' )'
  234.  
  235.     call Quit
  236.  
  237. return
  238.  
  239. /*:VRX         PB_2_Click
  240. */
  241. PB_2_Click:
  242.     rc = ""
  243.     call Quit
  244. return
  245.  
  246. /*:VRX         PB_3_Click
  247. */
  248. PB_3_Click:
  249.     "view a2z.inf VRFileDialog function"
  250. return
  251.  
  252. /*:VRX         Quit
  253. */
  254. Quit:
  255.     window = VRWindow()
  256.     call VRSet window, "Shutdown", 1
  257.     drop window
  258. return
  259.  
  260. /*:VRX         Window1_Close
  261. */
  262. Window1_Close:
  263.     rc = ""
  264.     call Quit
  265. return
  266.  
  267.