CharOffset

Typeoperator
DictionaryLCB
LibraryLiveCode Builder
Syntax
the ( first | last ) offset of <Needle> in <Target>
Associationscom.livecode.char
Summary

Finds the first or last occurrence of Needle within Target

Parameters
NameTypeDescription
Needle

An expression which evaluates to a string.

Target

An expression which evaluates to a string.

Example
variable tVar as Number
put the first offset of "art" in "cartoon" into tVar -- tVar contains 2
variable tVar as Number
variable tFilePath as String
put "/Users/user/Documents/file.txt" into tFilePath
put the last offset of "/" in tFilePath into tVar

variable tFileName as String
put char 1 to tVar of tFilePath into tFileName -- tVar contains "file.txt"
Values
NameTypeDescription
return

Returns the offset of Needle in Target.

Description

The first (respectively last) offset of Needle in Target is number of chars between the first char of Target and the first (respectively last) occurrence of Needle. If neither first or last is specified, then the first offset is found. If Needle does not occur in Target, then the output is 0.

Tagsstrings