GetValue


The GetValue function opens a dialog to request a string or value. If you click [OK], the entered string is returned to the script and saved to a history list for the dialog. The current string is shown in the edit field of the list box. The remaining items in the list box show a history of strings that have been recently used and which may be selected. This function is similar to GetString except that a history list is maintained.

 

Syntax

sStr, bOK = GetValue()

sStr, bOK = GetValue( s )

sStr, bOK = GetValue( s, sPrompt )

sStr, bOK = GetValue( s, sPrompt, sTitle )

sStr, bOK = GetValue( s, sPrompt, sTitle, sRegistry )

sStr, bOK = GetValue( s, sPrompt, sTitle, sRegistry, sTooltip )

bullet.gif    s is the initial string. If nil, a blank string is used.

bullet.gif    sPrompt is the message above the string field. If nil, a default is used.

bullet.gif    sTitle is the window title. If nil, a default is used.

bullet.gif    sRegistry is the key for the history list in the Windows Registry. If nil, the default registry is used.

bullet.gif    sTooltip is the string for a popup Tooltip. If nil, no Tooltip is used.

bullet.gif    If [OK] is clicked, the string sStr and the button bOK=true are returned

bullet.gif    If the dialog is canceled, "",false is returned.

Remarks

All arguments are optional and assume default values beyond the last argument you specify. To use a default argument but follow it with a specified argument, use a nil in its place.

This function maintains a history list in the Windows registry. By choosing different names for the sHistory argument, you can have different history lists for different instances of the dialog. If [OK] is clicked, the string is added to the history list and returned as the value sStr.

Although this function returns a string, it can also be used to fetch numbers. After the function returns, the calling module can convert sStr to a number using the Lua function tonumber(). Of course, Lua allows implicit conversion; when a number is needed but a string form of the number exists, Lua will automatically attempt to convert the string to a number.

Example

The window shown above was created using the following code, specifying on the initial value:

 

str, bOK = GetValue( "Starting value" )

-- initial value is specified

Related Topics

GetNumber, GetString

 


Mira Pro x64 Script User's Guide, Copyright Ⓒ 2024 Mirametrics, Inc. All Rights Reserved.