display dialog "What is your name?" default answer ""
Explanation: The above statement will display a dialog and small text area where user can provide his/her input. Here the keyword default answer "" is necessary, if user input is required.
Figure 7.2.1 User Input Using Dialogs
set myName to display dialog "What is your name?" default answer "" set studentData to text returned of myName set lengthSize to length of text returned of myName
Explanation: Variable myName will store details of dialog. The dialog will ask the user for his/her name.
Once user, enters the name as input, studentData (type String) will store the actual text entered by user whereas lengthSize (type number) will store the length of text entered by user.
Figure 7.2.2 User Input Values Returned