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.


find [international] text  ¬
   [in field] [of marked cards]

find chars [international] text ¬
   [in field] [of marked cards]

find word [international] text ¬
   [in field] [of marked cards]

find whole [international] text ¬
   [in field] [of marked cards]

find string [international] text ¬
   [in field] [of marked cards]

The find command searches for a text string in all the card and background fields (visible or not) of the current stack.

International considers diphthongs and diacritical marks as it searches. In field searches only a specific card or background field. Of marked cards restricts its search to marked cards.

When find succeeds, a box appears around found text (or the first part of the text if the targets are discontinuous); the result is set to empty. When find fails, the result is set to the string "Not found".

The commands find, find chars, and find word treat each word of the search string as a separate search item. For example, find "this command" is treated as find "this" and find "command". The search succeeds if HyperCard finds all the words of the search string anywhere on the card (or anywhere in the specified field). The words do not have to be in order.

The commands find whole and find string treat spaces as part of the search string. For example, find whole "this command" succeeds only if HyperCard finds that exact string, including the space. The words must appear in order for find whole to succeed.

To prevent find from searching in a particular field, card, or background, see dontSearch in Related Topics.

Here are the forms of find types:

  • find: Whole or partial strings starting from the beginning of a word.
  • find chars: Partial strings anywhere within a word.
  • find word: Whole words only.
  • find whole: Whole or partial strings, including spaces, starting from the beginning of a word.
  • find string: Partial strings anywhere, including spaces (ignores word boundaries).


find "HyperCard"

-- Restrict the search:
find "select" in bkgnd field "Title"
find "select" in card field id 8293
find "select" in marked cards
find "select" in field 2 of marked cards

-- Find partial matches or whole words only:
find chars "elect" in bkgnd fld "title" -- will match select
find word "msg" in second card field  
find chars international "bøhr"

-- Find whole and find string include any spaces as part of the string:
find whole "lets you search for a whole phrase" 
find string "ets you search for part of a phr"

-- Find the contents of a variable:
find whole currentFindVar

-- Find the contents of a field:
find whole (field "title") in field "index"

-- Find any general expression:
find string (char 1 to 4 of the short name of this card)

Demo Script

on findDemo
  -- find a contiguous string of characters, including spaces:
   set cursor to watch
   find string "ind a contig" in field "Demo Script"
   wait 2 seconds
   -- next, find a phrase:
   find whole "find a phrase" in field "Demo Script"
   wait 2 seconds
end findDemo


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:

"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

An expression that identifies a field by name, number, or id using one of the following forms (in AppleScript, use “background” in place of “bkgnd”):

card field id posInteger [of card ]card field text [of card ] -- namecard field posInteger [of card ]ordinal card field [of card ]

[bkgnd] field id posInteger [of card ][bkgnd] field text [of card ] -- name[bkgnd] field posInteger [of card ]ordinal [bkgnd] field [of card ]

For example:

card field id 3894
card field "My Notes"
card field 1
first card field
background field 3 of card 1
When used inside a field script in HyperTalk:
When a field receives a message:[the] target

A field can also be referred to as a part when you’re talking about its position among all buttons and fields within the same card or background.

Related Topics

« export paint | HyperTalk Reference | functionKey »

Version 0.7b1 (March 24, 2022)

Made with Macintosh

Switch to Modern View