Skip to main content

CodeunitOffset

Type

operator

Summary

Finds the first or last occurrence of Needle within Target

Syntax

the ( first | last ) offset of codeunits <Needle> in <Target>

Description

The first (respectively last) offset of Needle in Target is number of codeunits between the first codeunit 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.

Parameters

NameTypeDescription

Needle

An expression which evaluates to a string.

Target

An expression which evaluates to a string.

Examples

variable tVar as Number
put the first offset of codeunits "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 codeunit 1 to tVar of tFilePath into tFileName -- tVar contains "file.txt"
Thank you for your feedback!

Was this page helpful?