GetText

GetValue


The GetValue function opens a dialog to request a string (or a value). If you click [OK], the entered string is saved to a history list and is returned. 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( s=nil, sPrompt=nil, sTitle=nil, sRegistry=nil, sTooltip=nil )

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

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

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

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

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

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

    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