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.

put

put expression
put expression preposition ¬
   [chunk of] container

put menuItemList preposition ¬
     [menuItem of] menu ¬
     [with menuMessages messageList]

The put command evaluates an expression and places the value it extracts into, after, or before the contents of a container.

The container can be a button, a field, a variable, the Message box, the selection, a chunk expression, or a menu. If you don’t specify a container, HyperCard puts the value into the Message box, showing it if it’s hidden.

Use put with into to replace the contents of a container or menu, with before to place the value at the beginning of its contents, and with after to append the value to the end of its contents.

The lines of text that you put into a pop-up button become the items of the menu that appears when you click the button.

Before you can add items to a menu, the menu must already exist.

The menuItemList is a comma-separated list of the items you want to add to the menu. Use the single character "-" to get a gray line. You can put up to 64 items into a menu with a single put statement.

The optional messageList is a comma-separated list of message names that HyperCard sends to the current card when the user chooses one of the menu items. The number of items in the messageList must equal the number of items in menuItemList.

To skip a message name, use an empty item—a null between two commas:

"myMessage 1,,myMessage 3"


Examples

-- These are equivalent:
put 42.5 * 675
put 42.5 * 675 into msg
put 42.5 * 675 into the Message box 

put empty into It  

put "Hello" into field 1  
put "Go: " before field "WhereTo"  
put "." after last character of last word of field 3  
put the date into varName
put the clickLine into theLineClicked
put the value of the clickLine into theTextClicked
put "*" after the selection

-- Add items to a menu:
create menu "Example"
put "1,2,3,-,4,5,6" into menu "Example"
put "7" after menu "Example" with menuMessage "beep"
put "a,b,c,-" before menu "example" ¬
    with menuMessages "beep,beep 2,beep 3,empty"

-- add items to a button
put "Boston" & return & "New York" & return & "Salem" into button "Maps"

Demo Script

on putDemo
   get bkgndFields()
   if the number of chars of it < 255 then answer it
 end putDemo
 

 function bkgndFields
   -- Returns a return-delimited list of the bg fields
   repeat with i = 1 to the number of bkgnd fields
     put the short name of bg field i & return after theFields
   end repeat
   return theFields
 end bkgndFields

Placeholders

expression
HyperTalk DefinitionAny HyperTalk expression. All expressions evaluate to text, a number, or a constant.

For example:

true
sin(90)
"this is" && it
(3+2) = 5
the heapspace div 1024


Note: Formally, HyperCard distinguishes between factors (simple values) and expressions. The difference between factors and expressions matters only if you like to drop parentheses. Most functions take factors as their parameters, which is why length of 3 + 5 returns 6 and length of (3 + 5) returns 1. In short, always use parentheses to group things the way you want them to evaluate, and you won’t have to worry about the difference between factors and expressions.

AppleScript DefinitionAny series of words that has a value.

preposition
One of the following:

into
before
after


chunk
One of the following forms (or combinations thereof):

ordinal charactercharacter posInteger [to posInteger ]ordinal wordword posInteger [to posInteger ]ordinal itemitem posInteger [to posInteger ]ordinal lineline posInteger [to posInteger ]

For example:

first character
second item
middle line
character 1
char 1 to 10
word 3
item 5 to (the number of items of me)
line 1 to 10
char 1 to 10 of word 2 to 4 of ¬
line 3 to 6
A chunk combined with of and a container is called a chunk expression. For example:
line 1 of card field "index"


Important: You can’t combine a stack name with a chunk expression—you can only refer to a chunk in the current stack.

container
HyperTalk DefinitionA place where you can store and retrieve a value.

There are six types of containers in HyperCard: a variable, a button, a field, the selection, the Message box, and menus.

myVariable
[the] selection
the Message box
btn 3
bg btn "Names"
card field 1
bkgnd field "Total"
menu 2
menu "Edit"
Additionally, you can refer to a button or field by its part number:

card part 1
last background part
AppleScript DefinitionAn object that contains one or more other objects, known as elements of the container. In a reference, the container specifies where to find an object. You specify containers with the reserved words of or in.

You can also use the possesive form ('s) to specify containers. For example, in

first window's name
the container is first window. The object it contains is a name property.

menuItemList
A comma-separated list of names that you want to appear on a menu.

Use the single character “-” to get a gray line.

For example, the Menu item list for the first 9 items on the Go menu would be:
"Back,Home,Help,Recent,-," & ¬
"First,Prev,Next,Last"
See also: messageList.

menuItem
An expression that evaluates to one of the following:

menuItem text
menuItem posInteger
ordinal menuItem
For example:

menuItem "New"
menuItem 2
second menuItem


menu
An expression that evaluates to one of the following:

menu text
menu posInteger
ordinal menu
For example:

menu "File"
menu 2
second menu


messageList
A comma-separated list of message names that you want sent when the user chooses a menu item in menuItemList.

Use empty to indicate no message in HyperTalk, or "" to indicate no message in AppleScript.

For example, the menu message list for the first 9 items on the Go menu would be:

"go back,go home,help," & ¬"go recent,empty," & ¬"go first,go prev,go next," & ¬"go last"


Related Topics

« push | HyperTalk Reference | read »

Version 0.7b1 (March 24, 2022)

Made with Macintosh

Switch to Retro View