Platforms to show: All Mac Windows Linux Cross-Platform

DeclareFunctionMBS.ClearParameters
Type Topic Plugin Version macOS Windows Linux iOS Targets
method DynamicDeclares MBS Util Plugin 20.3 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Function: Clears all parameters.
Notes: Sets them all to zero/nil.

Feedback, Comments & Corrections

DeclareFunctionMBS.Constructor(Signature as String, FunctionPtr as Ptr)
Type Topic Plugin Version macOS Windows Linux iOS Targets
method DynamicDeclares MBS Util Plugin 20.3 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Function: The constructor.
Example:
// change path if you like to try this on Windows or Linux
Dim d As New DeclareLibraryMBS("/usr/lib/libz.1.dylib")

// zlibVersion
// ZEXTERN Const char * ZEXPORT zlibVersion Of((void));

Dim p As ptr = d.Symbol("zlibVersion")
Dim f As New DeclareFunctionMBS("()Z", p)

Dim n As String = f.Invoke
MsgBox "zlibVersion: "+n
Notes:
Pass the signature and function pointer from a C function.
If signature is incorrect, the application will probably crash with stack corruption.

Feedback, Comments & Corrections

DeclareFunctionMBS.Invoke as Variant
Type Topic Plugin Version macOS Windows Linux iOS Targets
method DynamicDeclares MBS Util Plugin 20.3 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Function: Invokes the function.
Example:
// change path if you like to try this on Windows or Linux
Dim d As New DeclareLibraryMBS("/usr/lib/libz.1.dylib")

// zlibVersion
// ZEXTERN Const char * ZEXPORT zlibVersion Of((void));

Dim p As ptr = d.Symbol("zlibVersion")
Dim f As New DeclareFunctionMBS("()Z", p)

Dim n As String = f.Invoke
MsgBox "zlibVersion: "+n

See also:

Feedback, Comments & Corrections

DeclareFunctionMBS.Invoke(Parameters() as Variant) as Variant
Type Topic Plugin Version macOS Windows Linux iOS Targets
method DynamicDeclares MBS Util Plugin 20.3 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Function: Invokes the function.
Notes:
First calls SetParameters with the given array to set parameters.
Then invokes the function.

See also:

Feedback, Comments & Corrections

DeclareFunctionMBS.ParameterBoolean(Index as Integer) as Boolean
Type Topic Plugin Version macOS Windows Linux iOS Targets
property DynamicDeclares MBS Util Plugin 20.3 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Function: The parameter as boolean.
Notes:
You can get and set value here.
(Read and Write computed property)

Feedback, Comments & Corrections

DeclareFunctionMBS.ParameterDouble(Index as Integer) as Double
Type Topic Plugin Version macOS Windows Linux iOS Targets
property DynamicDeclares MBS Util Plugin 20.3 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Function: The parameter value as double.
Notes:
You can get and set value here.
(Read and Write computed property)

Feedback, Comments & Corrections

DeclareFunctionMBS.ParameterInteger(Index as Integer) as Int64
Type Topic Plugin Version macOS Windows Linux iOS Targets
property DynamicDeclares MBS Util Plugin 20.3 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Function: The parameter as integer value.
Notes:
You can get and set value here.
(Read and Write computed property)

Some examples using this property:

Feedback, Comments & Corrections

DeclareFunctionMBS.ParameterPointer(Index as Integer) as Ptr
Type Topic Plugin Version macOS Windows Linux iOS Targets
property DynamicDeclares MBS Util Plugin 20.3 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Function: The parameter as pointer value.
Notes:
You can get and set value here.
(Read and Write computed property)

Feedback, Comments & Corrections

DeclareFunctionMBS.ParameterSingle(Index as Integer) as Single
Type Topic Plugin Version macOS Windows Linux iOS Targets
property DynamicDeclares MBS Util Plugin 20.3 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Function: The parameter as single value.
Notes:
You can get and set value here.
(Read and Write computed property)

Feedback, Comments & Corrections

DeclareFunctionMBS.ParameterString(Index as Integer) as String
Type Topic Plugin Version macOS Windows Linux iOS Targets
property DynamicDeclares MBS Util Plugin 20.3 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Function: The parameter as string value.
Example:
// We try to run strstr on C Library on macOS to find string in string with strstr as example:

Dim d As New DeclareLibraryMBS("/usr/lib/libc.dylib")

// char *strstr(Const char *__big, Const char *__little);

Dim p As ptr = d.Symbol("strstr")
Dim f As New DeclareFunctionMBS("(ZZ)Z", p)

f.ParameterString(0) = "Hello World!"
f.ParameterString(1) = "World"

Dim n1 As String = f.Invoke
// gives back World! as that was found

f.ParameterString(0) = "Hello World!"
f.ParameterString(1) = "xxx"

Dim n2 As String = f.Invoke
// gives empty string as not found

Break // see in debugger
Notes:
To avoid crashes, we only read strings from parameters with type string or pointer.
But you can assign a string value to all types, which may not make sense for numbers.
You can get and set value here.
(Read and Write computed property)

Feedback, Comments & Corrections

DeclareFunctionMBS.ParameterValue(Index as Integer) as Variant
Type Topic Plugin Version macOS Windows Linux iOS Targets
property DynamicDeclares MBS Util Plugin 20.3 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Function: Get or set the value as variant.
Notes:
We automatically convert values based on the parameter type.
The class stores reference to the variant when setting to make sure strings and MemoryBlocks are not freed too early.
You can get and set value here.
(Read and Write computed property)

Feedback, Comments & Corrections

DeclareFunctionMBS.SetParameters(paramArray Parameters as Variant)
Type Topic Plugin Version macOS Windows Linux iOS Targets
method DynamicDeclares MBS Util Plugin 20.3 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Function: Set all parameters together with passing arguments to this function.
Example:
// We try to run sysctlbyname on macOS

Dim d As New DeclareLibraryMBS("/usr/lib/libc.dylib")

// int sysctlbyname(const char *name, void *oldp, size_t *oldlenp, void *newp, size_t newlen);

Dim p As ptr = d.Symbol("sysctlbyname")

'const char* -> CString for name -> Z
'void* -> pointer to data -> p
'size_t * -> pointer to 32/64 bit integer for length -> p
'void* -> pointer to data -> p
'size_t -> 32/64bit unsigned int -> L in 64-bit

Dim f As New DeclareFunctionMBS("(ZpppL)i", p)

Dim mData As New MemoryBlock(8)
Dim mLen As New MemoryBlock(8)
Dim pData As ptr = mData
dim pLen as ptr = mLen

mLen.UInt64Value(0) = mData.Size

f.SetParameters "hw.ncpu", pData, pLen, Nil, 0
Dim n As Integer = f.Invoke
// result is zero on result or -1 on failure

Dim CPUCount As Integer = mData.UInt32Value(0)

If n = 0 Then
MsgBox "CPU count: "+Str(CPUCount)
Else
MsgBox "Failed."
End If

Break // see in debugger

See also:

Feedback, Comments & Corrections

DeclareFunctionMBS.SetParameters(Parameters() as Variant)
Type Topic Plugin Version macOS Windows Linux iOS Targets
method DynamicDeclares MBS Util Plugin 20.3 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Function: Sets all arguments by passing an array of values.

See also:

Feedback, Comments & Corrections

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

The biggest plugin in space...




Links
MBS FileMaker Plugins

Start Chat