DotNetObject.Call
WTSupported in traditional Synergy on Windows
|
|
|
|
retval = object.Call(methodname [, arg ...])
Arguments
retval
The return value of the method (@System.Object).
object
The handle of an object returned by the DotNetObject constructor, the DotNetAssembly constructor, or some other method or property that returns an object.
methodname
The name of the method to call.
arg
One or more arguments for the method.
Discussion
Methodname must be a public or public static method defined for the specified object; otherwise, an $ERR_MISSMETH error will occur.
If a method is defined more than once using different parameters, the default binder is used to attempt to locate the best fit for the parameters passed. The binder attempts an exact match, a conversion match honoring integer variable sizes matching the same or larger types, and finally, a conversion match from any int to any int. If no match is found, an $ERR_MISSMETH error will occur.
The type and number of arguments in arg must exactly match one of the argument signatures for the method; optional arguments and variable-length argument lists are not supported.
The system attempts to convert parameters from Synergy/DE types to .NET types via an intermediate type according to the rules below:
- Alpha is converted to System.String.
- Implied-decimal is converted to System.Decimal.
- If the target is float or double the value passed is converted to that type.
- Decimal is converted to Int64.
- If the target is Boolean, Byte, Int16, Int32, Int64, SByte, UInt16, UInt32, or UInt64, the Int64 value passed is converted to that type.
- Integer arguments rely on the types of the arguments expected.
- An enumeration is treated like an i4, and an i4 can be passed to a .NET enumeration.
- If there is no exact match, integer arguments are converted to Boolean, Byte, Int16, Int32, Int64, SByte, UInt16, UInt32, or UInt64.
The intermediate type is then converted by the standard .NET conversion functions as permitted by the binder. It is important to follow the .NET rules for conversions, or the .NET Framework will generate an exception. A .NET exception is also caused by the following circumstances:
- A negative value is passed to an unsigned type.
- A value in a larger type is passed to a smaller type (for example, Int32 containing 100000 is passed to Int16).
To pass a null object as a parameter, use ^NULL.
Objects are returned as follows, depending on the .NET type:
Returned object |
|
---|---|
System.String |
Synergy System.String |
System.Decimal |
Boxed Synergy implied-decimal value |
One of the integer types described above |
Boxed Synergy integer value of appropriate size |
Any other returned .NET type |
Type DotNetObject, wrapping the returned .NET object |
If object is an object returned from the DotNetAssembly constructor, only static methods can be accessed using the namespace.class.method form of methodname.
Examples
The example below invokes DateTime.Parse. See Sample programs for an example in the context of a complete program.
obj2 = (DotNetObject)((DotNetObject)asm).Call("System.DateTime.Parse", & "13 March 1986")