Platforms to show: All Mac Windows Linux Cross-Platform

MemoryBlock.FindByteMBS(srcOfs as Integer, numBytes as Integer, byteValue as Integer) as Integer
Type Topic Plugin Version macOS Windows Linux iOS Targets
method MemoryBlock MBS Util Plugin 10.1 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Function: Finds the position of the first byte which has the given value.
Example:
dim m as MemoryBlock = NewMemoryBlock(100)
dim n as Integer

n = m.FindByteMBS(0, 100, 0)

MsgBox str(n) // shows 0 as the byte at offset 0 is zero

m.Byte(0)=1

n = m.FindByteMBS(0, 100, 0)

MsgBox str(n) // shows 1 as the byte at offset 1 is zero

m.FillBytesMBS(0,100,5)

n = m.FindByteMBS(0, 100, 6)

MsgBox str(n) // shows -1 as there is no byte with value 6
Notes: Returns -1 if the byte is not found.

See also:

Feedback, Comments & Corrections

MemoryBlock.FindByteMBS(values() as UInt8, StartByteOffset as Integer = 0) as Integer
Type Topic Plugin Version macOS Windows Linux iOS Targets
method MemoryBlock MBS Util Plugin 21.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Function: Finds position of a given value.
Example:
Dim m As MemoryBlock = "Hello World"

Dim u() As UInt8
u.Append Asc("e")
u.Append Asc("o")

Dim pos1 As Integer = m.FindByteMBS(u)
Dim pos2 As Integer = m.FindByteMBS(u, pos1+1)

// shows 1 and 4
MsgBox "Found position: "+Str(pos1)+" and "+Str(pos2)
Notes:
Values is an array of possible values to find.
For best performance avoid duplicates in that array.

Returns zero based byte offset.
Result is -1 if not found.

See also:

Blog Entries

Feedback, Comments & Corrections

The items on this page are in the following plugins: MBS Util Plugin.

The biggest plugin in space...




Links
MBS FileMaker blog

Start Chat