vcScope
vcScope is a collection of statements in a robot program.
Properties
| Name | Type | Access | Description |
| ParentStatement | vcStatement | R | Gets the statement that owns the scope, for example a conditional If or While statement that has a nested block of statements; otherwise the value is None for routines. |
| Statements | List of vcStatement | R | Gets a list of statements belonging to the scope. |
Methods
| Name | Return Type | Parameters | Description |
| addStatement | vcStatement | Enumeration type, [Integer index]
or Enumeration type, Integer index, [String icon] |
Creates a new statement of a given type in the scope, and then returns that statement.
The default index value is -1 which adds the new statement to the end of the scope. An optional icon argument can be given to define the path of an icon used by the statement; otherwise the statement is given a default icon. See Statement Constants for more information. Note: If you want to add a custom statement, implement a vcPositionStatement as a process statement by passing a type of VC_STATEMENT_PROCESS or create an add-on. |
| clear | None | None | Deletes all statements in the scope. |
| deleteStatement | None | vcStatement statement | Deletes a given statement in the scope. |
| getStatement | vcStatement | Integer index | Returns a statement at a given index in the scope. |
Events
| Name | Parameters | Description |
| OnScopeExecuted | vcScope scope, Boolean isImmediate | Triggered when a scope is executed. The isImmediate argument defines whether the scope was executed in immediate mode (non time-consuming mode) or not. |
| OnStatementAdded | vcStatement | Triggered when a new statement is added to the scope. |
| OnStatementRemoving | vcStatement | Triggered when a statement is being deleted from the scope. |
Examples
Example. Add statement with custom icon
| from vcScript import * #Main routine of robot used in this case comp = getComponent() rx = comp.findBehavioursByType(VC_ROBOTEXECUTOR)[0] routine = rx.Program.MainRoutine #add with default index and icon statement1 = routine.addStatement("Process") #add to start of routine and use a default icon statement2 = routine.addStatement(VC_STATEMENT_HALT, 0) #add after first statement in routine and use custom icon statement3 = routine.addStatement("Process", 1, "rDetach") |