home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / vxdemo.zip / SYSTEM.$$$ / VRCOPYF.VRM < prev    next >
Text File  |  1993-09-01  |  5KB  |  215 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.     VRCopyF: Generate a prototype for VRCopyFile function
  93.  
  94.     Usage:  call VRCopyF <Parent>
  95.  
  96.     Where:  Parent is the parent window for the dialog
  97. */
  98. return
  99.  
  100. /*:VRX         Error
  101. */
  102. Error: procedure
  103.     field = arg( 1 )
  104.     error = arg( 2 )
  105.     call VRMessage VRWindow(), error, "Error"
  106.     call VRMethod field, "SetFocus"
  107. return
  108.  
  109. /*:VRX         Fini
  110. */
  111. Fini:
  112.     window = VRWindow()
  113.     call VRSet window, "Visible", 0
  114.     drop window
  115. return Prototype
  116.  
  117. /*:VRX         Halt
  118. */
  119. Halt:
  120.     signal _VREHalt
  121. return
  122.  
  123. /*:VRX         Init
  124. */
  125. Init:
  126.  
  127.     Prototype = ""
  128.  
  129.     window = VRWindow()
  130.     call VRMethod window, "CenterWindow"
  131.     call VRSet window, "Visible", 1
  132.     call VRMethod window, "Activate"
  133.     drop window
  134.  
  135. return
  136.  
  137. /*:VRX         PB_1_Click
  138. */
  139. PB_1_Click:
  140.  
  141.     value = VRGet( "File", "Value" )
  142.     if value = "" then do
  143.         call Error "From", "You must specify a file to copy from."
  144.         return
  145.     end
  146.     quotes = VRGet( "Quotes", "Set" )
  147.     if quotes = 1 then do
  148.         value = '"' || value || '"'
  149.     end
  150.  
  151.     value1 = VRGet( "File1", "Value" )
  152.     if value1 = "" then do
  153.         call Error "To", "You must specify a file to copy to."
  154.         return
  155.     end
  156.     quotes1 = VRGet( "Quotes1", "Set" )
  157.     if quotes1 = 1 then do
  158.         value1 = '"' || value1 || '"'
  159.     end
  160.  
  161.     Prototype = 'ok = VRCopyFile( ' ||,
  162.                               value || ', ' ||,
  163.                               value1 || ' )'
  164.  
  165.     call Quit
  166.  
  167. return
  168.  
  169. /*:VRX         PB_2_Click
  170. */
  171. PB_2_Click:
  172.     rc = ""
  173.     call Quit
  174. return
  175.  
  176. /*:VRX         PB_3_Click
  177. */
  178. PB_3_Click:
  179.     "view a2z.inf VRCopyFile function"
  180. return
  181.  
  182. /*:VRX         PB_4_Click
  183. */
  184. PB_4_Click:
  185.  
  186.     filename = VRFileDialog( VRWindow(), "File name", "Open" )
  187.     if filename \= "" then call VRSet "File", "Value", filename
  188.  
  189. return
  190.  
  191. /*:VRX         PB_5_Click
  192. */
  193. PB_5_Click:
  194.  
  195.     filename = VRFileDialog( VRWindow(), "File name", "Open" )
  196.     if filename \= "" then call VRSet "File1", "Value", filename
  197.  
  198. return
  199.  
  200. /*:VRX         Quit
  201. */
  202. Quit:
  203.     window = VRWindow()
  204.     call VRSet window, "Shutdown", 1
  205.     drop window
  206. return
  207.  
  208. /*:VRX         Window1_Close
  209. */
  210. Window1_Close:
  211.     rc = ""
  212.     call Quit
  213. return
  214.  
  215.