returns the byte position of the first occourence of the specified string of binary data within container of binary data.
# Metadata
Platforms: desktop, server, mobile OS: mac, windows, linux, ios, android Introduced: 7.0 Security:
# Syntax
byteOffset(bytesToFind,binaryStringToSearch [,bytesToSkip])
# Params
- bytesToFind : a string of <binary data> to find - binaryStringToSearch : a container with <binary data> - bytesToSkip : A non-negative integer. If you don't specify how many <bytesToSkip>, the <byteOffset> <function> does not skip any bytes and starts at the beginning of the <binaryStringToSearch>.
# Examples
byteOffset("c","abcde") -- returns 3
byteOffset("b","abacadabra",2) -- returns 6
byteOffset("bark","embarking") -- returns 3
byteOffset(null & numberToByte(255),"End" & null & numberToByte(255)) -- returns 4
# Description
Use the byteOffset function to find where a string of binary data occurs within a container of binary data.
The value returned by the byteOffset function is the number of the bytes where bytesToFind appears in binaryStringToSearch. If the bytessToFind is not in binaryStringToSearch, the byteOffset function returns zero.
If the bytesToFind contains more than one byte, and the entire bytesToFind appears in the bytesToSearch, the byteOffset function returns the byte number where the bytesToFind starts.
If you specify how many bytesToSkip, the byteOffset function skips the specified number of bytes in the binaryStringToSearch. The value return is relative to this starting point instead of the beginning of the binaryStringToSearch.
# Tags
# See
- **keyword:** character, characters, integer, string, point - **operator:** begins with - **command:** find, sort container - **function:** offset, wordOffset, itemOffset, lineOffset, length, value - **control structure:** function - **glossary:** binary data, return, non-negative