home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / vxdemo.zip / SYSTEM.$$$ / VRCREATE.VRM < prev    next >
Text File  |  1993-09-01  |  6KB  |  285 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         Add_PB_Click
  89. */
  90. Add_PB_Click:
  91.  
  92. info = VRGet( "Info", "Value" )
  93. value = VRGet( "Value", "Value" )
  94. if value \= "" & info \= "" then do
  95.     call VRSet "Add_PB", "Enabled", 0
  96.     call VRSet "Info", "Value", ""
  97.     call VRSet "Value", "Value", ""
  98.     iquoted = VRGet( "Quotes1", "Set" )
  99.     vquoted = VRGet( "Quotes2", "Set" )
  100.     if iquoted then info = '"' || info || '"'
  101.     if vquoted then value = '"' || value || '"'
  102.     string = info || ', ' || value
  103.     call VRMethod "LB_1", "AddString", string
  104. end
  105. else do
  106.     call VRSet "Add_PB", "Enabled", 0
  107. end
  108.  
  109. return
  110.  
  111. /*:VRX         Comments
  112. */
  113. Comments:
  114. /*  
  115.     VRCreate: Generate a prototype for the VRCreate function
  116.  
  117.     Usage:  call VRCreate <Parent>
  118.  
  119.     Where:  Parent is the parent window for the dialog
  120. */
  121. return
  122.  
  123. /*:VRX         Error
  124. */
  125. Error: procedure
  126.     field = arg( 1 )
  127.     error = arg( 2 )
  128.     call VRMessage VRWindow(), error, "Error"
  129.     call VRMethod field, "SetFocus"
  130. return
  131.  
  132. /*:VRX         Fini
  133. */
  134. Fini:
  135.     window = VRWindow()
  136.     call VRSet window, "Visible", 0
  137.     drop window
  138. return Prototype
  139.  
  140. /*:VRX         Halt
  141. */
  142. Halt:
  143.     signal _VREHalt
  144. return
  145.  
  146. /*:VRX         Info_Change
  147. */
  148. Info_Change:
  149.  
  150. info = VRGet( "Info", "Value" )
  151. value = VRGet( "Value", "Value" )
  152. if value \= "" & info \= "" then do
  153.     call VRSet "Add_PB", "Enabled", 1
  154. end
  155. else do
  156.     call VRSet "Add_PB", "Enabled", 0
  157. end
  158.  
  159. return
  160.  
  161. /*:VRX         Init
  162. */
  163. Init:
  164.  
  165.     Prototype = ""
  166.  
  167.     window = VRWindow()
  168.     call VRMethod window, "CenterWindow"
  169.     call VRSet window, "Visible", 1
  170.     call VRMethod window, "Activate"
  171.     drop window
  172. return
  173.  
  174. /*:VRX         LB_1_Click
  175. */
  176. LB_1_Click:
  177.  
  178. selected = VRGet( "LB_1", "SelectedString" )
  179. if selected \= "" then do
  180.     call VRSet "Remove_PB", "Enabled", 1
  181. end
  182. else do
  183.     call VRSet "Remove_PB", "Enabled", 0
  184. end
  185.  
  186. return
  187.  
  188. /*:VRX         PB_1_Click
  189. */
  190. PB_1_Click:
  191.     parent = VRGet( 'Object', 'Value' )
  192.     if parent = '' then do
  193.         call Error 'Parent', 'You must specify a parent object.'
  194.         return
  195.     end
  196.     if VRGet( "Quotes3", "Set" ) then do
  197.         parent = '"' || parent || '"'
  198.     end
  199.  
  200.     object = VRGet( 'ObjType', 'Value' )
  201.     if object = '' then do
  202.         call Error 'Object', 'You must specify an object type.'
  203.         return
  204.     end
  205.     if VRGet( "Quotes", "Set" ) then do
  206.         object = '"' || object || '"'
  207.     end
  208.  
  209.     pairs = ""
  210.     numpairs = VRGet( "LB_1", "Count" )
  211.     if numpairs > 0 then do
  212.         do i = 1 to numpairs
  213.             selected = VRMethod( "LB_1", "GetString", i )
  214.             pairs = pairs || ', ' || selected
  215.         end
  216.     end
  217.  
  218.     Prototype = 'object = VRCreate( ' || parent ||,
  219.                               ', ' || object ||,
  220.                               pairs ||,
  221.                               ' )'
  222.  
  223.     call Quit
  224.  
  225. return
  226.  
  227. /*:VRX         PB_2_Click
  228. */
  229. PB_2_Click:
  230.     rc = ""
  231.     call Quit
  232. return
  233.  
  234. /*:VRX         PB_3_Click
  235. */
  236. PB_3_Click:
  237.     "view a2z.inf VRCreate function"
  238. return
  239.  
  240. /*:VRX         Quit
  241. */
  242. Quit:
  243.     window = VRWindow()
  244.     call VRSet window, "Shutdown", 1
  245.     drop window
  246. return
  247.  
  248. /*:VRX         Remove_PB_Click
  249. */
  250. Remove_PB_Click:
  251.  
  252. selected = VRGet( "LB_1", "Selected" )
  253. call VRMethod "LB_1", "Delete", selected
  254. selected = VRGet( "LB_1", "SelectedString" )
  255. if selected \= "" then do
  256.     call VRSet "Remove_PB", "Enabled", 1
  257. end
  258. else do
  259.     call VRSet "Remove_PB", "Enabled", 0
  260. end
  261. return
  262.  
  263. /*:VRX         Value_Change
  264. */
  265. Value_Change:
  266.  
  267. info = VRGet( "Info", "Value" )
  268. value = VRGet( "Value", "Value" )
  269. if value \= "" & info \= "" then do
  270.     call VRSet "Add_PB", "Enabled", 1
  271. end
  272. else do
  273.     call VRSet "Add_PB", "Enabled", 0
  274. end
  275.  
  276. return
  277.  
  278. /*:VRX         Window1_Close
  279. */
  280. Window1_Close:
  281.     rc = ""
  282.     call Quit
  283. return
  284.  
  285.