MIL_CONST_TEXT_PTR FunctionName, | //in |
MIL_INT ParameterNum, | //in |
MIL_CONST_TEXT_PTR InterpreterLanguage, | //in |
MIL_CONST_TEXT_PTR ScriptFileName, | //in |
MIL_CONST_TEXT_PTR ScriptFunctionName, | //in |
MIL_INT ScriptFunctionOpcode, | //in |
MIL_INT64 InitFlag, | //in |
MIL_ID *ScriptBasedContextFuncIdPtr | //out |
This function allows you to allocate a MIL function context for the current script-based user-defined MIL function. Being script-based, the function will, instead of calling a C function, run a function in a script. Call MfuncAllocScript() in the master function of the user-defined function. MfuncAllocScript() signals the creation of a user-defined MIL function, and should be the first MIL function called in the master function. It will also allocate a MIL function context identifier for the current function. You should use this MIL function context identifier as an argument for other Mfunc...() functions used during the user-defined function's execution. Once the function context is allocated, your function is known as a script-based user-defined MIL function. A script-based user-defined MIL function is considered a standard MIL function, respecting all MIL environment controls, such as tracing and error handling. The script that you provided as the slave-portion of the function is compiled/interpreted at runtime.
When defining the function context, you must specify a unique opcode for the script-based user-defined function. The opcode is used to locate the script-based user-defined function when an application calls the script-based user-defined function. You must also specify the language in which the script is written.
Script-based user-defined MIL functions can be grouped into user-defined script modules or remain ungrouped. To specify whether a user-defined function is grouped or not, and if grouped, assign it to a specific user-defined script module, pass an appropriate opcode to the ScriptFunctionOpcode parameter. Specify the opcode as a combination of two values: an offset from 0 to 63 and a label either identifying the module in which to group the function (M_SCRIPT_MODULE...) or identifying that the function is ungrouped (M_SCRIPT_FUNCTION). A user-defined script module can have up to 64 functions, and there can be up to 64 ungrouped functions.
Specifies the name of the script-based user-defined MIL function.
For specifying the name of the
user-defined function
|
|||||||||||||||||||||||||||||||||||||||
Value | Description
|
||||||||||||||||||||||||||||||||||||||
MIL_TEXT("FunctionName") 1 |
Specifies the name of the script-based user-defined MIL function. (more details...) |
1 If you are passing the value in a variable, don't enclose it in MIL_TEXT().
Specifies the number of parameters to be registered for the current user-defined function.
For specifying the number of
parameters
|
|||||||||||||||||||||||||||||||||||||||
Value | Description
|
||||||||||||||||||||||||||||||||||||||
0 <= Value <= 15 |
Specifies the number of parameters that you register for the function using MfuncParam() (or one of the type-specific versions of this function such as MfuncParamMILInt()). (more details...) |
Specifies the language and language version in which the script is written.
For specifying the path to the language
interpreter.
|
|||||||||||||||||||||||||||||||||||||||
Value |
Description
|
||||||||||||||||||||||||||||||||||||||
Specifies that the script is written in a language that can be identified using the supplied custom interpreter interface DLL. (more details...) |
|||||||||||||||||||||||||||||||||||||||
Parameters | |||||||||||||||||||||||||||||||||||||||
Specifies the drive, directory, and name of the file of the custom interpreter interface DLL file that you provide (for example, "C:\mydirectory\myCustomDLL.dll"). To specify the file on a remote computer (under Distributed MIL), prefix the specified file name string with "remote:///" (for example, "remote:///C:\mydirectory\myCustomDLL"). If the DLL file is not located in a directory that is part of the path environment variable, you must provide the full path to the file. |
|||||||||||||||||||||||||||||||||||||||
M_INTERPRETER_C_PYTHON27 |
Specifies that a CPython 2.7 based script is used. (more details...) |
||||||||||||||||||||||||||||||||||||||
M_INTERPRETER_C_PYTHON34 |
Specifies that a CPython 3.4 based script is used. (more details...) |
||||||||||||||||||||||||||||||||||||||
M_INTERPRETER_CSHARP |
[This is
only applicable to Windows]
Specifies that C# based code is used. |
||||||||||||||||||||||||||||||||||||||
M_INTERPRETER_VB_DOT_NET |
Specifies the name and path of the file containing the user-defined script. The script file must be accessible to the computer executing the script.
If the script file is not located in a directory that is part of the path environment variable, you must provide the full path to the file.
When developing a script-based user-defined MIL function that will be used in a Distributed MIL application, it is recommended that a copy of the script file be placed on all the remote computers in the cluster, in a directory that is part of the computer's path environment variable.
Specifies the name of the function to export from the script file.
Note that, unless using a custom interpreter interface DLL, an error is generated if no function name is provided. If a custom interpreter interface DLL is used which doesn't require a function name, you can pass M_NULL to this parameter.
Specifies the opcode to use to locate the script-based user-defined MIL function when an application calls the function. The opcode also serves to identify the module in which to group the function, if any.
To set a label identifying that the script-based user-defined MIL function is ungrouped, or a label identifying the module in which it is grouped, set one of the following:
For setting the label identifying that
the function is grouped or ungrouped
|
|||||||||||||||||||||||||||||||||||||||
Value | Description
|
||||||||||||||||||||||||||||||||||||||
M_SCRIPT_FUNCTION + |
Specifies that the script-based user-defined MIL function is an ungrouped user-defined MIL function. (more details...) |
||||||||||||||||||||||||||||||||||||||
M_SCRIPT_MODULE_1 + |
Specifies that the script-based user-defined MIL function will be grouped in the first module. (more details...) |
||||||||||||||||||||||||||||||||||||||
M_SCRIPT_MODULE_2 + |
Specifies that the script-based user-defined MIL function will be grouped in the second module. (more details...) |
You must add the following value to the above-mentioned values to set the offset.
For setting the offset
|
|||||||||||||||||||||||||||||||||||||||
Combination value | Description
|
||||||||||||||||||||||||||||||||||||||
0 <= Value <= 63 |
Sets the offset of the script-based user-defined MIL function among the ungrouped user-defined MIL functions or among those in the specified group. (more details...) |
Specifies more information about the script-based user-defined MIL function.
The values below allow you to set whether the script-based user-defined MIL function is executed asynchronously or synchronously.
For specifying whether the script-based
user-defined MIL function is executed asynchronously or
synchronously
|
|||||||||||||||||||||||||||||||||||||||
Value | Description
|
||||||||||||||||||||||||||||||||||||||
M_DEFAULT |
Specifies the default value. (more details...) |
||||||||||||||||||||||||||||||||||||||
M_ASYNCHRONOUS_FUNCTION + |
Specifies that the script-based user-defined MIL function will not wait for the slave script/function to finish executing before executing the next function (typically MfuncFree()) in the master function. (more details...) |
||||||||||||||||||||||||||||||||||||||
M_SYNCHRONOUS_FUNCTION + |
Specifies that the script-based user-defined MIL function will wait for the slave script/function to finish executing before executing the next function in the master function. (more details...) |
You must add one of the following values to the above-mentioned values to set whether the script-based user-defined MIL function can be executed remotely.
For specifying whether the script-based
user-defined MIL function can be executed remotely
|
|||||||||||||||||||||||||||||||||||||||
Combination value | Description
|
||||||||||||||||||||||||||||||||||||||
M_LOCAL |
Specifies that the script-based user-defined MIL function must be executed by the Host processor. (more details...) |
||||||||||||||||||||||||||||||||||||||
M_REMOTE |
Specifies that the script-based user-defined MIL function will be executed remotely, if possible. (more details...) |
You can add one of the following values to the above-mentioned value to set the type of the script-based user-defined MIL function.
Note that both M_ALLOC and M_FREE imply that the script-based user-defined MIL function is M_SYNCHRONOUS_FUNCTION, and cannot be added to M_ASYNCHRONOUS_FUNCTION.
For setting the type of script-based
user-defined MIL function
|
|||||||||||||||||||||||||||||||||||||||
Combination value | Description
|
||||||||||||||||||||||||||||||||||||||
M_ALLOC |
Specifies that the script-based user-defined MIL function is an allocation function, used to allocate a user-defined MIL object on a required system. |
||||||||||||||||||||||||||||||||||||||
M_FREE |
Specifies that the script-based user-defined MIL function frees an object allocated using a user-defined MIL allocation function. (more details...) |
Header | Include mil.h. |
Library | Use mil.lib. |
DLL | Requires mil.dll. |