Definition of variables

I have defined some simple variables in a template in Teddy, see simple example below. The variable A can be defined previously in Teddy, e.g. “#define A=1”. In this case, A defined inside the template should not be changed (if A exist → A=1, else A=10). Does anyone have a good idea how to do this in Teddy?

#define A=1

sto#A 10 ! #A=10 only if it has not been defined previously outside the template.

Why don’t you just define all variables in a Prog Template with Sto?
Using #Define AND Sto is adding an extra layer of complexity, which seems unnecessary.

However if you really need to, here’s how you do it:

#define A=1

+Prog Template 
  sto#A $(A)
  sto#A 10

Will print A(0) = 1.0 with above code snippet and A(0) = 10.0 if you remove the define

1 Like