Home THE HYPERCARD CENTER

HyperTalk Reference
Home » HyperTalk Reference » Commands

Note: This is a work in progress and will be formatting errors. Read more about the project on the home page.

answer

answer text

answer text with reply1
answer text with reply1 or reply2
answer text with reply1 or reply2 ¬
   or reply3

answer file text [of type fileType]

answer program text [of type ¬
 processType]

The form answer text displays a question (text ) in a dialog box. The dialog box contains from one to three buttons, each representing a different reply the user can select.

If you use answer without specifying any replies, HyperTalk displays an OK button as the default. Otherwise, the last reply you specify becomes the default button. (Pressing Enter or Return chooses the default button.) Answer returns the name of the button clicked by the user in the local variable it.

Answer automatically sizes the dialog box to fit the size of the text (up to 13 lines). The total length of the text cannot exceed 254 characters.

The form Answer file text displays a directory dialog box that you use to select a file.

answer file text of type fileType displays only files of a specified type: application, picture, painting or paint, stack, or text. (Click the fileType placeholder for more information about file types.)

Answer file returns the full pathname of the selected file in the local variable it. It returns empty if the user clicks Cancel.

Answer file also sets the result to Cancel if the user clicks Cancel. Check the value of the result in the statement immediately following answer file.

The form Answer program text produces a dialog box of all System 7-friendly processes currently running on the local machine and on any networked computers to which the local machine has access.

A System 7-friendly process is a program or entity that’s capable of exchanging information with another process. The name of the selected program is placed in the container it.

text is a quoted prompting string that appears at the top of the dialog box. If you provide the null string for text (that is, ""), the system puts Choose a program to link to: at the top of the dialog box.

Use the form answer program text of type processType to see only certain types of processes (spell checkers, word processors, spreadsheets, and so on).

An application's default process type is its creator. So to see only copies of HyperCard, you’d use WILD.

For more details, see "PPC Toolbox" in Inside Macintosh V.6 or Inside Macintosh: Interapplication Communications.


Examples

answer "The file has been saved."
answer "Really delete this file?" with "Yes" or "No"
answer "Sort by:" with "Cancel" or "Number" or "Name"

answer file "Choose a file to load:"
answer file "Where is the stack you want?" of type stack

answer file "Where is the program you want to open?" of type application
if the result is "Cancel" then ...

answer program "What program do you want to switch to?"
answer program "" -- prompts with "Choose a program to link to:"

Demo Script

on mouseUp
   answer file "Please select a file:" of type stack OR text
   if it is not empty then
     put it into fullPathName
     put fullPathToFileName(fullPathName) into fileName -- see below
     answer "You selected file: “" & fileName & "”" & return & return &¬
     "The full path for the file is:" & return & "“" & fullPathName & "”"
   end if
 end mouseUp
 

 function fullPathToFileName fullPathName
   put the itemDelimiter into savedDelimiter
   set itemDelimiter to ":"
   put last item of fullPathName into fileName
   set itemDelimiter to savedDelimiter
   return fileName
 end fullPathToFileName

Placeholders

text
An expression that evaluates to a text string.

A text expression can be a literal string surrounded by quotation marks or the value of a container.

For example:

"Hello"
"The sum is:" && 3
card field 1
line 1 of bg fld "Address"
the Message box
the selection
myVar -- a variable
See also: background, bkgnd, button, card, field, menu, menuItem, and stack

fileType
HyperTalk Definition1. One of the following constants:

application
picture
paint
painting
stack
text
2. An expression that evaluates to a four- character text string that identifies a file type:

"APPL" -- application"PICT" -- picture"PNTG" -- paint, painting"STAK" -- stack"TEXT" -- text

AppleScript DefinitionAn expression that evaluates to a file type recognized by the application receiving a command.

Related Topics

« add | HyperTalk Reference | arrowKey »


Version 0.7b1 (March 24, 2022)

Made with Macintosh

Switch to Modern View