Home
The HyperCard Center
HyperTalk Reference
Home » HyperTalk Reference » Functions

Note: This is a work in progress and will be formatting errors. 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

Placeholders

Related Topics

« numToChar | HyperTalk Reference | optionKey »

Version 0.7b1 (March 24, 2022)

Made with Macintosh

Switch to Retro View