StringRequest -- ask the user to enter a string (V2.0)
s$, ok = StringRequest(title$, body$[, def$, type, maxchars, password])
This function pops up a requester prompting the user to enter a string. The requester window will have the title you specify in the argument title$ and the body text specified in body$. Optionally, you can specify a default string that shall be displayed in the requester's string widget. If you do not specify def$, the string widget will be empty. The optional argument type can be used to specify which characters the user is allowed to type in, #ALL and #NUMERICAL are currently supported here. The optional argument maxchars can be used to limit the number of characters the user can type. This argument defaults to 0 which means that the user can type in as much as he wants. Last but not least there is the optional argument password, which can be set either to True or False. If it is set to True, the characters that the user types will not be visible.

The string that the user has entered will be returned by this function. if the user acknowledges the requester. If the user cancels this requester, an empty string will be returned. The second return value allows you identify whether or not the user pressed the 'OK' button. This is normally only needed if your application allows an empty string on 'OK'. In that case you need to check the second return value, too.

Please note that this command requires reqtools.library to be installed on AmigaOS 3, MorphOS, and AROS. Under AmigaOS 4 the StringRequest() function works without reqtools.library.

Starting with Hollywood 6.0 you can pass an empty string ("") in the first parameter. In that case, the requester will use the title specified in the @APPTITLE preprocessor command.

title for the requester window
text for the requester body
optional: default string for the string widget (defaults to "")
optional: which characters are accepted by the requester; currently possible are #ALL (accept everything) and #NUMERICAL (accepts numbers only) (defaults to #ALL)
optional: how many characters can be typed in (defaults to 0 meaning that the user can type in as much as he wants)
optional: True if the characters shall not be visible or False if they can be visible (defaults to False)
the string entered by the user or "" if requester was cancelled
True if the user pressed the 'OK' button, False otherwise (V4.5)
a$ = StringRequest("My Program", "Please enter your name!")
Print("Hello,", a$, "!")
Ask the user for his name and print it out.

Show TOC