Understanding VisualNEO Win FileWrite Command: Unexpected Results with Append Option

VisualNeo Win Help > Action Command Reference > FileWrite says:

‘By default, FileWrite will convert any pipe characters “|” contained within the text into carriage returns/line breaks. To prevent this, add an exclamation point character “!” to the beginning of the data parameter (…).’

After having some unexpected results using FileWrite last week, I decided to investigate the FileWrite command.

FileWrite "[PubDir]test_#124_all.txt" "All" "a|b|c"

Output:
a
b
c

Three lines separated by CarriageReturn+LineFeed ([#13][#10]). This confirms the reference text.

FileWrite "[PubDir]test_#124_app.txt" "Append" "a|b|c"

Output:
a|b|c

In contrast to what the reference text suggests, there is no conversion of “|” to CarriageReturn+LineFeed ([#13][#10]) if the option “Append” instead of “All” is used.

Let’s investigate the reverse situation: ‘|’ replaced by [#13][#10]:

FileWrite "[PubDir]test_#13#10_all.txt" "All" "a[#13][#10]b[#13][#10]c"

Output:
a
b
c

Three lines separated by CarriageReturn+LineFeed ([#13][#10]), as could be expected.

FileWrite "[PubDir]test_#13#10_app.txt" "Append" "a[#13][#10]b[#13][#10]c"

Output:
a|b|c

Surprise! To fix this, use the magical exclamation point character:

FileWrite "[PubDir]test_excl_#13#10_app.txt" "Append" "!a[#13][#10]b[#13][#10]c"

Output:
a
b
c

Three lines separated by CarriageReturn+LineFeed ([#13][#10]).

Conclusion:
FileWrite with the option “Append” does not behave as expected, when the command uses strings containing the pipe character ‘|’ or control characters ‘[#13][#10]’. You may consider always the exclamation point character ! when using FileWrite.

Thanks for reading.