Go easy on me on this one...... I am using a string variable to keep track of outcomes in a rule with multiple Ifs.
I want to clear the string at the start of the rule and then add characters to it at each successive if. Then record the string to the log.
This should be trivial but for some reason I can't see to clear the string easily. The only way I could get it to work was to write an arbitrary string (dog) to the variable and then remove that same string in the next instruction. I tried setting string to '' and "" and ' ' and " " but these didn't clear the string as I would have expected. I also can't use the set variable and leave the field blank as you can't exit the set command without putting something in the field.
Maybe I didn't have enough coffee this morning. I am sure I must be doing something stupid but I've tried many different schemes... Ideas?
There has to be a better way of doing whatever it is you are doing with that String variable.
The appears to be something that should to be stored in an array. Do other rules or apps consume the result of your string, so you need global access? You can probably get AI to write you a data store driver that stores this data in an array in an attribute, with commands to add and remove items to the array. It would not be a hard driver to write from scratch either, if you know how to write simple drivers.
You may not even need an array if you can title each data item. You can have a data store driver that has an attribute for every value you are storing in that string, and then a simple set command to set them. You can then just pull the attribute value directly from the data driver when you need it, as a custom attribute in RM.
If you are staying with string storage, it would also make more sense to use a JSON string, if you really want to store multiple data items in a single string. It would much easier to parse the data back out of it.
Using Webcore could also simplify this, as the data can be stored in a single piston array variable, where everything that needs to work on that data is in the same piston.
Edit: Here is simple data store device. It wouldn't be hard to modify it to meet you data storage needs, with the proper names and such for attributes. Create more attributes as needed, and add the names of those to the constraints on the command lines.
Just wondering why I can't reset a string variable to empty with a simple one line command. The rest of my rule works fine. I am only puzzled by the inability initialize the variable to an empty string each time the rule actions run. I would have thought set variable to "" would do it but alas no.
So my solution is simply set the variable to a known string (blank) then remove that string. Seems unnecessarily complicated but it works. The single quotes and double quote methods didn't work. I can initialize a number variable to any number with a single line in a rule, don't know why I can't do something similar with a string.
Initializing with a number is initializing with an actual value as opposed to no value. You are actually doing the same thing when you are initializing a string with "dog" or "blank" or even a single letter.
Revisiting the OP, you could also simply assign the initial value "Here is the log: " to the string variable in Step 1, then append from there. Done. Reset. Finito.