Python access to FB variables

Vincent,

How does python script access FB variables?

I defined a project variable varV1 and tried this simple script in an OnExecute handler:

the_world_is_flat = 1
if the_world_is_flat:
print "Be careful not to fall off!" print varV1


but FB borks with error message:
 NameError: name 'varV1' is not defined

Faithfully,
Sean.
 

 

Python and Powershell are a bit different from the active script based languages, you have to use the FBVariables collection :

FBVariables[“SETME”] = “hello world”
print FBVariables[“SETME”]

I see. Thanks.
You might want to update the chm help topic “Scripting in FinalBuilder”. The PowerShell case is mentioned in the help, but not the Python case.

Faithfully,
Sean