Xojo Conferences
MBSOct2019CologneDE

Platforms to show: All Mac Windows Linux Cross-Platform

Next items

MemoryBlock.AddressMBS(offset as Int64 = 0) as UInt64
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method MemoryBlock MBS Util Plugin 11.3 Yes Yes Yes Yes No
Function: Returns the adress of the byte at offset inside the memoryblock.

Some examples which use this method:

Feedback, Comments & Corrections

MemoryBlock.AddressPtrMBS(offset as Int64 = 0) as Ptr
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method MemoryBlock MBS Util Plugin 11.3 Yes Yes Yes Yes No
Function: Returns the adress of the byte at offset inside the memoryblock.

Some examples which use this method:

Feedback, Comments & Corrections

MemoryBlock.AndBitsMBS(Second as memoryblock, Dest as memoryblock=nil) as memoryblock
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method MemoryBlock MBS Util Plugin 9.8 Yes Yes Yes Yes No
Function: Performs a And on the bits in the memoryblock.
Example:
dim m1 as MemoryBlock = NewMemoryBlock(20)
dim m2 as MemoryBlock = NewMemoryBlock(20)
dim m3 as MemoryBlock = NewMemoryBlock(20)

m1.Int32Value(0)=&b10000001
m2.Int32Value(0)=&b10000000

MsgBox bin(m1.Int32Value(0))+EndOfLine+bin(m2.Int32Value(0))+EndOfLine+bin(m3.Int32Value(0))

call m1.AndBitsMBS(m2,m3)

MsgBox bin(m1.Int32Value(0))+EndOfLine+bin(m2.Int32Value(0))+EndOfLine+bin(m3.Int32Value(0))
Notes:
Dest is first and second memoryblock combine with a bitwiseand.
And first and second memoryblock are filled with the difference between them.

If dest is nil, a new memoryblock is created. You can speed up processing with reusing the same memoryblock in iterations. If you pass a memoryblock, the plugin does not check the size of the memoryblock.

Returns nil on any error. For example if source is a memoryblock without a known size.

See also:

Feedback, Comments & Corrections

MemoryBlock.AndBitsMBS(Second as memoryblock, Mask as Integer, Dest as memoryblock=nil) as memoryblock
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method MemoryBlock MBS Util Plugin 9.8 Yes Yes Yes Yes No
Function: Performs a And on the bits in the memoryblock.
Example:
dim m1 as MemoryBlock = NewMemoryBlock(20)
dim m2 as MemoryBlock = NewMemoryBlock(20)
dim m3 as MemoryBlock = NewMemoryBlock(20)

m1.Int32Value(0)=&b11110001
m2.Int32Value(0)=&b11110000

const mask = &b11001111

MsgBox bin(m1.Int32Value(0))+EndOfLine+bin(m2.Int32Value(0))+EndOfLine+bin(m3.Int32Value(0))

call m1.AndBitsMBS(m2,mask,m3)

MsgBox bin(m1.Int32Value(0))+EndOfLine+bin(m2.Int32Value(0))+EndOfLine+bin(m3.Int32Value(0))
Notes:
The mask is always 8 bit. Use the &b notation to specify it.
Dest is first and second memoryblock combine with a bitwiseand.
And first and second memoryblock are filled with the difference between them. Only bits set int he given mask are used.

If dest is nil, a new memoryblock is created. You can speed up processing with reusing the same memoryblock in iterations. If you pass a memoryblock, the plugin does not check the size of the memoryblock.

Returns nil on any error. For example if source is a memoryblock without a known size.

See also:

Feedback, Comments & Corrections

MemoryBlock.AppendMBS(other as memoryblock) as memoryblock
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method MemoryBlock MBS Util Plugin 3.3 Yes Yes Yes Yes No
Function: Returns a new memoryblock with the bytes of the two given memoryblocks.
Notes:
This function will not work if the memoryblock has an unknown size.
If one memoryblock is nil than you get a copy of the other memoryblock.

Feedback, Comments & Corrections

MemoryBlock.BytesEqualMBS(srcOfs as Integer, numBytes as Integer, destBlk as memoryBlock, destOfs as Integer) as Boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method MemoryBlock MBS Util Plugin Yes Yes Yes Yes No
Function: Returns true if equal byte data.
Example:
dim m1 as MemoryBlock = NewMemoryBlock(100)
dim m2 as MemoryBlock = NewMemoryBlock(100)

// try with 2 different strings
m1.CString(0)="Hello"
m2.CString(0)="Hallo"

if m1.BytesEqualMBS(0, 100, m2, 0) then
MsgBox "equal"
else
MsgBox "not equal"
end if

