Instance
(Engine-Level Function)
Description: | Limit module instances. This function limits the number of fixed module instances allowed to run simultaneously and returns the old limit |
Returns: | Numeric |
Usage: | Script Only. |
Function Groups: | Basic Module |
Related to: | NumInstances | CalledInstances | GetInstance |
Format: | Instance(Module, Count) |
Parameters: |
Module |
Required. Any text expression that specifies the fixed module to limit. It must be in the current scope. Scope resolution operators ( \ ) are not permitted. If the module does not exist, nothing is done. If the module is not a fixed module, the return value is -1. |
Count |
Required. Any numeric expression that specifies the number of fixed module instances allowed to run simultaneously. If Count is in the range 1 to 2, 147,483,647, the new limit is set and the old limit is returned. If Count is 0, the limit is not changed, but the current limit is returned. Count is ignored if the module is not a queued module. |
Comments: | This function is recommended for experienced users only and is not needed for most applications. If this function is not used, the number of concurrent instances for a given fixed module defaults to 1. |
This limit is the number of concurrent instances allowed for each parent instance. Each parent module instance has a separate Count for each of its fixed modules, which is separate from other instances of itself.
Example:
If 1 Main; [ Motors = Instance("Motor", 5); ]
Assume that this statement is found in a module that has a child module called Motor. Execution of the script will cause Motors to be assigned a value of 1, and to limit the number of instances of Motors to 5 (note that it is necessary for Motor to be a member or an ancestor of Feeder). All instances the parent module will be affected, which is to say that each one will be allowed to have up to 5 running instances of Motor.