Home THE HYPERCARD CENTER

HyperTalk Reference
Home » HyperTalk Reference »

Note: This is a work in progress and many formatting issues have been fixed. Read more about the project on the home page.

offset

offset(text1, text2)

Value returned: the number 0 if text1 does not appear in text2; otherwise, a positive integer equal to the number of characters from the first character of text2 to the first character of text1 within text2

Examples

get offset("world", "Hello world")
put offset(searchString,card field "Index") into theOffset
put offset(line 1 of card field 1, collectedHits) into N
if N is 0 then ...
else ...

Demo Script

on answerDiskName
answer "This stack resides on the disk named" && diskName() & "."
end answerDiskName
function diskName thelongName
if thelongName is empty
then put the long name of this stack into theLongName
-- remove “stack "” from the beginning of theLongName
delete char 1 to offset(quote,theLongName) of theLongName
-- return word before the first “:”
return char 1 to offset(":",theLongName) - 1 of theLongName
end diskName

Related Topics

Placeholders

HyperTalk Reference


Version 0.8b4 (July 4, 2025)

Made with Macintosh

Switch to Modern View