VX-REXX Code snippets

From EDM2
Revision as of 17:20, 30 January 2017 by Ak120 (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This is simply a collection of a few small but useful examples of VX-REXX code.

Code for saving a changed windows position

This was an answer by Jacqueline Wells to a question in a USENET posting about how you could make a VX-REXX program sense if the user has changed the size and position of a window, so that next time the program was started it would open up in the same position and size as the last time it was used.

"The best way to handle this is to read the top, left, width and height properties of the window then write them out to an ini file when the application closes. I use the following code in the QUIT: routine of my VXRexx programs and it works like a charm:"

 /* Get and save window size and position */
 wHeight = VRGet( "Window1", "Height" )
 wWidth  = VRGet( "Window1", "Width" )
 wTop    = VRGet( "Window1", "Top" )
 wLeft   = VRGet( "Window1", "Left" )
 ok      = VRSetIni( IniAppName, "OpenHeight", wHeight, IniName, "NoClose" )
 ok      = VRSetIni( IniAppName, "OpenWidth",  wWidth,  IniName, "NoClose" )
 ok      = VRSetIni( IniAppName, "OpenTop",    wTop,    IniName, "NoClose" )
 ok      = VRSetIni( IniAppName, "OpenLeft",   wLeft,   IniName )

Where:

IniAppName  = the name of the application, eg "myProgName"
IniName     = the name of the ini file to use, eg "myProg.Ini"

Note = if this value is omitted, VXRexx will automatically use the OS2.ini file. Try to avoid doing this.

Open*       = OpenHeight, OpenTop etc. are the application key names to use in the ini file.
w*          = wHeight, wTop etc are the values to assign for the key name