home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / VREXX2.ZIP / vrexx.inf (.txt) < prev    next >
OS/2 Help File  |  1992-09-10  |  42KB  |  1,882 lines

  1.  
  2. ΓòÉΓòÉΓòÉ 1. VREXX ΓòÉΓòÉΓòÉ
  3.  
  4.      VREXX - Version 1.0
  5. (C) Copyright IBM Corp.  1992
  6.  
  7.           Written by:
  8.  
  9. Richard B. Lam
  10. IBM T.J. Watson Research Center
  11. Route 134  POB 218
  12. Yorktown Heights, NY  10598
  13.  
  14. VREXX is Visual REXX - a new way for OS/2 users to create their own 
  15. Presentation Manager (PM) programs using REXX!  VREXX provides users with a set 
  16. of functions that can be called from REXX procedures.  These functions open and 
  17. close standard PM windows, providing programmable control over the appearance 
  18. and positioning of the windows.  Dialog box functions allow file selection, 
  19. display of messages, entering numbers or text strings, and making single or 
  20. multiple selections through radiobutton, checkbox or listbox controls.  Table, 
  21. Color and font selection dialogs are also available.  And, graphics functions 
  22. for setting pixels, drawing markers, lines, polygons, splines, arcs, circles 
  23. and text (in multiple fonts) are included. 
  24.  
  25. With VREXX, OS/2 REXX procedures can use all of the standard features of REXX 
  26. under OS/2, except that the old text window input and output procedures are 
  27. replaced with PM windows and dialogs.  No prior experience with PM programming 
  28. is necessary.  The OS/2 Programming toolkit is NOT required.  All you need to 
  29. do is write a REXX program that makes function calls to the VREXX functions. 
  30.  
  31. VREXX features: 
  32.  
  33. o Creation and manipulation of standard PM windows 
  34.  
  35. o Powerful dialog functions, including: 
  36.  
  37.    - Positioning control over the dialogs 
  38.  
  39.    - Dialog button selections 
  40.  
  41.    - Standard filename selection dialog 
  42.  
  43.    - Data Table, Color selection and Font selection dialogs 
  44.  
  45.    - 10 line message box 
  46.  
  47.    - Input boxes for entering text or numbers 
  48.  
  49.    - Radiobutton, checkbox and listbox controls for selecting item(s) from a 
  50.      list 
  51.  
  52. o Graphics support, with functions for: 
  53.  
  54.    - Setting window foreground and background colors 
  55.  
  56.    - Setting individual pixels 
  57.  
  58.    - Drawing markers, with 10 different marker types 
  59.  
  60.    - Polylines, with 7 different line types 
  61.  
  62.    - Filled polygons, with 6 different fill types 
  63.  
  64.    - Splines 
  65.  
  66.    - Arcs and circles 
  67.  
  68. o On-line help facility 
  69.  
  70.  
  71. ΓòÉΓòÉΓòÉ 2. SYSTEM REQUIREMENTS ΓòÉΓòÉΓòÉ
  72.  
  73. VREXX runs under OS/2 PM version 2.0 on IBM PS/2 or PC-compatible systems. 
  74.  
  75. Copy VREXX.INF to a BOOKSHELF help file directory specified in your CONFIG.SYS 
  76. file.  Copy VREXX.EXE and the sample command files to a utility directory 
  77. included in your PATH statement.  Copy VREXX.DLL and DEVBASE.DLL to a directory 
  78. specified in your LIBPATH in CONFIG.SYS. 
  79.  
  80.  
  81. ΓòÉΓòÉΓòÉ 3. USING VREXX ΓòÉΓòÉΓòÉ
  82.  
  83. REXX procedures that call VREXX functions are started normally, by either 
  84. typing the CMD filename on an OS/2 command line, or by using the OS/2 START 
  85. command. 
  86.  
  87. To run a REXX procedure named EXAMPLE.CMD which calls VREXX functions, simply 
  88. type: 
  89.  
  90. example
  91. or 
  92.  
  93. start example.cmd
  94. from an OS/2 command line prompt.  The EXAMPLE.CMD procedure will then execute 
  95. normally, in addition to providing access to the VREXX functions. To access 
  96. on-line help for VREXX, use the OS/2 VIEW command by typing: 
  97.  
  98. view vrexx.inf
  99. or 
  100.  
  101. vrexx
  102. from an OS/2 command line prompt. 
  103.  
  104. Before calling VREXX functions in your REXX procedures, you must load and 
  105. initialize the external functions by calling VInit.  Also, the VExit function 
  106. must be called at the end of your REXX procedure to clean up the system 
  107. resources allocated in the initialization.  The recommended approach for this 
  108. is to structure your REXX procedure as follows: 
  109.  
  110. /* EXAMPLE.CMD - structure for initializing and */
  111. /*               terminating VREXX procedures   */
  112.  
  113. /* initialize VREXX */
  114.  
  115. '@echo off'
  116. call RxFuncAdd 'VInit', 'VREXX', 'VINIT'
  117. initcode = VInit()
  118. if initcode = 'ERROR' then signal CLEANUP
  119.  
  120. signal on failure name CLEANUP
  121. signal on halt name CLEANUP
  122. signal on syntax name CLEANUP
  123.  
  124. /* REXX statements and VREXX function calls go here */
  125. /* ...                                              */
  126. /* end of REXX statements                           */
  127.  
  128. /* terminate VREXX - add any other clean-up */
  129. /* for your REXX procedure here also        */
  130.  
  131. CLEANUP:
  132.    call VExit
  133.  
  134. exit
  135.  
  136. The SIGNAL statements ensure that VExit is called if your REXX procedure 
  137. contains an error.  You may optionally add a SIGNAL ON ERROR NAME CLEANUP 
  138. statement also, depending on whether you provide another error handler for 
  139. non-fatal ERROR return codes. 
  140.  
  141. After initialization, VREXX lets you create multiple windows, with each window 
  142. returning a specific id that you use to refer to the window for later 
  143. operations.  Note for PM programmers:  the REXX command files are procedural, 
  144. not event-driven.  Therefore, your REXX procedure executes from top to bottom 
  145. as a normal REXX program.  But, at any time, especially when dialogs are 
  146. displayed, the windows created with VREXX calls can be manipulated just like 
  147. other PM windows - they may be iconized, resized, moved, etc.  Also, the 
  148. contents of the window are maintained internally - you don't need to redraw the 
  149. window every time it is moved or sized.  The windows are destroyed by calling a 
  150. window close function, passing it the id of the window to close. 
  151.  
  152. Although multiple windows may be created, only 1 dialog box at a time may be 
  153. processed by the running REXX procedure. 
  154.  
  155. Graphics coordinates for the windows are always set from 0 to 1000 in both the 
  156. x and y directions, with the origin at the lower left corner of the window. The 
  157. current color and line type apply to all graphics operations. 
  158.  
  159. The window and dialog positioning functions always operate with numbers 
  160. representing a percentage of the screen.  Thus, to center a window on the 
  161. screen with the window filling half of the screen area, the left and bottom 
  162. corners of the window are set to 25, while the right and top corners of the 
  163. window are set to 75.  See the COMMAND REFERENCE section for more examples on 
  164. graphics and window positioning. 
  165.  
  166. There are three sample REXX programs that come with the package, called 
  167. TESTWIN.CMD, TESTDLGS.CMD, and TESTDRAW.CMD, which demonstrate the syntax of 
  168. the VREXX functions.  See the EXAMPLES section for more details. 
  169.  
  170.  
  171. ΓòÉΓòÉΓòÉ 4. COMMAND REFERENCE ΓòÉΓòÉΓòÉ
  172.  
  173. This section provides a summary of the functions which can be called from a 
  174. REXX procedure running under VREXX.  See the EXAMPLES section for some REXX 
  175. procedures which implement the VREXX commands. 
  176.  
  177. The following functions are provided: 
  178.  
  179. o Startup, Termination and Version Functions 
  180.  
  181.    VExit               Cleans up the current VREXX system resources 
  182.  
  183.    VGetVersion         Returns the current VREXX program version number 
  184.  
  185.    VInit               Initializes the VREXX functions and system resources 
  186.  
  187. o Window Functions 
  188.  
  189.    VBackColor          Sets the background color of a window 
  190.  
  191.    VClearWindow        Clears the contents of a window 
  192.  
  193.    VCloseWindow        Closes a window 
  194.  
  195.    VForeColor          Sets the foreground color of a window 
  196.  
  197.    VOpenWindow         Opens a new window 
  198.  
  199.    VResize             Resizes and repositions a window on the screen 
  200.  
  201.    VSetTitle           Sets the titlebar of a window to a specified string 
  202.  
  203. o Dialog Functions 
  204.  
  205.    VCheckBox           Creates a checkbox dialog for selecting multiple items 
  206.                        from a list 
  207.  
  208.    VColorBox           Allows selection of foreground and background colors 
  209.                        from a dialog 
  210.  
  211.    VDialogPos          Controls the positioning of dialog windows on the screen 
  212.  
  213.    VFileBox            Allows selection of a full pathname of a file from a 
  214.                        dialog 
  215.  
  216.    VFontBox            Allows selection of the typeface and point size to use 
  217.                        for text output 
  218.  
  219.    VInputBox           Creates an entryfield dialog with prompt strings for 
  220.                        entering numbers or strings 
  221.  
  222.    VListBox            Creates a listbox dialog for selecting 1 item from a 
  223.                        large list 
  224.  
  225.    VMsgBox             Creates a message box for displaying from 1 to 10 
  226.                        message strings 
  227.  
  228.    VMultBox            Creates a multiple entryfield dialog, with 1 to 10 
  229.                        entryfields and a prompt string for each field, with 
  230.                        optional echoing of input characters (e.g. for entering 
  231.                        passwords). 
  232.  
  233.    VRadioBox           Creates a radiobox dialog for selecting 1 item from a 
  234.                        list 
  235.  
  236.    VTableBox           Constructs a table dialog as a listbox, with 
  237.                        programmable column widths 
  238.  
  239. o Graphics Functions 
  240.  
  241.    VArc                Draws an arc or complete circle, optionally filled with 
  242.                        the current fill style 
  243.  
  244.    VDraw               Draws pixels, markers, lines, polygons or splines using 
  245.                        the current marker type, line attribute and fill style 
  246.  
  247.    VDrawParms          Sets the current marker type, line attribute and fill 
  248.                        style to use for subsequent graphics operations 
  249.  
  250.    VSay                Draws a text string in the current font on a window 
  251.  
  252.    VSetFont            Sets the current font to use for drawing text 
  253.  
  254. For the dialog functions, several of them take a [stem] variable name as an 
  255. argument.  For example, the VMsgBox function is called as follows: 
  256.  
  257. msg.0 = 2
  258. msg.1 = 'This is the first line'
  259. msg.2 = 'This is the second line'
  260.  
  261. buttons = 1
  262.  
  263. call VMsgBox 'Dialog title', msg, buttons
  264. where msg is the variable name of a stem variable.  This variable uses the same 
  265. format for all dialog functions, where the stem.0 variable holds the number of 
  266. items, and stem.1 through stem.n hold the actual items.  In the example above, 
  267. there are 2 message lines to be displayed, so msg.0 is set to 2, and msg.1 and 
  268. msg.2 hold the actual lines that will be displayed by the function. 
  269.  
  270. The dialogs also take a standard [buttons] argument, which is defined as a 
  271. number between 1 and 6, denoting that the following buttons be created on the 
  272. dialog: 
  273.  
  274.  [buttons] value     Buttons created     Return value
  275.  _______________     _______________     ____________
  276.  
  277.         1            OK                  'OK'
  278.         2            Cancel              'CANCEL'
  279.         3            OK and Cancel       'OK' or 'CANCEL'
  280.         4            Yes                 'YES'
  281.         5            No                  'NO'
  282.         6            Yes and No          'YES' or 'NO'
  283.  
  284. In the example above, the [buttons] argument to the VMsgBox function was 1, so 
  285. the message box dialog would be created with a single pushbutton labelled "OK". 
  286. The VMsgBox function could also be called with the syntax: 
  287.  
  288. return_button = VMsgBox('Dialog title', msg, buttons)
  289. where the return_button variable would be set to the return value corresponding 
  290. to the pushbutton selected by the user (return_value = 'OK' in this example). 
  291.  
  292. Those dialogs which need to return a selected string will place the selected 
  293. string in a [stem].vstring variable.  For example, to access the string typed 
  294. into an entryfield with the VInputBox function, use the following code: 
  295.  
  296. str.0 = 1
  297. str.1 = 'Type a string'
  298. call VInputBox 'Example', str, 1
  299.  
  300. answer = str.vstring
  301.  
  302. /* answer now contains the user input */
  303.  
  304.  
  305. ΓòÉΓòÉΓòÉ 4.1. VArc ΓòÉΓòÉΓòÉ
  306.  
  307. Purpose             Draws an arc or complete circle, optionally filled with the 
  308.                     current fill style 
  309.  
  310. Definition 
  311.  
  312.                                         VArc [id] [x] [y] [radius] [angle1] [angle2]
  313.  
  314. Parameters          [id] is the window id.  [x] and [y] are the center point of 
  315.                     the arc, and [radius] is the radius of the arc, in units of 
  316.                     0 to 1000.  [angle1] and [angle2] are the angles to draw 
  317.                     the arc between, starting with angle 0 at 3 o'clock, 
  318.                     increasing in a counter-clockwise direction. 
  319.  
  320. Comments            [angle1] should be less than [angle2] and both angles 
  321.                     should be between 0 and 360 degrees.  The angles may be 
  322.                     specified in floating point format. 
  323.  
  324. Function Result     none 
  325.  
  326. Example: 
  327.  
  328. /* draw an arc in the center of a window, going
  329.    from 12 o'clock to 6 o'clock, with a radius of
  330.    100 */
  331.  
  332. a1 = 90
  333. a1 = 270.0
  334. call VArc id, 500, 500, 100, a1, a2
  335.  
  336.  
  337. ΓòÉΓòÉΓòÉ 4.2. VBackColor ΓòÉΓòÉΓòÉ
  338.  
  339. Purpose             Sets the background color of a window 
  340.  
  341. Definition 
  342.  
  343.                                         VBackColor [id] [color]
  344.  
  345. Parameters          [id] is the window id and [color] is the new background 
  346.                     color to use for the window. 
  347.  
  348. Comments            [color] must be specified as a string, in either upper, 
  349.                     lower or mixed case, and must equal one of 'BLACK', 
  350.                     'WHITE', 'RED', 'GREEN', 'BLUE', 'CYAN', 'YELLOW' or 
  351.                     'PINK'. 
  352.  
  353. Function Result     none 
  354.  
  355. Example: 
  356.  
  357. /* change a window background color to 'RED' */
  358.  
  359. call VBackColor id, 'RED'
  360.  
  361.  
  362. ΓòÉΓòÉΓòÉ 4.3. VCheckBox ΓòÉΓòÉΓòÉ
  363.  
  364. Purpose             Creates a checkbox dialog for selecting multiple items from 
  365.                     a list 
  366.  
  367. Definition 
  368.  
  369.                                         VCheckBox [title] [stem] [output] [buttons]
  370.  
  371. Parameters          [title] is the string to use for the dialog titlebar, and 
  372.                     [stem] is the variable name of the stem variable containing 
  373.                     the items that will be used in constructing the dialog. 
  374.                     [output] is the variable name of the stem variable where 
  375.                     the selected items will be placed, and [buttons] denotes 
  376.                     the desired button types to be placed on the dialog. 
  377.  
  378. Comments            A maximum of 10 items may be passed to this function. The 
  379.                     [output] stem variable need not exist when this function is 
  380.                     called. The number of items selected is given by the 
  381.                     [output].0 variable name (e.g. if [output] = 
  382.                     user_selection, then the REXX variable user_selection.0 
  383.                     holds the number of items checked in the dialog, and 
  384.                     user_selection.1 through user_selection.n hold the actual 
  385.                     selections).  The [output] variable can be initialized 
  386.                     before calling this function with the default strings to be 
  387.                     checked when the dialog is created. 
  388.  
  389. Function Result     'OK', 'CANCEL', 'YES' or 'NO', depending on the [buttons] 
  390.                     argument 
  391.  
  392. Example: 
  393.  
  394. /* let user select movies */
  395.  
  396. movie.0 = 5
  397. movie.1 = 'Silence of the Lambs'
  398. movie.2 = 'Dr. Strangelove'
  399. movie.3 = 'Terminator 2'
  400. movie.4 = 'Goldfinger'
  401. movie.5 = 'Basic Instinct'
  402.  
  403. button = VCheckBox('Select movies', movie, selection, 3)
  404. if button = 'OK' then do
  405.    call VMsgBox('Your selections', selection, 1)
  406. end
  407.  
  408.  
  409. ΓòÉΓòÉΓòÉ 4.4. VClearWindow ΓòÉΓòÉΓòÉ
  410.  
  411. Purpose             Clears the contents of a window 
  412.  
  413. Definition 
  414.  
  415.                                         VClearWindow [id]
  416.  
  417. Parameters          [id] is the id of the window to clear. 
  418.  
  419. Comments            This function erases all graphics from a window, enabling 
  420.                     you to start over with a new set of graphics commands. 
  421.  
  422. Function Result     none 
  423.  
  424. Example: 
  425.  
  426. /* clear a window of all graphics */
  427.  
  428. call VClearWindow id
  429.  
  430.  
  431. ΓòÉΓòÉΓòÉ 4.5. VCloseWindow ΓòÉΓòÉΓòÉ
  432.  
  433. Purpose             Closes a window 
  434.  
  435. Definition 
  436.  
  437.                                         VCloseWindow [id]
  438.  
  439. Parameters          [id] is the id of the window you wish to close. 
  440.  
  441. Comments            The window must have been opened with a call to 
  442.                     VOpenWindow. 
  443.  
  444. Function Result     none 
  445.  
  446. Example: 
  447.  
  448. /* close a window */
  449.  
  450. call VCloseWindow id
  451.  
  452.  
  453. ΓòÉΓòÉΓòÉ 4.6. VColorBox ΓòÉΓòÉΓòÉ
  454.  
  455. Purpose             Allows selection of foreground and background colors from a 
  456.                     dialog 
  457.  
  458. Definition 
  459.  
  460.                                         VColorBox [stem]
  461.  
  462. Parameters          [stem] is the name of a stem variable which holds the .fore 
  463.                     and .back color values for the foreground and background 
  464.                     colors. 
  465.  
  466. Comments            The colors should be specified as one of 'BLACK', 'WHITE', 
  467.                     'RED', 'GREEN', 'BLUE', 'CYAN', 'YELLOW' or 'PINK'. 
  468.  
  469. Function Result     'OK' or 'CANCEL' 
  470.  
  471. Example: 
  472.  
  473. /* get new foreground and background colors for a
  474.    window and set them */
  475.  
  476. color.fore = 'BLACK'
  477. color.back = 'WHITE'
  478. button = VColorBox color
  479.  
  480. if button = 'OK' then do
  481.    call VForeColor color.fore
  482.    call VBackColor color.back
  483. end
  484.  
  485.  
  486. ΓòÉΓòÉΓòÉ 4.7. VDialogPos ΓòÉΓòÉΓòÉ
  487.  
  488. Purpose             Controls the positioning of dialog windows on the screen 
  489.  
  490. Definition 
  491.  
  492.                                         VDialogPos [x] [y]
  493.  
  494. Parameters          [x] and [y] are the center position to use for positioning 
  495.                     subsequent dialog boxes on the screen. 
  496.  
  497. Comments            [x] and [y] should be integers between 0 and 100, specified 
  498.                     in percentage of the screen. 
  499.  
  500. Function Result     none 
  501.  
  502. Example: 
  503.  
  504. /* position a message box in the center of the screen */
  505.  
  506. call VDialogPos 50, 50
  507.  
  508. msg.0 = 1
  509. msg.1 = 'This box is in the center of the screen'
  510. call VMsgBox 'TEST', msg, 1
  511.  
  512.  
  513. ΓòÉΓòÉΓòÉ 4.8. VDraw ΓòÉΓòÉΓòÉ
  514.  
  515. Purpose             Draws pixels, markers, lines, polygons or splines using the 
  516.                     current marker type, line attribute and fill style 
  517.  
  518. Definition 
  519.  
  520.                                         VDraw [id] [drawtype] [xstem] [ystem] [num]
  521.  
  522. Parameters          [id] is the id of the window to use for drawing the 
  523.                     graphics.  [drawtype] is a string, which must be one of 
  524.                     'PIXEL', 'MARKER', 'LINE', 'POLYGON' or 'SPLINE', depending 
  525.                     on the graphic to be drawn.  [xstem] and [ystem] are 
  526.                     variable names for stem variables, which contain the 
  527.                     coordinates to be used for drawing the graphics (ranging 
  528.                     from .1 to .n).  [num] is the number of data points 
  529.                     specified in the [xstem] and [ystem] variables. 
  530.  
  531. Comments            The coordinates should range between 0 and 1000.  The 
  532.                     drawtypes and their effects are: 
  533.  
  534.    o 'PIXEL' sets a pixel in the foreground color for each point 
  535.  
  536.    o 'MARKER' draws a marker at each point using the current marker type 
  537.  
  538.    o 'LINE' draws a polyline connecting all of the points using the current 
  539.      line attribute 
  540.  
  541.    o 'POLYGON' draws a closed figure using the coordinates as vertices, filling 
  542.      the figure with the current fill type 
  543.  
  544.    o 'SPLINE' requires 4 data points, and draws a B╨Æzier cubic spline that 
  545.      passes through points 1 and 4, using points 2 and 3 as control points. 
  546.  
  547. Function Result     none 
  548.  
  549. Example:  See the TESTDRAW.CMD procedure for some sample function calls using 
  550. the VDraw function. 
  551.  
  552.  
  553. ΓòÉΓòÉΓòÉ 4.9. VDrawParms ΓòÉΓòÉΓòÉ
  554.  
  555. Purpose             Sets the current marker type, line attribute and fill style 
  556.                     to use for subsequent graphics operations 
  557.  
  558. Definition 
  559.  
  560.                                         VDrawParms [id] [markertype] [linetype] [filltype]
  561.  
  562. Parameters          [id] is the window id.  [markertype] is the marker type to 
  563.                     draw, [linetype] is the line attribute to use, and 
  564.                     [filltype] is the fill style to use in subsequent VDraw 
  565.                     operations. 
  566.  
  567. Comments            0 is the default for all 3 attributes, equal to a cross 
  568.                     marker, a solid line, or an empty fill style.  The other 
  569.                     values and their corresponding meanings are shown in the 
  570.                     example. 
  571.  
  572. Function Result     none 
  573.  
  574. Example: 
  575.  
  576. /* VDrawParms marker, line and fill values */
  577.  
  578. default = 0
  579.  
  580. /* marker types */
  581.  
  582. cross        = 1     /* X */
  583. plus         = 2     /* + */
  584. diamond      = 3     /* diamond */
  585. square       = 4     /* box */
  586. star6        = 5     /* 6 point star */
  587. star8        = 6     /* 8 point star */
  588. soliddiamond = 7     /* solid diamond */
  589. solidsquare  = 8     /* Γûá */
  590. soliddot     = 9     /* . */
  591. circle       = 10    /* O */
  592.  
  593. /* line types */
  594.  
  595. solid      = 0       /* ____  */
  596. dot        = 1       /* ....  */
  597. dash       = 2       /* ----  */
  598. dashdot    = 3       /* -.-.  */
  599. dotdot     = 4       /* .. .. */
  600. longdash   = 5       /* __ __ */
  601. dashdotdot = 6       /* -..-  */
  602.  
  603. /* set up fill types */
  604.  
  605. nofill    = 0        /*       */
  606. solidfill = 1        /* Γûê */
  607. horz      = 2        /* ===== */
  608. vert      = 3        /* ||||| */
  609. leftdiag  = 4        /* \\\\\ */
  610. rightdiag = 5        /* ///// */
  611.  
  612. /* sample function call */
  613.  
  614. call VDrawParms diamond, dotdot, leftdiag
  615.  
  616.  
  617. ΓòÉΓòÉΓòÉ 4.10. VExit ΓòÉΓòÉΓòÉ
  618.  
  619. Purpose             Cleans up the current VREXX system resources 
  620.  
  621. Definition 
  622.  
  623.                                         VExit
  624.  
  625. Parameters          none 
  626.  
  627. Comments            This function should be called after all VREXX function 
  628.                     calls in the current REXX procedure are made. 
  629.  
  630. Function Result     none 
  631.  
  632. Example: 
  633.  
  634. /* terminate VREXX */
  635.  
  636. call VExit
  637.  
  638.  
  639. ΓòÉΓòÉΓòÉ 4.11. VFileBox ΓòÉΓòÉΓòÉ
  640.  
  641. Purpose             Allows selection of a full pathname of a file from a dialog 
  642.  
  643. Definition 
  644.  
  645.                                         VFileBox [title] [template] [stem]
  646.  
  647. Parameters          [title] is the string to use for the dialog titlebar. 
  648.                     [template] is the pathname template that specifies the file 
  649.                     types to display.  [stem] is the name of a stem variable 
  650.                     that contains the full pathname of the selected file. 
  651.  
  652. Comments            If the name of the [stem] variable is fname, the full 
  653.                     pathname is returned in the REXX variable fname.vstring. 
  654.  
  655. Function Result     'OK' or 'CANCEL' 
  656.  
  657. Example: 
  658.  
  659. /* get a filename */
  660.  
  661. button = VFileBox('Pick a file', '*.dat', name)
  662. if button = 'OK' then do
  663.    filename = name.vstring
  664.  
  665.    /* get size of file */
  666.  
  667.    bytes = stream(filename, C, 'query size')
  668. end
  669.  
  670.  
  671. ΓòÉΓòÉΓòÉ 4.12. VFontBox ΓòÉΓòÉΓòÉ
  672.  
  673. Purpose             Allows selection of the typeface and point size to use for 
  674.                     text output 
  675.  
  676. Definition 
  677.  
  678.                                         VFontBox [stem]
  679.  
  680. Parameters          [stem] is the name of a stem variable, with [stem].type and 
  681.                     [stem].size containing the selected font type and font 
  682.                     point size returned from the dialog box. 
  683.  
  684. Comments            The point size must be a positive integer greater than 
  685.                     zero.  The font type must be one of the following strings: 
  686.  
  687.    o 'SYSTEM' - standard system font 
  688.  
  689.    o 'SYMBOL' - greek/math symbols 
  690.  
  691.    o 'COUR' - Courier, Courier Bold, Courier Italic, Courier Bold Italic 
  692.  
  693.    o 'COURB' 
  694.  
  695.    o 'COURI' 
  696.  
  697.    o 'COURBI' 
  698.  
  699.    o 'HELV' - Helvetica, Helvetica Bold, Helvetica Italic, Helvetica Bold 
  700.      Italic 
  701.  
  702.    o 'HELVB' 
  703.  
  704.    o 'HELVI' 
  705.  
  706.    o 'HELVBI' 
  707.  
  708.    o 'TIME' - Times Roman, TR Bold, TR Italic, TR Bold Italic 
  709.  
  710.    o 'TIMEB' 
  711.  
  712.    o 'TIMEI' 
  713.  
  714.    o 'TIMEBI' 
  715.  
  716. Function Result     'OK' or 'CANCEL' 
  717.  
  718. Example: 
  719.  
  720. /* let user pick a new font */
  721.  
  722. cur_font.type = 'SYSTEM'
  723. cur_font.size = 10
  724.  
  725. button = VFontBox(cur_font)
  726.  
  727. if button = 'OK' then do
  728.    call VSetFont id, cur_font.type, cur_font.size
  729. end
  730.  
  731.  
  732. ΓòÉΓòÉΓòÉ 4.13. VForeColor ΓòÉΓòÉΓòÉ
  733.  
  734. Purpose 
  735.  
  736. Definition          Sets the foreground color of a window 
  737.  
  738.                                         VForeColor [id] [color]
  739.  
  740. Parameters          [id] is the window id and [color] is the new foreground 
  741.                     color to use for the window. 
  742.  
  743. Comments            [color] must be specified as a string, in either upper, 
  744.                     lower or mixed case, and must equal one of 'BLACK', 
  745.                     'WHITE', 'RED', 'GREEN', 'BLUE', 'CYAN', 'YELLOW' or 
  746.                     'PINK'. 
  747.  
  748. Function Result     none 
  749.  
  750. Example: 
  751.  
  752. /* change a window foreground color to 'PINK' */
  753.  
  754. call VForeColor id, 'PINK'
  755.  
  756.  
  757. ΓòÉΓòÉΓòÉ 4.14. VGetVersion ΓòÉΓòÉΓòÉ
  758.  
  759. Purpose             Returns the current VREXX program version number 
  760.  
  761. Definition 
  762.  
  763.                                         VGetVersion
  764.  
  765. Parameters          none 
  766.  
  767. Comments            none 
  768.  
  769. Function Result     Returns the version number as major.minor 
  770.  
  771. Example: 
  772.  
  773. /* test version of VREXX */
  774.  
  775. ver = VGetVersion()
  776.  
  777. if ver <> '2.1' then do
  778.    msg.0 = 1
  779.    msg.1 = 'Wrong version of VREXX'
  780.  
  781.    call VMsgBox('Initialization Error', msg, 2)
  782.    exit
  783. end
  784.  
  785.  
  786. ΓòÉΓòÉΓòÉ 4.15. VInit ΓòÉΓòÉΓòÉ
  787.  
  788. Purpose             Initializes the VREXX functions and system resources 
  789.  
  790. Definition 
  791.  
  792.                                         VInit
  793.  
  794. Parameters          none 
  795.  
  796. Comments            This function must be called before calling any other VREXX 
  797.                     functions.  The VExit routine should be called at the end 
  798.                     of the REXX procedure if VInit was called. 
  799.  
  800. Function Result     Returns 'ERROR' if initialization was unsuccessful. 
  801.  
  802. Example: 
  803.  
  804. /* load and initialize VREXX (use the */
  805. /* RxUtils function RxFuncAdd)        */
  806.  
  807. call RxFuncAdd 'VInit', 'VREXX', 'VINIT'
  808. call VInit
  809.  
  810. /* or */
  811.  
  812. call RxFuncAdd 'VInit', 'VREXX', 'VINIT'
  813. initcode = VInit()
  814.  
  815.  
  816. ΓòÉΓòÉΓòÉ 4.16. VInputBox ΓòÉΓòÉΓòÉ
  817.  
  818. Purpose             Creates an entryfield dialog with prompt strings for 
  819.                     entering numbers or strings 
  820.  
  821. Definition 
  822.  
  823.                                         VInputBox [title] [stem] [width] [buttons]
  824.  
  825. Parameters          [title] is the string to use for the dialog titlebar. 
  826.                     [stem] is the name of the stem variable containing the 
  827.                     prompt strings to display in the dialog, and [width] if the 
  828.                     width (in character units) of the entryfield. [buttons] is 
  829.                     a number between 1 and 6 denoting the pushbuttons to 
  830.                     display on the dialog. 
  831.  
  832. Comments            Up to 10 strings can be specified for a prompt, and all 
  833.                     strings should be 80 characters or less in length.  The 
  834.                     [stem].vstring field may contain a default value for the 
  835.                     entryfield on input, and holds the contents of the 
  836.                     entryfield when the dialog is finished. 
  837.  
  838. Function Result     'OK', 'CANCEL', 'YES' or 'NO', depending on the value of 
  839.                     [buttons] 
  840.  
  841. Example: 
  842.  
  843. /* get the user's name */
  844.  
  845. prompt.0 = 4
  846. prompt.1 = 'Please enter your name'
  847. prompt.2 = 'Enter it first name last, last name first'
  848. prompt.3 = ''
  849. prompt.4 = 'Leave out your middle initial'
  850.  
  851. prompt.vstring = 'Doe John'
  852.  
  853. button = VInputBox('Verify info', prompt, 25, 2)
  854.  
  855. if button = 'OK' then do
  856.    name = prompt.vstring
  857. end
  858.  
  859.  
  860. ΓòÉΓòÉΓòÉ 4.17. VListBox ΓòÉΓòÉΓòÉ
  861.  
  862. Purpose             Creates a listbox dialog for selecting 1 item from a large 
  863.                     list 
  864.  
  865. Definition 
  866.  
  867.                                         VListBox [title] [stem] [width] [height] [buttons]
  868.  
  869. Parameters          [title] is the string to use for the dialog titlebar. 
  870.                     [stem] is the name of the stem variable which contains the 
  871.                     number of items and text of each item to be placed in the 
  872.                     listbox.  [width] and [height] are the dimensions of the 
  873.                     listbox in character units, and [buttons] is a number 
  874.                     between 1 and 6 denoting the type of pushbuttons to display 
  875.                     on the dialog. 
  876.  
  877. Comments            Any number of strings may be passed to this function.  On 
  878.                     input, [stem].vstring may contain the default list item to 
  879.                     be selected when the dialog is created.  If a default is 
  880.                     not specified, the first item becomes the default 
  881.                     selection. On output, [stem].vstring contains the listbox 
  882.                     item selected by the user. 
  883.  
  884. Function Result     'OK', 'CANCEL', 'YES' or 'NO', depending on the value of 
  885.                     [buttons] 
  886.  
  887. Example: 
  888.  
  889. /* select 1 item from a listbox */
  890.  
  891. clone.0 = 8
  892. clone.1 = 'Northgate'
  893. clone.2 = 'Everex'
  894. clone.3 = 'Gateway'
  895. clone.4 = 'PC Brand'
  896. clone.5 = 'AST Research'
  897. clone.6 = 'Tandy'
  898. clone.7 = 'Swan'
  899. clone.8 = 'Commodore'
  900.  
  901. call VListBox 'Pick an IBM PC clone', clone, 10, 5, 1
  902. selection = clone.vstring
  903.  
  904.  
  905. ΓòÉΓòÉΓòÉ 4.18. VMsgBox ΓòÉΓòÉΓòÉ
  906.  
  907. Purpose             Creates a message box for displaying from 1 to 10 message 
  908.                     strings 
  909.  
  910. Definition 
  911.  
  912.                                         VMsgBox [title] [stem] [buttons]
  913.  
  914. Parameters          [title] is the string to use for the dialog titlebar. 
  915.                     [stem] is the name of the stem variable which contains the 
  916.                     number of message lines text of each line to be displayed. 
  917.                     [buttons] is a number between 1 and 6 denoting the type of 
  918.                     pushbuttons to display on the dialog. 
  919.  
  920. Comments            Up to 10 lines of 80 characters each may be displayed. 
  921.  
  922. Function Result     'OK', 'CANCEL', 'YES' or 'NO', depending on the value of 
  923.                     [buttons] 
  924.  
  925. Example: 
  926.  
  927. /* display a message box */
  928.  
  929. mbox.0 = 5
  930. mbox.1 = 'VREXX Version 1.0'
  931. mbox.2 = ''
  932. mbox.3 = 'Written by R.B. Lam'
  933. mbox.4 = '(C) Copyright IBM Corp.  1992'
  934.  
  935. call VMsgBox 'VREXX Info', mbox, 1
  936.  
  937.  
  938. ΓòÉΓòÉΓòÉ 4.19. VMultBox ΓòÉΓòÉΓòÉ
  939.  
  940. Purpose             Creates a multiple entryfield dialog, with 1 to 10 
  941.                     entryfields and a prompt string for each field, with 
  942.                     optional echoing of input characters (e.g. for entering 
  943.                     passwords). 
  944.  
  945. Definition 
  946.  
  947.                                         VMultBox [title] [prompt] [width] [hide] [return] [buttons]
  948.  
  949. Parameters          [title] is the string to use for the dialog titlebar. 
  950.                     [prompt] is the name of the stem variable containing the 
  951.                     prompt strings to display (1 for each entryfield) in the 
  952.                     dialog, where [prompt].0 is the number of entryfields. 
  953.                     [width] is an array of widths (in character units) to use, 
  954.                     one for each entryfield.  [hide] is an array where the 
  955.                     elements are 0 or 1, depending on whether or not you wish 
  956.                     to echo (0) or not echo (1) the characters as they are 
  957.                     typed into the entryfield.  This is useful for entering 
  958.                     passwords (see the example below).  [return] is the array 
  959.                     of return strings, which represent what was typed into each 
  960.                     entryfield.  [return] may be initialized with default 
  961.                     strings for each entryfield before this function is called. 
  962.                     [buttons] is a number between 1 and 6 denoting the 
  963.                     pushbuttons to display on the dialog. 
  964.  
  965. Comments            Up to 10 strings can be specified for a prompt, and all 
  966.                     strings should be 80 characters or less in length. 
  967.  
  968. Function Result     'OK', 'CANCEL', 'YES' or 'NO', depending on the value of 
  969.                     [buttons] 
  970.  
  971. Example: 
  972.  
  973. /* get system, userid, and password */
  974.  
  975. /* here are the prompts */
  976.  
  977. p.0 = 3
  978. p.1 = 'System name'
  979. p.2 = 'User ID'
  980. p.3 = 'Password'
  981.  
  982. /* here are the widths for each entryfield */
  983.  
  984. w.0 = p.0
  985. w.1 = 20
  986. w.2 = 10
  987. w.3 = 8
  988.  
  989. /* don't echo the password field */
  990.  
  991. h.0 = p.0
  992. h.1 = 0
  993. h.2 = 0
  994. h.3 = 1
  995.  
  996. /* default strings */
  997.  
  998. r.0 = p.0
  999. r.1 = 'IBMVM'
  1000. r.2 = 'johndoe'
  1001. r.3 = ''
  1002.  
  1003. button = VMultBox('Logon Panel', p, w, h, r, 2)
  1004.  
  1005. if button = 'OK' then do
  1006.    call VMsgBox 'Logon Info', r, 1
  1007. end
  1008.  
  1009.  
  1010. ΓòÉΓòÉΓòÉ 4.20. VOpenWindow ΓòÉΓòÉΓòÉ
  1011.  
  1012. Purpose             Opens a new window 
  1013.  
  1014. Definition 
  1015.  
  1016.                                         VOpenWindow [title] [color] [stem]
  1017.  
  1018. Parameters          [title] is the string to use for the window titlebar. 
  1019.                     [color] is the background color to use for the window. 
  1020.                     [stem] is the name of a stem variable which contains the 
  1021.                     position and size of the window when it it created.  There 
  1022.                     are 4 fields, [stem].left, [stem].right, [stem].bottom and 
  1023.                     [stem].top, which must be specified. 
  1024.  
  1025. Comments            The left, right, top and bottom fields should be integer 
  1026.                     numbers representing a percentage of the screen, ranging 
  1027.                     between 0 and 100. 
  1028.  
  1029. Function Result     Returns an integer id number used to refer to the new 
  1030.                     window in subsequent function calls 
  1031.  
  1032. Example: 
  1033.  
  1034. /* put up a new window in the upper left quadrant of
  1035.    the screen, with a background of white */
  1036.  
  1037. pos.left   = 0
  1038. pos.bottom = 0
  1039. pos.right  = 50
  1040. pos.top    = 100
  1041.  
  1042. color = 'WHITE'
  1043.  
  1044. new_id = VOpenWindow('An example window', color, pos)
  1045.  
  1046.  
  1047. ΓòÉΓòÉΓòÉ 4.21. VRadioBox ΓòÉΓòÉΓòÉ
  1048.  
  1049. Purpose             Creates a radiobox dialog for selecting 1 item from a list 
  1050.  
  1051. Definition 
  1052.  
  1053.                                         VRadioBox [title] [stem] [buttons]
  1054.  
  1055. Parameters          [title] is the string to use for the dialog titlebar. 
  1056.                     [stem] is the name of the stem variable which contains the 
  1057.                     number of items and text of each item to be placed in the 
  1058.                     dialog.  [buttons] is a number between 1 and 6 denoting the 
  1059.                     type of pushbuttons to display on the dialog. 
  1060.  
  1061. Comments            A maximum of 10 items may be passed to this function.  On 
  1062.                     input, [stem].vstring can specify the default radio button 
  1063.                     to be pressed when the dialog is created.  If none is 
  1064.                     specified, the first item becomes the default. On output, 
  1065.                     [stem].vstring contains the item selected by the user. 
  1066.  
  1067. Function Result     'OK', 'CANCEL', 'YES' or 'NO', depending on the value of 
  1068.                     [buttons] 
  1069.  
  1070. Example: 
  1071.  
  1072. /* have user select a font by pushing a radiobutton */
  1073.  
  1074. font.0 = 7
  1075. font.1 = 'Garamond'
  1076. font.2 = 'Helvetica'
  1077. font.3 = 'Times Italic'
  1078. font.4 = 'Weather'
  1079. font.5 = 'Math'
  1080. font.6 = 'Orator'
  1081. font.7 = 'Default'
  1082.  
  1083. call VRadioBox 'Select a font', font, 1
  1084.  
  1085. msg.0 = 1
  1086. msg.1 = 'You selected' font.vstring
  1087.  
  1088. call VMsgBox 'Selection', msg, 1
  1089.  
  1090.  
  1091. ΓòÉΓòÉΓòÉ 4.22. VResize ΓòÉΓòÉΓòÉ
  1092.  
  1093. Purpose             Resizes and repositions a window on the screen 
  1094.  
  1095. Definition 
  1096.  
  1097.                                         VResize [id] [stem]
  1098.  
  1099. Parameters          [id] is the id of the window to move and size.  [stem] is 
  1100.                     the name of a stem variable containing the new coordinates 
  1101.                     of the window in percentage of screen units.  The size and 
  1102.                     position are given in [stem].left, [stem].right, 
  1103.                     [stem].bottom and [stem].top. 
  1104.  
  1105. Comments            The left, bottom, right and top coordinates should be 
  1106.                     integers between 0 and 100. 
  1107.  
  1108. Function Result     none 
  1109.  
  1110. Example: 
  1111.  
  1112. /* create a small window in the center of the screen,
  1113.    then move it to the lower right quadrant and
  1114.    increase its size */
  1115.  
  1116. pos.left   = 40
  1117. pos.bottom = 40
  1118. pos.right  = 60
  1119. pos.top    = 60
  1120. id = VOpenWindow('Small window', 'WHITE', pos)
  1121.  
  1122. pos.left   = 50
  1123. pos.bottom = 0
  1124. pos.right  = 100
  1125. pos.top    = 50
  1126. call VResize id, pos
  1127.  
  1128.  
  1129. ΓòÉΓòÉΓòÉ 4.23. VSay ΓòÉΓòÉΓòÉ
  1130.  
  1131. Purpose             Draws a text string in the current font on a window 
  1132.  
  1133. Definition 
  1134.  
  1135.                                         VSay [id] [x] [y] [text]
  1136.  
  1137. Parameters          [id] is the id of the window where the text will be drawn. 
  1138.                     [x] and [y] are the starting coordinates for the text, 
  1139.                     expressed as integers between 0 and 1000.  [text] is the 
  1140.                     text string to draw. 
  1141.  
  1142. Comments            The text will be drawn in the current font and the current 
  1143.                     color. 
  1144.  
  1145. Function Result     none 
  1146.  
  1147. Example: 
  1148.  
  1149. /* draw a set of text strings */
  1150.  
  1151. str.1 = 'You will need:
  1152. str.2 = '*  C Compiler'
  1153. str.3 = '*  OS/2 Programmer's Reference'
  1154.  
  1155. x = 50
  1156. y = 900
  1157. do i = 1 to 3
  1158.    call VSay id, x, y, str.i
  1159.    y = y - 100
  1160. end
  1161.  
  1162.  
  1163. ΓòÉΓòÉΓòÉ 4.24. VSetFont ΓòÉΓòÉΓòÉ
  1164.  
  1165. Purpose             Sets the current font to use for drawing text 
  1166.  
  1167. Definition 
  1168.  
  1169.                                         VSetFont [id] [type] [size]
  1170.  
  1171. Parameters          [id] is the id of the window.  [type] is a string 
  1172.                     representing the typeface requested, and [size] is the 
  1173.                     point size for the requested font. 
  1174.  
  1175. Comments            The point size must be a positive integer greater than 
  1176.                     zero.  The typeface must be one of the following strings: 
  1177.  
  1178.    o 'SYSTEM' - standard system font 
  1179.  
  1180.    o 'SYMBOL' - greek/math symbols 
  1181.  
  1182.    o 'COUR' - Courier, Courier Bold, Courier Italic, Courier Bold Italic 
  1183.  
  1184.    o 'COURB' 
  1185.  
  1186.    o 'COURI' 
  1187.  
  1188.    o 'COURBI' 
  1189.  
  1190.    o 'HELV' - Helvetica, Helvetica Bold, Helvetica Italic, Helvetica Bold 
  1191.      Italic 
  1192.  
  1193.    o 'HELVB' 
  1194.  
  1195.    o 'HELVI' 
  1196.  
  1197.    o 'HELVBI' 
  1198.  
  1199.    o 'TIME' - Times Roman, TR Bold, TR Italic, TR Bold Italic 
  1200.  
  1201.    o 'TIMEB' 
  1202.  
  1203.    o 'TIMEI' 
  1204.  
  1205.    o 'TIMEBI' 
  1206.  
  1207. Function Result     none 
  1208.  
  1209. Example: 
  1210.  
  1211. /* set the font to 20 point Helvetica Bold */
  1212.  
  1213. call VSetFont id, 'HELVB', 20
  1214.  
  1215.  
  1216. ΓòÉΓòÉΓòÉ 4.25. VSetTitle ΓòÉΓòÉΓòÉ
  1217.  
  1218. Purpose             Sets the titlebar of a window to a specified string 
  1219.  
  1220. Definition 
  1221.  
  1222.                                         VSetTitle [id] [title]
  1223.  
  1224. Parameters          [id] is the id of the window, and [title] is the new string 
  1225.                     to use for the window's titlebar. 
  1226.  
  1227. Comments 
  1228.  
  1229. Function Result     none 
  1230.  
  1231. Example: 
  1232.  
  1233. /* open a window with one title, then change it */
  1234.  
  1235. pos.left   = 25
  1236. pos.bottom = 25
  1237. pos.right  = 75
  1238. pos.top    = 75
  1239.  
  1240. id = VOpenWindow('Old Window Title', 'WHITE', pos)
  1241.  
  1242. call VSetTitle id, 'New Window Title'
  1243.  
  1244.  
  1245. ΓòÉΓòÉΓòÉ 4.26. VTableBox ΓòÉΓòÉΓòÉ
  1246.  
  1247. Purpose             Constructs a table dialog as a listbox, with programmable 
  1248.                     column widths 
  1249.  
  1250. Definition 
  1251.  
  1252.                                         VTableBox [title] [stem] [selection] [width] [height] [buttons]
  1253.  
  1254. Parameters          [title] is the string to use for the dialog titlebar. 
  1255.                     [stem] is the name of the stem variable which contains the 
  1256.                     number of rows and columns, column widths, column labels 
  1257.                     and text of each item to be placed in a table-style 
  1258.                     listbox. [selection] contains the number of the table row 
  1259.                     to be selected when the dialog is created.  [width] and 
  1260.                     [height] are the dimensions of the table in character 
  1261.                     units, and [buttons] is a number between 1 and 6 denoting 
  1262.                     the type of pushbuttons to display on the dialog. 
  1263.  
  1264. Comments            Any number of strings may be passed to this function, all 
  1265.                     with a maximum length of 80.  The number of columns in the 
  1266.                     table is limited to 10.  The number of rows and columns in 
  1267.                     the table are specified with the [stem].rows and 
  1268.                     [stem].cols variables.  The column widths are specified in 
  1269.                     [stem].width.1, [stem].width.2, etc. The column labels are 
  1270.                     specified in [stem].label.1, [stem].label.2, etc. Finally, 
  1271.                     the entries for the table are stored in row-column order, 
  1272.                     with [stem].1.1 being the entry for row 1, column 1, 
  1273.                     [stem].1.2 being the entry for row 1, column 2, etc. On 
  1274.                     output, [stem].vstring contains the table row number 
  1275.                     selected by the user. 
  1276.  
  1277. Function Result     'OK', 'CANCEL', 'YES' or 'NO', depending on the value of 
  1278.                     [buttons] 
  1279.  
  1280. Example: 
  1281.  
  1282. /* display a table of data */
  1283.  
  1284. table.rows = 50
  1285. table.cols = 3
  1286.  
  1287. table.label.1 = 'Name'
  1288. table.label.2 = 'Division'
  1289. table.label.3 = 'Serial Number'
  1290.  
  1291. table.width.1 = 20
  1292. table.width.2 = 10
  1293. table.width.3 = 15
  1294.  
  1295. table.1.1 = 'John Doe'
  1296. table.1.2 = 10
  1297. table.1.3 = 'CR1034'
  1298.  
  1299. table.2.1 = 'Mary Jane'
  1300. table.2.2 = 44
  1301. table.2.3 = 'TX1143'
  1302.  
  1303. /* etc. */
  1304.  
  1305. table.50.1 = 'Joe Programmer'
  1306. table.50.2 = 11
  1307. table.50.3 = '001101'
  1308.  
  1309. call VTableBox 'Pick a row from the table', table, 1, 50, 15, 1
  1310. selection_number = table.vstring
  1311.  
  1312.  
  1313. ΓòÉΓòÉΓòÉ 5. EXAMPLE VREXX PROCEDURES ΓòÉΓòÉΓòÉ
  1314.  
  1315. This section provides several example REXX procedures which give you some ideas 
  1316. about how to incorporate the VREXX functions in your own REXX programs.  The 
  1317. following examples are presented: 
  1318.  
  1319. TESTWIN.CMD         Shows creation and manipulation of PM windows, text 
  1320.                     display, etc. 
  1321.  
  1322. TESTDLGS.CMD        Demonstrates the use of the standard dialog functions, 
  1323.                     including filename and list item selections. 
  1324.  
  1325. TESTDRAW.CMD        Draws some arbitrary graphics to PM windows. 
  1326.  
  1327.  
  1328. ΓòÉΓòÉΓòÉ 5.1. TESTWIN.CMD ΓòÉΓòÉΓòÉ
  1329.  
  1330. /* TESTWIN.CMD */
  1331.  
  1332. '@echo off'
  1333. call RxFuncAdd 'VInit', 'VREXX', 'VINIT'
  1334. initcode = VInit()
  1335. if initcode = 'ERROR' then signal CLEANUP
  1336.  
  1337. signal on failure name CLEANUP
  1338. signal on halt name CLEANUP
  1339. signal on syntax name CLEANUP
  1340.  
  1341. /* display the version number of VREXX */
  1342.  
  1343. ver = VGetVersion()
  1344. msg.0 = 1
  1345. msg.1 = 'VREXX version # ' ver
  1346. call VMsgBox 'TESTWIN.CMD', msg, 1
  1347.  
  1348. /* open a window and draw some text */
  1349.  
  1350. win.left   = 20
  1351. win.right  = 70
  1352. win.top    = 80
  1353. win.bottom = 40
  1354. id = VOpenWindow('My VREXX Window', 'RED', win)
  1355.  
  1356. text.1 = 'This is a VREXX window, created with a call to VOpenWindow.'
  1357. text.2 = 'The window currently has a title = My VREXX Window, and it'
  1358. text.3 = 'has a red background, which can be changed by a call to the'
  1359. text.4 = 'VBackColor function.  The font is 12 point Times Roman.'
  1360.  
  1361. call VForeColor id, 'WHITE'
  1362. call VSetFont id, 'TIME', 12
  1363.  
  1364. x = 10
  1365. y = 900
  1366. do i = 1 to 4
  1367.    call VSay id, x, y, text.i
  1368.    y = y - 50
  1369. end
  1370.  
  1371. /* now display a message box */
  1372.  
  1373. msg.0 = 2
  1374. msg.1 = 'Press OK to change the window title, the'
  1375. msg.2 = 'window background color, and the font...'
  1376. call VMsgBox 'TESTWIN.CMD', msg, 1
  1377.  
  1378. /* change the title and background color */
  1379.  
  1380. call VSetTitle id, 'A New Title!'
  1381. text.2 = 'The new window title = A New Title!, and it'
  1382.  
  1383. call VClearWindow id
  1384. call VBackColor id, 'BLUE'
  1385. text.3 = 'has a blue background, which can be changed by a call to the'
  1386. call VForeColor id, 'WHITE'
  1387.  
  1388. /* change the font */
  1389.  
  1390. call VSetFont id, 'HELVB', 15
  1391. text.4 = 'VBackColor function.  The font is now 15 point Helvetica Bold.'
  1392.  
  1393. /* redraw the text in the window */
  1394.  
  1395. x = 10
  1396. y = 900
  1397. do i = 1 to 4
  1398.    call VSay id, x, y, text.i
  1399.    y = y - 60
  1400. end
  1401.  
  1402. /* now move and resize the window */
  1403.  
  1404. msg.0 = 3
  1405. msg.1 = 'Now the window will be cleared and moved around'
  1406. msg.2 = 'and resized using the VResize function.  Press'
  1407. msg.3 = 'OK to continue...'
  1408. call VMsgBox 'TESTWIN.CMD', msg, 1
  1409.  
  1410. call VClearWindow id
  1411.  
  1412. win.left   = 5
  1413. win.right  = 15
  1414. win.bottom = 80
  1415. win.top    = 95
  1416. call VResize id, win
  1417.  
  1418. do 8
  1419.    win.left   = win.left   + 5
  1420.    win.right  = win.right  + 10
  1421.    win.top    = win.top    - 5
  1422.    win.bottom = win.bottom - 10
  1423.    call VResize id, win
  1424. end
  1425.  
  1426. /* put up a message box */
  1427.  
  1428. msg.0 = 1
  1429. msg.1 = 'Press Cancel to end...'
  1430. call VMsgBox 'TESTWIN.CMD', msg, 2
  1431.  
  1432. call VCloseWindow id
  1433.  
  1434. /* end of CMD file */
  1435.  
  1436. CLEANUP:
  1437.    call VExit
  1438.  
  1439. exit
  1440.  
  1441.  
  1442. ΓòÉΓòÉΓòÉ 5.2. TESTDLGS.CMD ΓòÉΓòÉΓòÉ
  1443.  
  1444. /* TESTDLGS.CMD */
  1445.  
  1446. '@echo off'
  1447. call RxFuncAdd 'VInit', 'VREXX', 'VINIT'
  1448. initcode = VInit()
  1449. if initcode = 'ERROR' then signal CLEANUP
  1450.  
  1451. signal on failure name CLEANUP
  1452. signal on halt name CLEANUP
  1453. signal on syntax name CLEANUP
  1454.  
  1455. /* example VMsgBox call */
  1456.  
  1457. msg.0 = 4
  1458. msg.1 = 'This is a 4 line message box dialog.'
  1459. msg.2 = 'This is the line 2.  Line 3 is blank.'
  1460. msg.3 = ''
  1461. msg.4 = 'Press YES or NO to continue...'
  1462.  
  1463. call VDialogPos 50, 50
  1464. rb = VMsgBox('TESTDLGS.CMD', msg, 6)
  1465. if rb = 'YES' then do
  1466.    msg.0 = 1
  1467.    msg.1 = 'You pressed YES'
  1468. end
  1469. else do
  1470.    msg.0 = 1
  1471.    msg.1 = 'You pressed NO'
  1472. end
  1473. call VMsgBox 'VMsgBox Result', msg, 1
  1474.  
  1475. /* VInputBox example */
  1476.  
  1477. prompt.0 = 2
  1478. prompt.1 = 'Enter your name'
  1479. prompt.2 = '(Last name first, First name last)'
  1480. prompt.vstring = 'Doe John'
  1481. button = VInputBox('VInputBox example', prompt, 20, 3)
  1482.  
  1483. if button = 'OK' then do
  1484.    msg.0 = 3
  1485.    msg.1 = 'You entered the name'
  1486.    msg.2 = prompt.vstring
  1487.    msg.3 = 'and you pressed OK'
  1488. end
  1489. else do
  1490.    msg.0 = 1
  1491.    msg.1 = 'You pressed CANCEL'
  1492. end
  1493. call VMsgBox 'VInputBox Result', msg, 1
  1494.  
  1495. /* VMultBox example */
  1496.  
  1497. prompt.0 = 2   /* 2 prompt lines */
  1498. prompt.1 = 'User ID'
  1499. prompt.2 = 'Password'
  1500.  
  1501. width.0 = 2
  1502. width.1 = 10   /* widths in character units */
  1503. width.2 = 8    /* for both entryfields */
  1504.  
  1505. hide.0 = 2
  1506. hide.1 = 0     /* echo the User ID input */
  1507. hide.2 = 1     /* don't echo the Password */
  1508.  
  1509. answer.0 = 2
  1510. answer.1 = ''  /* these are the default strings */
  1511. answer.2 = ''  /* which will contain the input */
  1512.  
  1513. button = VMultBox('VMultBox example', prompt, width, hide, answer, 3)
  1514.  
  1515. if button = 'OK' then do
  1516.    call VMsgBox 'VMultBox Result', answer, 1
  1517. end
  1518. else do
  1519.    msg.0 = 1
  1520.    msg.1 = 'You pressed CANCEL'
  1521.    call VMsgBox 'VMultBox Result', msg, 1
  1522. end
  1523.  
  1524. /* VListBox example */
  1525.  
  1526. list.0 = 17
  1527. list.1  = 'OS/2 2.0 Standard Edition'
  1528. list.2  = 'OS/2 2.0 Extended Edition'
  1529. list.3  = 'MMPM/2 Multimedia Extensions'
  1530. list.4  = 'Windows 3.0 Multimedia Extensions'
  1531. list.5  = 'Adobe Type Manager'
  1532. list.6  = 'C-Set/2 Compiler'
  1533. list.7  = 'OS/2 2.0 Programmer Toolkit'
  1534. list.8  = 'WorkFrame/2'
  1535. list.9  = 'Lan Server'
  1536. list.10 = 'Lan Requester'
  1537. list.11 = 'TCP/IP'
  1538. list.12 = 'PMGlobe Demo Program'
  1539. list.13 = 'ASYNC Terminal Emulator'
  1540. list.14 = 'IPFC Preprocessor'
  1541. list.15 = 'VREXX'
  1542. list.16 = 'OS/2 2.0 Corrective Service'
  1543. list.17 = 'IBM SAA CUA Controls Library'
  1544. list.vstring = list.15          /* default selection */
  1545.  
  1546. call VDialogPos 25, 25
  1547. call VListBox 'Select a Product and Press YES', list, 35, 8, 4
  1548. msg.0 = 1
  1549. msg.1 = list.vstring
  1550. call VMsgBox 'VListBox Selection', msg, 1
  1551.  
  1552. /* test of VTableBox */
  1553.  
  1554. table.rows = 5
  1555. table.cols = 3
  1556.  
  1557. table.label.1 = 'Name'
  1558. table.label.2 = 'Division'
  1559. table.label.3 = 'Serial Number'
  1560.  
  1561. table.width.1 = 25
  1562. table.width.2 = 10
  1563. table.width.3 = 15
  1564.  
  1565. table.1.1 = 'Mary Jacobs'
  1566. table.1.2 = 20
  1567. table.1.3 = '243611'
  1568.  
  1569. table.2.1 = 'Joe Johnson'
  1570. table.2.2 = 19
  1571. table.2.3 = '837462'
  1572.  
  1573. table.3.1 = 'Henry Hill'
  1574. table.3.2 = 79
  1575. table.3.3 = '832628'
  1576.  
  1577. table.4.1 = 'Ruby Potts'
  1578. table.4.2 = 11
  1579. table.4.3 = '937567'
  1580.  
  1581. table.5.1 = 'Gary Williams'
  1582. table.5.2 = 22
  1583. table.5.3 = '086203'
  1584.  
  1585. button = VTableBox('Employee List', table, 1, 40, 10, 1)
  1586.  
  1587. msg.0 = 2
  1588. msg.1 = 'Button pressed was' button
  1589. msg.2 = 'Selection number =' table.vstring
  1590. call VMsgBox 'VTableBox Result', msg, 1
  1591.  
  1592. /* VRadioBox example */
  1593.  
  1594. list.0 = 10
  1595. call VRadioBox 'Select 1 item', list, 1
  1596. msg.0 = 1
  1597. msg.1 = list.vstring
  1598. call VMsgBox 'Selected item', msg, 1
  1599.  
  1600. /* test of VCheckBox */
  1601.  
  1602. list.0 = 10
  1603. sel.0 = 2
  1604. sel.1 = list.2
  1605. sel.2 = list.3
  1606. call VCheckBox 'Select items', list, sel, 1
  1607. if sel.0 > 0 then do
  1608.    call VMsgBox 'Selected items', sel, 1
  1609. end
  1610.  
  1611. /* VColorBox example */
  1612.  
  1613. call VDialogPos 75, 75
  1614. color.fore = 'YELLOW'
  1615. color.back = 'BLUE'
  1616. call VColorBox color
  1617. msg.0 = 2
  1618. msg.1 = 'Foreground color is' color.fore
  1619. msg.2 = 'Background color is' color.back
  1620. call VMsgBox 'Color selections', msg, 1
  1621.  
  1622. /* VFontBox example */
  1623.  
  1624. font.type = 'HELVB'
  1625. font.size = 25
  1626. call VFontBox font
  1627. msg.0 = 2
  1628. msg.1 = 'Font type is' font.type
  1629. msg.2 = 'Font size is' font.size
  1630. call VMsgBox 'Font selection', msg, 1
  1631.  
  1632. /* test of VFileBox */
  1633.  
  1634. call VDialogPos 10, 50
  1635. button = VFileBox('Pick a file...', 'c:\os2\*.exe', 'file')
  1636. msg.0 = 3
  1637. msg.1 = 'File name picked was'
  1638. msg.2 = file.vstring
  1639. msg.3 = 'Button pressed was' button
  1640. call VMsgBox 'VFileBox Result', msg, 1
  1641.  
  1642. /* end of CMD file */
  1643.  
  1644. CLEANUP:
  1645.    call VExit
  1646.  
  1647. exit
  1648.  
  1649.  
  1650. ΓòÉΓòÉΓòÉ 5.3. TESTDRAW.CMD ΓòÉΓòÉΓòÉ
  1651.  
  1652. /* TESTDRAW.CMD */
  1653.  
  1654. '@echo off'
  1655. call RxFuncAdd 'VInit', 'VREXX', 'VINIT'
  1656. initcode = VInit()
  1657. if initcode = 'ERROR' then signal CLEANUP
  1658.  
  1659. signal on failure name CLEANUP
  1660. signal on halt name CLEANUP
  1661. signal on syntax name CLEANUP
  1662.  
  1663. /* set up marker types */
  1664.  
  1665. default      = 0
  1666. cross        = 1
  1667. plus         = 2
  1668. diamond      = 3
  1669. square       = 4
  1670. star6        = 5
  1671. star8        = 6
  1672. soliddiamond = 7
  1673. solidsquare  = 8
  1674. soliddot     = 9
  1675. circle       = 10
  1676.  
  1677. /* set up line types */
  1678.  
  1679. solid      = 0
  1680. dot        = 1
  1681. dash       = 2
  1682. dashdot    = 3
  1683. dotdot     = 4
  1684. longdash   = 5
  1685. dashdotdot = 6
  1686.  
  1687. /* set up fill types */
  1688.  
  1689. nofill    = 0
  1690. solidfill = 1
  1691. horz      = 2
  1692. vert      = 3
  1693. leftdiag  = 4
  1694. rightdiag = 5
  1695.  
  1696. /* create 2 windows for drawing some graphics */
  1697.  
  1698. win1.left   = 15
  1699. win1.bottom = 30
  1700. win1.right  = 55
  1701. win1.top    = 70
  1702. id1 = VOpenWindow('TESTDRAW.CMD Graphics Window 1', 'WHITE', win1)
  1703.  
  1704. win2.left   = 60
  1705. win2.bottom = 10
  1706. win2.right  = 95
  1707. win2.top    = 40
  1708. id2 = VOpenWindow('TESTDRAW.CMD Graphics Window 2', 'BLACK', win2)
  1709.  
  1710. /* draw a line graph in window 1 */
  1711.  
  1712. call VForeColor id1, 'BLACK'
  1713.  
  1714. x.1 = 100
  1715. y.1 = 600
  1716. x.2 = 400
  1717. y.2 = 600
  1718. call VDraw id1, 'LINE', x, y, 2         /* x axis */
  1719. x.1 = 100
  1720. y.1 = 600
  1721. x.2 = 100
  1722. y.2 = 900
  1723. call VDraw id1, 'LINE', x, y, 2         /* y axis */
  1724.  
  1725. a = -0.000222   /* construct a quadratic polynomial */
  1726. b = 0.861       /* Y = a*X*X + b*X + c */
  1727. c = 566
  1728.  
  1729. x.1 = 100
  1730. y.1 = a*100*100 + b*100 + c
  1731. do i = 2 to 5
  1732.    j = i - 1
  1733.    x.i = x.j + 75
  1734.    y.i = a * x.i * x.i + b * x.i + c
  1735. end
  1736.  
  1737. call VDrawParms id1, soliddiamond, dashdot, default
  1738. call VDraw id1, 'MARKER', x, y, 5
  1739. call VDraw id1, 'LINE', x, y, 5
  1740.  
  1741. /* draw a set of arcs in window 2 */
  1742.  
  1743. call VForeColor id2, 'YELLOW'
  1744.  
  1745. cx = 100
  1746. cy = 200
  1747. radius = 20
  1748. angle1 = 0
  1749. angle2 = 60
  1750.  
  1751. do i = 1 to 6
  1752.    call VArc id2, cx, cy, radius, angle1, angle2
  1753.    radius = radius + 20
  1754.    cx = cx + 150
  1755.    angle2 = angle2 + 60
  1756. end
  1757.  
  1758. /* draw a bar graph in window 1 */
  1759.  
  1760. call VDrawParms id1, default, default, default
  1761. x.1 = 550
  1762. y.1 = 600
  1763. x.2 = 950
  1764. y.2 = 600
  1765. call VDraw id1, 'LINE', x, y, 2         /* x axis */
  1766. x.1 = 550
  1767. y.1 = 600
  1768. x.2 = 550
  1769. y.2 = 900
  1770. call VDraw id1, 'LINE', x, y, 2         /* y axis */
  1771.  
  1772. px.1 = 600
  1773. py.1 = 600
  1774. px.2 = 600
  1775. py.2 = 650
  1776. px.3 = 650
  1777. py.3 = 650
  1778. px.4 = 650
  1779. py.4 = 600
  1780.  
  1781. call VForeColor id1, 'RED'
  1782. do i = 1 to 6
  1783.    /* draw bar with a new fill type */
  1784.  
  1785.    call VDrawParms id1, default, solid, i-1
  1786.    call VDraw id1, 'POLYGON', px, py, 4
  1787.    call VDraw id1, 'LINE', px, py, 4
  1788.  
  1789.    px.1 = px.1 + 50
  1790.    px.2 = px.1
  1791.    px.3 = px.3 + 50
  1792.    px.4 = px.3
  1793.  
  1794.    py.2 = py.2 + 45
  1795.    py.3 = py.2
  1796. end
  1797.  
  1798. /* draw some lines of different types in window 2 */
  1799.  
  1800. color.1 = 'WHITE'               /* set up color array */
  1801. color.2 = 'RED'
  1802. color.3 = 'GREEN'
  1803. color.4 = 'BLUE'
  1804. color.5 = 'CYAN'
  1805. color.6 = 'YELLOW'
  1806. color.7 = 'PINK'
  1807.  
  1808. x.1 = 200
  1809. y.1 = 950
  1810. x.2 = 800
  1811. y.2 = 950
  1812.  
  1813. do i = 1 to 7
  1814.    call VForeColor id2, color.i
  1815.    call VDrawParms id2, default, i-1, default
  1816.    call VDraw id2, 'LINE', x, y, 2
  1817.  
  1818.    y.1 = y.1 - 100
  1819.    y.2 = y.1
  1820. end
  1821.  
  1822. /* set up a spline in window 1, drawing the control points */
  1823. /* of the spline as markers, and labelling them with text  */
  1824.  
  1825. sx.1 = 350
  1826. sy.1 = 450
  1827. sx.2 = 700
  1828. sy.2 = 200
  1829. sx.3 = 200
  1830. sy.3 = 125
  1831. sx.4 = 650
  1832. sy.4 = 425
  1833.  
  1834. call VForeColor id1, 'BLUE'
  1835. call VDrawParms id1, soliddot, default, default
  1836. call VDraw id1, 'MARKER', sx, sy, 4
  1837. call VDraw id1, 'SPLINE', sx, sy, 4
  1838.  
  1839. call VForeColor id1, 'GREEN'
  1840. call VSetFont id1, 'HELVB', 12
  1841. call VSay id1, 300, 75, 'Spline Control Points'
  1842.  
  1843. /* put up a message box */
  1844.  
  1845. msg.0 = 1
  1846. msg.1 = 'Press OK to close the windows'
  1847. call VMsgBox 'TESTDRAW.CMD', msg, 1
  1848.  
  1849. call VCloseWindow id1
  1850. call VCloseWindow id2
  1851.  
  1852. /* end of CMD file */
  1853.  
  1854. CLEANUP:
  1855.    call VExit
  1856.  
  1857. exit
  1858.  
  1859.  
  1860. ΓòÉΓòÉΓòÉ 6. TECHNICAL DATA ΓòÉΓòÉΓòÉ
  1861.  
  1862. VREXX packages its external functions in the dynamic link library VREXX.DLL. 
  1863. Thus, REXX procedures can load and call the VInit function, which sets up 
  1864. system resources and initializes the other VREXX external functions for access 
  1865. by REXX.  The VExit function then frees up these system resources before the 
  1866. REXX procedure exits. 
  1867.  
  1868. When VInit is called, it starts a copy of the new VREXX.EXE program and sets up 
  1869. a shared memory block to pass variables between the DLL and the program. The 
  1870. program creates an invisible control window, and waits for the VREXX external 
  1871. functions to post messages to the window.  The control window then creates the 
  1872. windows, draws graphics, processes dialogs, etc. 
  1873.  
  1874. Variables are shared between the DLL and the REXX environment through the 
  1875. shared variable pool. Stem variables are used to facilitate the use of REXX 
  1876. arrays by the user. Shared memory blocks and semaphores are used to pass data 
  1877. and synchronize between the DLL and the control window. 
  1878.  
  1879.  
  1880. ΓòÉΓòÉΓòÉ 7. RELEASE NOTES AND COMMENTS ΓòÉΓòÉΓòÉ
  1881.  
  1882. Version 1.0 (9/9/92) is the initial release.