// try with 2 equal strings
m1.CString(0)="Hello"
m2.CString(0)="Hello"

if m1.BytesEqualMBS(0, 100, m2, 0) then
MsgBox "equal"
else
MsgBox "not equal"
end if
Notes:
Fixed in 10.1 to return true on equal bytes and false on non equal bytes. Older plugin versions returned the wrong value.

Does not check the bounds of the memoryblock, so it can crash with wrong parameters.
Returns false if one of the memoryblocks is nil.

Some examples which use this method:

Feedback, Comments & Corrections

MemoryBlock.BytesZeroMBS(srcOfs as Integer, numBytes as Integer) as Boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method MemoryBlock MBS Util Plugin 10.1 Yes Yes Yes Yes No
Function: Returns true if all bytes in the memoryblock in the given range are zero.
Example:
dim m as MemoryBlock = NewMemoryBlock(100)

if m.BytesZeroMBS(0,100) then
MsgBox "all zero"
else
MsgBox "error"
end if

m.Byte(50)=1

if m.BytesZeroMBS(0,100) then
MsgBox "error"
else
MsgBox "okay"
end if
Notes:
Returns false on any error.
Bounds are not checked with the memoryblock, so be careful.

Feedback, Comments & Corrections

MemoryBlock.ConvertRGB12BitTo8BitMBS(Width as Integer)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method MemoryBlock MBS Util Plugin 14.3 Yes Yes Yes Yes No
Function: Converts a memoryblock with 12 bit RGB data into 8 bit RGB data.
Notes:
Width is number of pixels.

Please make sure the memoryblock is 9 bytes bigger than input to avoid errors.
Plugin converts each 9 bytes (72 bits) with 2 RGB triple. So first 12 bits are red, next 12 bits green and last 12 bits blue.
Plugin removes last 4 bits.

Feedback, Comments & Corrections

MemoryBlock.CopyBytesFromMacHandleMBS(srcHandle as Integer, numBytes as Integer, destOfs as Integer)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method MemoryBlock MBS Util Plugin Yes No No Yes, macOS only No
Function: Copies bytes from Mac Handle into your memoryblock.
Notes: Same as CopyBytesFromMacPtr, only that the memory address is a so-called Handle (see documentation about the MacOS memory Manager), which is double-referenced.

Feedback, Comments & Corrections

MemoryBlock.CopyBytesFromMacPtrMBS(srcPtr as Ptr, numBytes as Integer, destOfs as Integer)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method MemoryBlock MBS Util Plugin Yes Yes Yes Yes No
Function: Copies the given amount of bytes from the given address in the Mac's memory address space into the memoryBlock.
Notes: Make sure that the destination block is large enough to hold the copied bytes (if not, your application or even the whole system can crash).

Feedback, Comments & Corrections

MemoryBlock.CopyBytesMBS(srcOfs as Integer, numBytes as Integer, destBlk as memoryBlock, destOfs as Integer)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method MemoryBlock MBS Util Plugin Yes Yes Yes Yes No
Function: Copies the specified amount of bytes into a second memoryBlock.
Example:
dim m as MemoryBlock
dim n as MemoryBlock

m=NewMemoryBlock(100)
n=NewMemoryBlock(100)

m.Long(0)=12345

m.CopyBytesMBS(0,4,n,0)

MsgBox str(n.long(0))
Notes: You must make sure that the destination block is large enough to hold the copied bytes (if not, your application or even the whole system can crash).

See also:

Some examples which use this method:

Feedback, Comments & Corrections

