Unable to write a file that contains the "|" symbol - Forum

Forum Navigation
You need to log in to create posts and topics.

Unable to write a file that contains the "|" symbol

I need to create a file with the content of a variable previously captured from a php file.
The php file contains the "|" symbol several times.
I haven't been able to write to a txt or php file that includes such symbol.
I have tried with several workarrounds but nothing:

To show the problem I created this example.
I have a txt file with 3 lines:
Line 1, AA
Line 2, ||
Line 3, BB

So I do,

FileToVar "!C:\demo\Text.txt" "[Content]"

then

FileWrite "!C:\demo\ResultText.txt" "All" "[Content]"

and then the result text has "lost" the "|" symbol.

Ive tried with definevar, filetovar, fileread, replacing with StrReplace "[Content]" "|" "![#124]", with "!" exclamations in many places...
I am sure there's a trick but OI don't find it.
Thank you for your help.

Uploaded files:
  • You need to login to have access to uploads.

Hi @engano

Try this:

.this works...
.FileRead "!C:\demo\Text.txt" "1" "[Line1]"
.FileRead "!C:\demo\Text.txt" "2" "[Line2]"
.FileRead "!C:\demo\Text.txt" "3" "[Line3]"
.FileWrite "!C:\demo\ResultText.txt" "1" "[Line1]"
.FileWrite "!C:\demo\ResultText.txt" "2" "[Line2]"
.FileWrite "!C:\demo\ResultText.txt" "3" "[Line3]"

. And if you don't know the number of lines..do a loop

.count lines of file
FileToVar "!C:\demo\Text.txt" "[Content]"
StrParse "[Content]" "[#13][#10]" "[Testvar]" "[TestCount]"

FileRead "!C:\demo\Text.txt" "[CurrentLine]" "[Line]"
SetVar "[CurrentLine]" "0"


While "[CurrentLine] " "<=" "[TestCount]"
    FileWrite "!C:\demo\ResultText.txt" "[CurrentLine]" "[Line]"
    SetVar "[CurrentLine]" "[CurrentLine]+1"
    FileRead "!C:\demo\Text.txt" "[CurrentLine]" "[Line]"

EndWhile

AlertBox "The end" "Finish"

 

Uploaded files:
  • You need to login to have access to uploads.

Thank you for the tip.
I will try and let you know.

Thank you.

@engano please take a look at this blog post:
https://visualneo.com/visualneo-win/understanding-visualneo-win-filewrite-command-unexpected-results-with-append-option

I'm sure you will find it interesting.

Thank you very much for your help and info.
I solved the issue using the line by line approach suggested by EMO.
I also used npUtil plugin because it has an action that locates the line number of a string (npLineNumber).

And thank you again Luis for all your effort and work developing VisualNeo Win and Web.