The function in question is:
switch({source}, condition1, Condition Nth, value1, value Nth)
The Way I need to output it involves using 0 and 1s (True/False) and will look like this:
"switch([.]ALARM,1,0,On,Off, Unknown)"
Where the 1 and 0 need to be ints instead of strings.
The program we have to use at work does not allow me to use .format and I was curious is there a way to make this happen.
Example of what I have tried:
First test (index 0 is the 0 and/or 1s in question for both variables):
formula = "switch({source}, \"" + int(conditionOne[0]) + "\""+ "," + "\"" + int(conditionTwo[0]) + "\""+ "," + "\"" + conditionOne[1] + "\"" + "," + "\"" + conditionTwo[1] + "\"" + ", \"Unknown\")"
Second test (the program reads {} as sets instead of formatting:
test = "switch({source}, \"" + {0} + "\""+ "," + "\"" + {1} + "\""+ "," + "\"" + conditionOne[1] + "\"" + "," + "\"" + conditionTwo[1] + "\"" + ", \"Unknown\")".format(conditionOne[0],conditionTwo[0])
Edit and Answer:
I reached out to ignition personal and found out they use %d, which I have never used since the updates of python 3. I am guessing that program uses an old form of python?
Here is the code that gets it to work, if anyone else out there uses the ignition program:
test3 = "switch({source}, %d, %d," % (int(conditionOne[0]),int(conditionTwo[0])) + "\"" + conditionOne[1] + "\"" + "," + "\"" + conditionTwo[1] + "\"" + ", \"Unknown\")"
... + str(conditionOne[0]) + ...