MemoryBlock.CopyBytesMBS(srcOfs as Integer, numBytes as Integer, destOfs as Integer)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method MemoryBlock MBS Util Plugin Yes Yes Yes Yes No
Function: Copies the specified amount of bytes inside the memoryBlock.
Notes: You must make sure that the copied bytes fit inside the block (if they don't, your application or even the whole system can crash).

See also:

Some examples which use this method:

Feedback, Comments & Corrections

MemoryBlock.CopyBytesToMacHandleMBS(srcOfs as Integer, numBytes as Integer, destHandle as Integer)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method MemoryBlock MBS Util Plugin Yes No No Yes, macOS only No
Function: Copies byte data from the memoryblock into the memory the handle is pointing to.
Notes: Same as CopyBytesToMacPtr, only that the memory address is a so-called Handle (see documentation about the MacOS memory Manager), which is double-referenced.

Feedback, Comments & Corrections

MemoryBlock.CopyBytesToMacPtrMBS(srcOfs as Integer, numBytes as Integer, destPtr as Ptr)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method MemoryBlock MBS Util Plugin Yes Yes Yes Yes No
Function: Copies the given amount of bytes from the memoryBlock to the given address in the Mac's memory address space.
Notes: Be careful where you copy the data to - you can easily crash your computer if you write to the wrong address space.

Feedback, Comments & Corrections

MemoryBlock.CopyByteToUShortMBS(dest as memoryblock, SourceOffset as Integer, DestinationOffset as Integer, ByteCount as Integer, divisor as Integer)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method MemoryBlock MBS Util Plugin 4.1 Yes Yes Yes Yes No
Function: Copies bytes in a memoryblock to another memoryblock converting the 8bit values to 16bit values.
Notes:
Common values for divisor are 256 and 257.
No bound checking. Crashes with invalid values. Optimized for special divisor values.

Some examples which use this method:

Feedback, Comments & Corrections

MemoryBlock.CopyNthBitsMBS(source as memoryblock, SourceOffsetBits as Integer, DestinationOffsetBits as Integer, BitCount as Integer, StepCount as Integer, NumberOfSteps as Integer) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method MemoryBlock MBS Util Plugin 6.3 Yes Yes Yes Yes No
Function: Copies every nth bits in the source memoryblock to the current memoryblock.
Notes:
BitCount = the number of bits to copy from each step.
StepCount = the number of bits to not copy.
NumberOfSteps = the number of rounds to do.
There is no bound checking. The function will crash with invalid parameters!

Feedback, Comments & Corrections

MemoryBlock.CopyNthBytesMBS(source as memoryblock, SourceOffsetBytes as Integer, DestinationOffsetBytes as Integer, ByteCount as Integer, StepCount as Integer, NumberOfSteps as Integer) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method MemoryBlock MBS Util Plugin 4.1 Yes Yes Yes Yes No
Function: Copies every nth bytes in the source memoryblock to the current memoryblock.
Example:
dim s,d as memoryBlock

s=NewmemoryBlock(100)
d=NewmemoryBlock(100)

s.CString(0)="Hello World!"

call d.CopyNthBytesMBS(s,0,0,2,4,3)

MsgBox d.CString(0) // "Heo rl"
Notes:
ByteCount = the number of bytes to copy from each step.
StepCount = the number of bytes to not copy.
NumberOfSteps = the number of steps to do.
There is no bound checking. The function will crash with invalid parameters!

Feedback, Comments & Corrections

MemoryBlock.CopyUShortToByteMBS(dest as memoryblock, SourceOffset as Integer, DestinationOffset as Integer, ByteCount as Integer, divisor as Integer)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method MemoryBlock MBS Util Plugin 4.1 Yes Yes Yes Yes No
Function: Copies shorts in a memoryblock to another memoryblock converting the 16bit values to 8bit values.
Notes:
Common values for divisor are 256 and 257.
No bound checking. Crashes with invalid values. Optimized for special divisor values.

Some examples which use this method:

Feedback, Comments & Corrections

MemoryBlock.ExpandBitsMBS(dest as memoryblock, SourceByteCount as Integer, LowValue as Integer = 0, HighValue as Integer = 255) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method MemoryBlock MBS Util Plugin 11.0 Yes Yes Yes Yes No
Function: Expands bits into bytes.
Example:
dim m1 as new MemoryBlock(200)
dim m2 as new MemoryBlock(1600)

for i as Integer = 0 to 127
m1.Int8Value(i) = i
next

dim n as Integer = 128
dim b as Boolean = m1.ExpandBitsMBS(m2, n)

break // see result in debugger
Notes:
Takes a bit from the source memoryblock and writes a byte for it to destination. Uses LowValue (default 0) if the bit is not set and HighValue (Default 255) if the bit is set.
Works only on x86 CPUs (no PPC).
Reads source memoryblock in 32 bit blocks and writes the destination in 32 byte blocks.

Feedback, Comments & Corrections

MemoryBlock.ExtractBitsMBS(Mask as Integer, Dest as memoryblock=nil) as memoryblock
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method MemoryBlock MBS Util Plugin 9.8 Yes Yes Yes Yes No
Function: Copies bits from a memoryblock to another.
Example:
dim mask as Integer = &b01010101
dim m as MemoryBlock = "Hello World"

dim r as MemoryBlock = m.ExtractBitsMBS(mask)

MsgBox r.StringValue(0,r.size) // shows "@EDDE UEPDD"
Notes:
The mask is always 8 bit. Use the &b notation to specify it.
If dest is nil, a new memoryblock is created. You can speed up processing with reusing the same memoryblock in iterations. If you pass a memoryblock, the plugin does not check the size of the memoryblock.

Returns nil on any error. For example if source is a memoryblock without a known size.

Feedback, Comments & Corrections

MemoryBlock.FillBytesMBS(offset as Integer, count as Integer, value as Integer)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method MemoryBlock MBS Util Plugin 3.3 Yes Yes Yes Yes No
Function: Fills memory with a specific byte value.
Notes: Caution: No bounds checking.

Some examples which use this method:

Feedback, Comments & Corrections

MemoryBlock.FindByteMBS(srcOfs as Integer, numBytes as Integer, byteValue as Integer) as Integer
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method MemoryBlock MBS Util Plugin 10.1 Yes Yes Yes Yes No
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.

Feedback, Comments & Corrections

MemoryBlock.FindBytesMBS(srcOfs as Integer, maxBytes as Integer, target as memoryBlock, targOfs as Integer, targLen as Integer) as Integer
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method MemoryBlock MBS Util Plugin Yes Yes Yes Yes No
Function: Finds some bytes from the target memoryblock inside the current memoryblock.

Feedback, Comments & Corrections

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

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

MsgBox str(n) // -1 as no value is not zero

m.Byte(30)=1

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

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

m.Byte(0)=255

n = m.FindNotByteMBS(0, 100, 255)

MsgBox str(n) // shows 1 as the byte at offset 1 is not 255
Notes: Returns -1 if the no byte was found which has not the given value.

Feedback, Comments & Corrections

MemoryBlock.FindStringMBS(srcOfs as Integer, maxBytes as Integer, target as String) as Integer
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method MemoryBlock MBS Util Plugin Yes Yes Yes Yes No
Function: Finds a string inside a memoryblock.

Feedback, Comments & Corrections

MemoryBlock.GetStringMBS(offset as Integer, numBytes as Integer) as String
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method MemoryBlock MBS Util Plugin Yes Yes Yes Yes No
Function: Returns a string from the memoryblock.
Notes: With newer RB versions you may better use StringValue.

Feedback, Comments & Corrections

MemoryBlock.InvertBytesMBS(offset as Integer, count as Integer)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method MemoryBlock MBS Util Plugin 7.0 Yes Yes Yes Yes No
Function: Inverts the given number of bytes in a memoryblock.
Example:
dim m as memoryblock
m=newmemoryblock(100)
' do something
m.InvertBytesMBS(0,100) // invert all bytes
Notes: Does work faster if count is a multiply of 4.

Some examples which use this method:

Feedback, Comments & Corrections

MemoryBlock.LeftMBS(length as Integer) as memoryblock
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method MemoryBlock MBS Util Plugin 3.3 Yes Yes Yes Yes No
Function: Returns a memoryblock with the first given number of bytes.
Notes:
If length is greater than the size of the memoryblock then then length is set to size.
Returns nil if length<=0 or on low memory.
This function will not work if the memoryblock has an unknown size.

Some examples which use this method:

Feedback, Comments & Corrections

MemoryBlock.MaxMBS(firstMem as Ptr, secondMem as Ptr, BitSize as Integer = 8, Signed as Boolean = false, offsetByte as Integer = 0, lengthBytes as Integer = 0) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method MemoryBlock MBS Util Plugin 14.2 Yes Yes Yes Yes No
Function: Calculates max values of values in memory.
Example:
dim m1 as new MemoryBlock(12)
dim m2 as new MemoryBlock(12)
dim mr1 as new MemoryBlock(12)
dim mr2 as new MemoryBlock(12)

for i as Integer = 0 to 11
m1.UInt8Value(i) = i
m2.UInt8Value(11-i) = i
next

if mr1.minMBS(m1, m2) then
if mr2.maxMBS(m1, m2) then

MsgBox EncodeHex(m1)+" first"+EndOfLine+_
EncodeHex(m2)+" second"+EndOfLine+_
EncodeHex(mr1)+" min"+EndOfLine+_
EncodeHex(mr2)+" max"

end if
end if
Notes:
firstMem and secondMem can be ptr or memoryblock with some values. Can be same as destination (the memoryblock the method is called at)
BitSize defines integer bit depth 8, 16, 32 or 64. Signed defines if to expect signed or unsigned integers.
offsetByte defines offset in destination memoryblock. lengthBytes is length of memory. If zero, we use size of destination memoryblock.
Passing bad parameters can easily lead to crash. Return true on success and false on failure and raises exceptions for invalid parameters.

Some examples which use this method:

Feedback, Comments & Corrections

Next items

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




Links
MBS Xojo Chart Plugins