ObjectPascal
InputQuery
Function
Display a dialog that asks for user text input Dialogs unit
 function InputQuery ( const Caption, Prompt : string; var UserValue : string ) : Boolean;
Description
The InputQuery function displays a simple dialog box with the given Caption and Prompt message. It asks the user to enter data in a text box on the dialog.
 
If the user presses OK, the entered data is stored in the UserValue variable and the return value is True.
 
If the user cancels the dialog, then the return value is False and any entered data is lost.
 
Use to ask the user for simple data such as a name.
Related commands
InputBox Display a dialog that asks for user text input, with default
PromptForFileName Shows a dialog allowing the user to select a file
ShowMessage Display a string in a simple dialog with an OK button
ShowMessageFmt Display formatted data in a simple dialog with an OK button
ShowMessagePos Display a string in a simple dialog at a given screen position
 
Example code : Keep asking the user for their name until they do so
var
  value : string;

begin
  // Keep asking the user for their name
  repeat
    if not InputQuery('Test program', 'Please type your name', value)
    then WriteLn('User cancelled the dialog');
  until value <> '';

  // Show their name
  WriteLn('Hello '+value);
end;
Show full unit code
   A dialog is displayed asking for the user name.
   If the user types their name, 'Fred' and hits OK :
  
   Hello Fred    
  
   is then displayed