Using variables within subprograms

This is on CB3 series. I have a program that runs fine by itself. There’s about a dozen or so variables in it that are local (not in installation file).

When I add this program as a sub-program in another program, I get error messages when loading about duplicate variables. This error message has 2 options to select (Rename duplicate variables, or Use installation variable). I selected rename duplicate so that I can see which ones are problematic, and it appears to be the variables in the “sub-program”. These variables are no where else in the main program.

My solution for the time being was to add the variables to the installation file, but I’d rather not do that. I don’t understand why it’s giving me a program since those variables are isolated, and the program works by itself.

1 Like

Are you creating the variables through a script of through the Polyscope interface? If you are creating variables on the sub-program using the Polyscope interface (e.g. the Assignment function to initialize their values), they will be by default global variables, so they are “visible” for the main program.
If you are using a script, make sure they are declared as locals:

local var1 = 0
local var2 = "Hello"

I am creating them in the polyscope interface with the assignment function. I tried creating a script file that had some of the variables in it, but the software things the program is incomplete.

I am facing the same problem. I have two SubPrograms that are used in a Main Program.

Now I want to copy the Main Program and use it to form a different part. Most of my program remains the same just the waypoints will be moved.

When I call the subprogram it asks me the same - to “rename variables in subprogram”, I selected Cancel to not change the variables and am having issues running the program correctly?

Were you able to find a fix?

1 Like