Xojo Developer Conference
25/27th April 2018 in Denver.
MBS Xojo Conference
6/7th September 2018 in Munich, Germany.

Platforms to show: All Mac Windows Linux Cross-Platform

ArrayIsAMBS(v as Variant, ClassName as string) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
global method System MBS Util Plugin 12.3 Yes Yes Yes Yes No
Function: Checks if variant contains an array of the given class type.
Example:
dim w() as MouseCursor
w.Append System.Cursors.ArrowEastWest
w.Append System.Cursors.ArrowNorthSouth

dim v as Variant = w

if ArrayIsAMBS(w, "MouseCursor") then
MsgBox "OK"
end if
Notes:
If the variant contains an array of some class, variant or object and has at least one value, the plugin checks this first value for being of type of the same class. Like an ISA check.
This helps to solve feedback case 12213.
Returns false if variant has no array, if variant is nil, if array is not an array of objects or if first object is nil.

Feedback, Comments & Corrections

BacktraceMBS(MaxFrames as Integer = 0, skip as Integer = 2) as string()
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
global method System MBS Util Plugin 13.0 Yes No Yes No No
Function: Queries the stack trace of the current function.
Example:
MsgBox Join(BacktraceMBS, EndOfLine)
Notes:
MaxFrames: How many steps to show at maximum. Default is 128 currently.
skip: How many entries to skip. Default is 2 to not show this function.
Requires Mac OS X 10.5 or Linux.
Skip is 2 to hide this plugin function in the list.

Feedback, Comments & Corrections

GetAutoMemoryAddressMBS(o as auto) as integer
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
global method System MBS Util Plugin 17.3 Yes Yes Yes Yes No
Function: Queries memory address of auto object.
Notes: Allows you to compare if two variables refer same object.

Some examples using this method:

Feedback, Comments & Corrections

GetObjectMemoryAddressMBS(o as object) as integer
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
global method System MBS Util Plugin 17.3 Yes Yes Yes Yes No
Function: Queries memory address of object.
Notes: Allows you to compare if two variables refer same object.

Some examples using this method:

Feedback, Comments & Corrections

GetStringMemoryAddressMBS(s as string) as integer
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
global method System MBS Util Plugin 17.3 Yes Yes Yes Yes No
Function: Queries memory address of string.
Notes: Allows you to compare if two variables refer same string.

Some examples using this method:

Feedback, Comments & Corrections

GetTextMemoryAddressMBS(s as text) as integer
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
global method System MBS Util Plugin 17.3 Yes Yes Yes Yes No
Function: Queries memory address of text object.
Notes: Allows you to compare if two variables refer same text.

Some examples using this method:

Feedback, Comments & Corrections

GetVariantArrayMBS(VariantContainingArray as Variant) as Variant()
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
global method System MBS Util Plugin 14.0 Yes Yes Yes Yes No
Function: Queries a variant containing array for an array and returns it as an array of variant.
Example:
dim test() as Dictionary
test.Append new Dictionary

dim v() as Variant = GetVariantArrayMBS(test)
dim dic as Dictionary = v(0)
Break
Notes:
Works with all arrays of objects (any type).
Raises exception if the array can't be converted or the variant contains no array.

Feedback, Comments & Corrections

GetVariantArrayUboundMBS(v as Variant) as Integer
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
global method System MBS Util Plugin 13.0 Yes Yes Yes Yes No
Function: Queries array ubound for an array inside a variant.
Notes:
If you have an array in the variant, you'd normally assign it to an array to query values from array.
This function queries ubound directly.
Returns -3 if variant is nil and -2 if variant contains not an object array.
Updated in 13.5 plugins to raise exception is array is nil.

Some examples using this method:

Feedback, Comments & Corrections

GetVariantArrayValueMBS(v as Variant, index as Integer) as Variant
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
global method System MBS Util Plugin 13.0 Yes Yes Yes Yes No
Function: Queries an object from an array of objects inside a variant.
Example:
// some part of app builds an array
dim a() as pair
a.Append 1:"Hello"
a.Append 2:"World"

// passes it as Variant somewhere else

dim v as Variant = a

// and later you may want to get values back without knowing the array type

// this raises TypeMismatchException
'dim o() as Object = v

// so use plugin to get objects:
dim v1 as Variant = GetVariantArrayValueMBS(v, 0)
dim v2 as Variant = GetVariantArrayValueMBS(v, 1)

// now you can check type and cast to the object type
dim p1 as pair = v1
dim p2 as pair = v2

MsgBox p1.Right+" "+p2.Right
Notes:
This function is to allow getting objects from an array inside a variant without known the class used to declare array.
Returns nil on any error.
Updated in 13.5 plugins to raise exception is array is nil.
Also updated to work with object, variant, string, date, integer, double, single, boolean, Int64 arrays. Other array types will raise exception.

Some examples using this method:

Feedback, Comments & Corrections

MillisecondsMBS as Double
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
global method System MBS Util Plugin 13.5 Yes Yes Yes Yes No
Function: Queries current milliseconds time.
Notes: Like Microseconds in Xojo (Real Studio), but queries system functions for milliseconds counter.

Feedback, Comments & Corrections

ObjectIsAMBS(o as object, ClassName as string) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
global method System MBS Util Plugin 12.3 Yes Yes Yes Yes No
Function: Checks if a given object is of a given class.
Example:
// you must know exact name of class

dim v as Variant = window1

if ObjectIsAMBS(v, "window1.window1") then
MsgBox "OK"
end if

v = System.Cursors.MagnifyLarger

if ObjectIsAMBS(v, "MouseCursor") then
MsgBox "OK"
end if
Notes:
Like ISA operator, but with class name as string.
Returns false if o is nil.

Feedback, Comments & Corrections

SetVariantArrayValueMBS(v as Variant, index as Integer, value as Variant)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
global method System MBS Util Plugin 16.2 Yes Yes Yes Yes No
Function: Sets an object from an array of objects inside a variant.
Example:
// some part of app builds an array
dim a() as pair

// passes it as Variant somewhere else

dim v as Variant = a

// and later you may want to put values in array without knowing object type for array

// this raises TypeMismatchException
'dim o() as Object = v

// so use plugin

SetVariantArrayValueMBS(v, 0, 1:"Hello")
SetVariantArrayValueMBS(v, 1, 2:"World")

MsgBox a(0).Right+" "+a(1).Right
Notes:
This function is to allow setting objects in an array inside a variant without known the class used to declare array.
Also updated to work with object, variant, string, date, integer, double, single, boolean, Int64 arrays. Other array types will raise exception.
Be sure to only put objects of right class in the array! Else you risk crashes.

If index is 1 bigger than ubound, we append an element.

Feedback, Comments & Corrections

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




Links
MBS Xojo Plugins