Now MsgGet is extended to handle arrays. Syntax:
MsgGet( cTitle, [ cMessage (or) aPrompts ], aData ) --> lModified
Simple example:
- Code: Select all Expand view RUN
local cName := "Mark"
local cCity := "New York"
local aData
aData := { cName, cCity }
if MsgGet( "Enter Values", { "Name", "City" }, aData )
cName := aData[ 1 ]
cCity := aData[ 2 ]
? cName, cCity
endif
Note: MsgGet() automatically pads some extra space for data entry and trims the values while returning.
Still this does not impress much. Even this involves writing many lines of code. If there are more variables more the code. We may still feel comfortable with coding a small dialog box of our own.
Now FWH makes the process even much simpler with the translate EDITVARS.
This is the translate:
#xtranslate EDITVARS <v1> [,<vN>] ;
[ TITLE <ttl> ] ;
[ PROMPTS <prmt,...> ] ;
[ PICTURES <pic,...> ] ;
[ VALIDS <bvld,...> ] ;
=> ;
MsgGet( <ttl>, {<prmt>}, ;
ArrTranspose( \{ \{ <"v1"> [,<"vN">] \}, ;
\{ bSETGET( <v1> ) [, bSETGET( <vN> ) ] \} , nil, ;
{<pic>}, {<bvld>} \} ) )
Now let us see how simole it is to get user input for multiple variables. Any number of variables.
First a very simple case:
- Code: Select all Expand view RUN
local cName, cCity, lMarried := .f., nSalary := 0.00
EDITVARS cName, cCity, lMarried, nSalary
? cName, cCity, lMarried, nSalary
Now let us use User friendly prompts and this time let us get User name and Password:
- Code: Select all Expand view RUN
local cUser, cPW
EDITVARS cUser, cPW PROMPTS "User Name", "Password"
? cUser, cPW
Please note how password edit is handled automatically.
The capability is not limited to two or three vairables. We can use for unlimited number of variables. The dialog box SCROLLS.
It is also possible for us to specify picture clauses, combo boxes, dbcombos, checkboxes (auto), memo edits, valids etc with a single command.
Here is a more complex example:
- Code: Select all Expand view RUN
local cName, cCity, cNotes
local cState := "NY"
local lMarried := .f., nAge := 20, nSalary := 20000.00
local aStates
use c:\fwh\samples\states
aStates := FW_DbfToArray()
close states
EDITVARS cName, cCity, cState, lMarried, nAge, nSalary, cNotes ;
PROMPTS "Name", "City", "State", "Married", "Age", "Salary", "Notes" ;
PICTURES nil, nil, aStates, nil, "99", nil, 'M' ;
VALIDS nil, nil, nil, nil, { || nAge >= 20 }, { || nSalary >= 10000 }
? cName, cCity, cState, lMarried, nAge, nSalary, cNotes
In this dialog, we have checkbox for logical values, memo edit for memos, DbCombo for State, Valid check for Age and Salary, etc.
Finally, if we are not happy with the bitmaps used by default, we can modify the bitmaps with our own globally (or till next change)
What if we have more variables than the screen can accommodate? No problem. The dialog Scrolls.