Assign Variable

An Assign Variable statement sets the value of a robot variable.

Robot Variables

Routine Variables

A robot routine variable is a local variable in a robot program specific to a routine. For example, a variable in Main routine can only be set and referred to in the Main routine.

Program Variables

A program variable is a property and global variable of a robot program. You can add program variables using API. For example, you can add a global counter variable to a vcProgram object and use it in the Main routine and subroutines of that program.

from vcScript import *
 
comp = getComponent()
robotExecutor = comp.findBehaviour("Executor")
robotProgram = robotExecutor.Program
 
#find or create global counter in robot program
counter = robotProgram.getProperty("counter")
if not counter:
  counter = robotProgram.createProperty(VC_INTEGER, "counter")

Component Properties

A component property is a global variable of a robot and its program. A default or general property can be referenced by name, whereas a grouped property needs to be referenced using the syntax <group name>::<property name>.

Properties

Name Description
TargetProperty Defines the name of variable to assign a value.
ValueExpression Defines an expression that when evaluated returns the value to assign TargetProperty.