home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / vxdemo.zip / SYSTEM.$$$ / VRMESSST.VRM < prev    next >
Text File  |  1993-09-01  |  6KB  |  258 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.     VRMessSt: Generate a prototype for the VRMessageStem function
  93.  
  94.     Usage:  call VRMessSt <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 "IType", "Value", "None"
  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.     lines = ""
  145.     glinelist = VRGet( "Quotes4", "Set" )
  146.     if glinelist then do
  147.         linelist = VRGet( "Linelist", "Value" )
  148.         if linelist = "" then do
  149.             call Error "Lines", "You must specify text to be displayed."
  150.             return
  151.         end
  152.         sepchar = Left( linelist, 1 )
  153.         i = 0
  154.         interpret "parse var linelist '" || sepchar || "' linelist"
  155.         do while linelist \= ""
  156.             interpret "parse var linelist item '" || sepchar || "' linelist"
  157.             i = i + 1
  158.             Prototype = Prototype || 'Lines.' || i ||,
  159.                         ' = "' || item || '"' || "0d0a"x
  160.         end
  161.         if i > 0 then do
  162.             Prototype = Prototype || "Lines.0 = " ||,
  163.                         i || '0d0a'x || '0d0a'x
  164.             lines = '"Lines."'
  165.         end
  166.     end
  167.     else do
  168.         linelist = VRGet( "Linelist", "Value" )
  169.         if linelist \= "" then do
  170.             if Lastpos( ".", linelist ) \= length( linelist ) then do
  171.                 call Error "Lines", "The line list must be a stem variable, followed by a period."
  172.                 return
  173.             end
  174.         end
  175.         lines = '"' || linelist || '"'
  176.     end
  177.  
  178.     title = VRGet( "Title", "Value" )
  179.     if VRGet( "Quotes1", "Set" ) then do
  180.         title = '"' || title || '"'
  181.     end
  182.  
  183.     itype = VRGet( "IType", "Value" )
  184.     itype = '"' || itype || '"'
  185.  
  186.     buttons = ""
  187.     gbuttonlist = VRGet( "Quotes5", "Set" )
  188.     if gbuttonlist then do
  189.         buttonlist = VRGet( "Buttonlist", "Value" )
  190.         sepchar = Left( buttonlist, 1 )
  191.         i = 0
  192.         interpret "parse var buttonlist '" || sepchar || "' buttonlist"
  193.         do while buttonlist \= ""
  194.             interpret "parse var buttonlist item '" || sepchar || "' buttonlist"
  195.             if item \= "" then do
  196.                 i = i + 1
  197.                 Prototype = Prototype || 'Buttons.' || i ||,
  198.                             ' = "' || item || '"' || "0d0a"x
  199.             end
  200.         end
  201.         if i > 0 then do
  202.             Prototype = Prototype || "Buttons.0 = " ||,
  203.                         i || '0d0a'x || '0d0a'x
  204.             buttons = '"Buttons."'
  205.         end
  206.     end
  207.     else do
  208.         buttonlist = VRGet( "Buttonlist", "Value" )
  209.         if buttonlist \= "" then do
  210.             if Lastpos( ".", buttonlist ) \= length( buttonlist ) then do
  211.                 call Error "Button list", "The button list must be a stem variable, followed by a period."
  212.                 return
  213.             end
  214.         end
  215.         buttons = '"' || buttonlist || '"'
  216.     end
  217.  
  218.     default = VRGet( "Default", "Value" )
  219.     escape = VRGet( "Escape", "Value" )
  220.  
  221.     Prototype = Prototype || 'id = VRMessageStem( ' || parent ||,
  222.                 ', ' || lines || ', ' || title ||,
  223.                 ', ' || itype || ', ' || buttons ||,
  224.                 ', ' || default || ', ' || escape || ' )'
  225.  
  226.     call Quit
  227.  
  228. return
  229.  
  230. /*:VRX         PB_2_Click
  231. */
  232. PB_2_Click:
  233.     rc = ""
  234.     call Quit
  235. return
  236.  
  237. /*:VRX         PB_3_Click
  238. */
  239. PB_3_Click:
  240.     "view a2z.inf VRMessageStem function"
  241. return
  242.  
  243. /*:VRX         Quit
  244. */
  245. Quit:
  246.     window = VRWindow()
  247.     call VRSet window, "Shutdown", 1
  248.     drop window
  249. return
  250.  
  251. /*:VRX         Window1_Close
  252. */
  253. Window1_Close:
  254.     rc = ""
  255.     call Quit
  256. return
  257.  
  258.