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.
|
|
sStr, bSuccess = GetValue()
sStr, bSuccess = GetValue( s )
sStr, bSuccess = GetValue( s, sPrompt )
sStr, bSuccess = GetValue( s, sPrompt, sTitle )
sStr, bSuccess = GetValue( s, sPrompt, sTitle, sRegistry )
sStr, bSuccess = GetValue( s, sPrompt, sTitle, sRegistry, sTooltip )
where
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.
bSuccess is an optional success flag.If [OK] is clicked, the string sStr is returned and bSuccess=true. If the dialog is canceled, "", false is returned.
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.
The window shown above was created using the following code. The initial value displayed in the edit field is passed as "Starting value":
|
-- initial value is specified |
|
|