I need to be able to loop through a list and for each item I hit in the list, I need to save the item as a separate global variable.
An Example Of The List in test_variables.txt file:
Each first word in the list needs to be assigned as the name of the global variable.
Each second word after the first word is the value of the variable and the value needs to be assigned to the global
Example: Test_ID would be the name of the global variable and Test_01 would be the value that needs to be assigned.
Sensetalk Code I Have So Far:
set runScriptCommand= “/bin/bash” && ResourcePath(“\run_python.sh”)
put ResourcePath(test_variables.txt) into inputFile
put file inputFile into myList
put each line of myList into variableList
repeat with each line of variableList
put word 1 of it into variableName
put word 2 of it into variableValue
if variableValue is empty then put "" into global variableName
else put variableValue into global variableName
In the return above, I want to return all global variables.
One issue that I have is that the logic is not correct for looping though the list and assigning Test_ID as a global variable and also assigning the value to it.
I need all variable names to be assigned as globals with separate names even if they do not hold a value. Then I need the value assigned to each.
Another issue that I have is that the value and name will contain characters such as “[”, “,” and " " ". This is from how sensetalk is building the list.
NOTE- Running the run_python.sh script at the beginning eventually creates the test_variables.txt file.