The OPS provides the function of saving and restoring script variables in Python scripts.
A maximum of 100 script variables can be stored. A variable with the same name as one that has been stored will replace the stored one.
# Save script variables.
opsObj.context.save(varName, value)
# Restore script variables.
opsObj.context.retrieve(varName)
Method |
Description |
|---|---|
opsObj |
Specifies an OPS object. It is obtained through ops.ops() instantiation. |
varName |
Specifies the name of a variable. The value is a string of a maximum of 16 characters. |
value |
Specifies the value of a variable. The value can be a string of a maximum of 1024 characters or an integer ranging from –2147483648 to 2147483647. |
test.py
import ops
test = ops.ops()
print 'test context save'
a, des= test.context.save("varInt1", 111)
print 'save varInt1 return' , a
a, des= test.context.save("varStr2", 'testString')
print 'save varStr2 return' , a
print 'test context save over'
test.py
import ops
test = ops.ops()
print 'test context retrieve'
a, des = test.context.retrieve("varInt1")
print 'retrieve varInt1 = ', a
a, des = test.context.retrieve("varStr2")
print 'retrieve varStr2 = ', a
print 'test context retrieve over'