Passing variables between functions

I have two functions defined in BLOCKY.

Using Python Code to define variable in one function:
spray_length = 1

Second function I try to use same variable but get an error that “spray_length” is undefined.

Do variables have to get defined inside a function when using Python Code?

Can they be made GLOBAL using Python Code?

Hi,
Could you show me the codes to help us understand the question?

1 Like

Vacuum_Spray_Sequence - Capture

I want to move the “Python Code spray_length = 2” command to a different function.

Initialize_operator_settings - Capture

When I move it I then I get the following error:

spray_length_undefined ERROR - Capture

I want to define a VARIABLE in the “initialize operator settings” FUNCTION and have it passed to the “vacuum_spray_sequence” FUNCTION,

Hi
image
Try to modify the python code here

global spray_length           
spray_length=2
1 Like

Here is how I was able to define a variable in one function and pass it to another without any errors.

spray_length = 1

Initialize_operator_settings - Capture

and used in another funcrtion that calls the variable using Python Code:

Vacuum_Spray_Sequence - Capture

by using time.sleep(self_vars[‘spray_length’])

Cool, that’s a better way.