Concatenate problems

Trying to get the appendfile to put each result on its own line in the text file. I have tried many iterations of concatenation, but can’t seem to get it right. The text file is generated, but the output is all on one line:

if {exists "C:\Temp\X-Fixlet-Source_Count.txt"}
   delete "C:\Temp\X-Fixlet-Source_Count.txt"
endif
if {number of relevant fixlets whose (value of header "X-Fixlet-Source" of it contains "Update") of site whose (name of it is "SITE1") > 0} 
   appendfile {unique values of values of headers "Subject" of relevant fixlets whose (value of header "X-Fixlet-Source" of it contains "Update") of site whose (name of it is "SITE1")}   
endif
if {number of relevant fixlets whose (value of header "X-Fixlet-Source" of it contains "Update") of site whose (name of it is "SITE2") > 0} 
   appendfile {unique values of values of headers "Subject" of relevant fixlets whose (value of header "X-Fixlet-Source" of it contains "Update") of site whose (name of it is "SITE2")}
endif
move __appendfile C:\Temp\X-Fixlet-Source_Count.txt
if {number of relevant fixlets whose (value of header "X-Fixlet-Source" of it contains "Update") of site whose (name of it is "SITE1") = 0} AND {number of relevant fixlets whose (value of header "X-Fixlet-Source" of it contains "Update") of site whose (name of it is "SITE2") = 0}
   delete "C:\Temp\X-Fixlet-Source_Count.txt"
endif

That’s an interesting use-case. This kind of need usually comes up when we’re building a script file to run in a batch or bash or powershell, but it’s the same kind of issue.

Basically, you have to embed the newline markers yourself, using string concatenation. For DOS/Windows files, an end-of-line is marked with two bytes CR and LF, which in ASCII are hexadecimal 0d and 0a. On UNIX files, it’s a single character ‘newline’ which is 0a. In Relevance we can use percent-encoding to represent these bytes in a string, as “%0d%0a” or “%0a” respectively.

Most text editors in Windows these days also recognize 0a as a newline, but that can vary.

To build such a concatenation you could use

appendfile {concatenation "%0d%0a" of unique values of values of headers "Subject" of relevant fixlets whose (value of header "X-Fixlet-Source" of it contains "Update") of site whose (name of it is "SITE1") }
1 Like

in appendfile %0d%0a is the carriage return/line feed that will get you a new line (in linux I think it is just %0a)

Try:

appendfile {concatenation "%0d%0a" of unique values of values of headers “Subject” of relevant fixlets whose (value of header “X-Fixlet-Source” of it contains “Update”) of site whose (name of it is “SITE1”)}

LOL Jason! - Jinx - You owe me a soda!

1 Like

Bingo…that was it and I was so close already. I was missing a quote :frowning:

Been staring at code for too long today! Thanks to you both for clearing out the cobwebs!

1 Like