
Quote from engano on March 24, 2023, 10:35 amI 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, BBSo 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.
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.

Quote from emo on March 24, 2023, 1:35 pmHi @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"
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:


Quote from luishp on March 24, 2023, 7:54 pm@engano please take a look at this blog post:
https://visualneo.com/visualneo-win/understanding-visualneo-win-filewrite-command-unexpected-results-with-append-optionI'm sure you will find it interesting.
@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.

Quote from engano on March 25, 2023, 2:29 amThank 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.
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.