I'm now the maintainer for a bunch of dxl scripts, and I am in the process of testing them all.
The script in question formats multiple strings into a buffer, then converts back to a string. This string is then concatenated with another string, and then stored in an attribute. The code is below (variable names and number of function parameters have been sanitised FYI):
string formatForField(string s1, string s2){
Buffer buff = create();
buff += s1
buff += "\n";
buff += s2;
string formattedString = tempStringOf(buff);
delete(buff);
return formattedString;
}
void alterField(string inputString1, string inputString2){
string formattedChange = formatForField(inputString1, inputString2);
string oldValue = currentObject."Attribute Name";
if (oldValue != "") {
oldValue = oldValue "\n---\n";
}
string newValue = oldValue formattedChange;
currentObject."Attribute Name" = newValue;
}
The problem is that occasionally instead of the expected result, the current objects's value of "Attribute Name" has □ appended onto the previous value.
If for example, the value of (current object)."Attribute Name
is "Lorem Ipsum"
and after running the script, the expected value of (current object)."Attribute Name
is:
Lorem Ipsum
---
inputString1
inputString2
Then occasionally, the value of (current object)."Attribute Name
will actually be:
Lorem Ipsum
---
□
I've not been able to locate any similar reported issues online, so I'm posting here. I'm not sure what is happening here, as 99% of the time the script provides the expected output. Interestingly, if the attribute contains the white square after running the script, running the script again with the same input will result in the expected output...
Edit: This image shows the white square I am on about, as it doesn't seem to show up in the live post view
Extra Edit: Upon further inspection, I've found that sometimes additional random characters are included. The right column is supposed to contain text, not the random characters it does contain.
Realised the error. The buff was being deleted just after calling tempStringOf and so the memory being referenced was deallocated, causing the weirdness. Silly mistake on my part.