|
|
#1 |
|
Forum King
Join Date: Mar 2006
Location: Ath. GR
Posts: 2,078
|
FileWrite Question
Perhaps it is something obvious that I can't get it, though the forum search did not quite help me.
The question is this: While the FileRead successfully stores in the variable an empty line, the FileWrite assumes that the variable is empty so does not add the empty line to the new file. Examine the example below for details as it become complicated to explain it. If I don't execute TrimNewLines then the text reproduced correctly in the new text file, but no in the log window where I can see the symbols of return and new line. If I do execute TrimNewLines then the text displayed correctly in the log window (with empy lines where they exist) but the filewrite does not catch the empty line stored into the variable, so I have to add $\r$\n in order to reproduce the original text structure. Eh! code: Quick AVI Creator - Quick and easy convert from DVD/MPEG/AVI/MKV to AVI/MP4/MKV Quick AVI Creator entirely edited with NSIS and entirely upgraded to Unicode NSIS |
|
|
|
|
|
#2 |
|
Major Dude
|
well, you have a solution, so where's the problem?
hand by comm@nder21 ---------- WiKi pages:CreateInternetShortcut|Enhanced FindWindow|Parse CSV-Data|Open/Close CD-Drive|Installer without Icon|Vista application compatibility |
|
|
|
|
|
#3 |
|
Forum King
Join Date: Mar 2006
Location: Ath. GR
Posts: 2,078
|
I have a solution as you said, but, is this the right one?
I mean this is the way supposed to act FileWrite or am I missing something? And if this is the way, there is a why. Why FileWrite is not able to manage the empty line that is stored in $var from FileRead? :-) Quick AVI Creator - Quick and easy convert from DVD/MPEG/AVI/MKV to AVI/MP4/MKV Quick AVI Creator entirely edited with NSIS and entirely upgraded to Unicode NSIS |
|
|
|
|
|
#4 |
|
Major Dude
|
hmm, i'm wondering if i misunderstood something.
i changed your loop a bit and came with this, plz test: PHP Code:
hand by comm@nder21 ---------- WiKi pages:CreateInternetShortcut|Enhanced FindWindow|Parse CSV-Data|Open/Close CD-Drive|Installer without Icon|Vista application compatibility |
|
|
|
|
|
#5 |
|
Forum King
Join Date: Mar 2006
Location: Ath. GR
Posts: 2,078
|
It does exactly the same with my code.
Again the FileWrite does not handle the empty line stored in $1 from FileRead.:-) Quick AVI Creator - Quick and easy convert from DVD/MPEG/AVI/MKV to AVI/MP4/MKV Quick AVI Creator entirely edited with NSIS and entirely upgraded to Unicode NSIS |
|
|
|
|
|
#6 |
|
Forum King
Join Date: Mar 2006
Location: Ath. GR
Posts: 2,078
|
Someone plz?!
Someone to explain me why while we are in a loop the FileWrite assumes that the variable $1 has no string, when actually once the variable has not string the loop is terminated. This means that the FileRead detects the empty line as string and it stores it on variable $1, though, the FileWrite does not detect it. Quick AVI Creator - Quick and easy convert from DVD/MPEG/AVI/MKV to AVI/MP4/MKV Quick AVI Creator entirely edited with NSIS and entirely upgraded to Unicode NSIS |
|
|
|
|
|
#7 |
|
Major Dude
|
no, that code works fine for me.
the loop i posted above works by 100% fine for me, the file is copied 1:1, just the output in the install log window is crappy. therefore you'll need to use trimnewlines just for display the license text: PHP Code:
hand by comm@nder21 ---------- WiKi pages:CreateInternetShortcut|Enhanced FindWindow|Parse CSV-Data|Open/Close CD-Drive|Installer without Icon|Vista application compatibility |
|
|
|
|
|
#8 |
|
Forum King
Join Date: Mar 2006
Location: Ath. GR
Posts: 2,078
|
Mine too, works 100% just the output in the install log window is crappy.
If I use TrimNewLines the log window is perfect with the empty lines since FileRead detects these empty lines, though, FileWrite assumes that the variable has no string and therefore the LicenseCopy.txt does not reproduced 100% like the way it is reproduced in log window. In other words DetailPrint and FileWrite they share the same variable at the same time to print the stored string, but, they export different results. Quick AVI Creator - Quick and easy convert from DVD/MPEG/AVI/MKV to AVI/MP4/MKV Quick AVI Creator entirely edited with NSIS and entirely upgraded to Unicode NSIS |
|
|
|
|
|
#9 |
|
Major Dude
|
yes, detailprint and filewrite work different regarding line breaks.
but with the code i posted, it works with neither crappy output to the log window nor wrong license file output. hand by comm@nder21 ---------- WiKi pages:CreateInternetShortcut|Enhanced FindWindow|Parse CSV-Data|Open/Close CD-Drive|Installer without Icon|Vista application compatibility |
|
|
|
|
|
#10 |
|
Forum King
Join Date: Mar 2006
Location: Ath. GR
Posts: 2,078
|
Thanks for the feedback :-)
Well, this is what I'm talking about since I opened this thread. Why FileWrite has different behaviour. I know it's easy to add TrimNewLines either by your way or by my way (examine the script on the top of the thread and uncomment those three lines). Just wanted to know if this happens for some particular reason. That's all. Again thanks a lot for your support :-) Quick AVI Creator - Quick and easy convert from DVD/MPEG/AVI/MKV to AVI/MP4/MKV Quick AVI Creator entirely edited with NSIS and entirely upgraded to Unicode NSIS |
|
|
|
|
|
#11 |
|
Major Dude
|
you're welcome
![]() i guess, if you want to understand why they work different, you should have a look at the source and find out, through which windows api calls the commands do their work. this should give us more information
hand by comm@nder21 ---------- WiKi pages:CreateInternetShortcut|Enhanced FindWindow|Parse CSV-Data|Open/Close CD-Drive|Installer without Icon|Vista application compatibility |
|
|
|
|
|
#12 | |
|
Forum King
Join Date: Mar 2006
Location: Ath. GR
Posts: 2,078
|
Quote:
Quick AVI Creator - Quick and easy convert from DVD/MPEG/AVI/MKV to AVI/MP4/MKV Quick AVI Creator entirely edited with NSIS and entirely upgraded to Unicode NSIS |
|
|
|
|
|
|
#13 |
|
M.I.A.
[NSIS Dev, Mod] Join Date: Oct 2001
Location: Israel
Posts: 11,337
|
The difference between DetailPrint and FileWrite is that FileWrite writes exactly what you tell it to. DetailPrint writes one line and adds a line break. If you give FileWrite an empty string, it'll write nothing at all. If you give it a string parsed by TrimNewLines, it won't write a line break and you'll get many lines concatenated.
NSIS FAQ | NSIS Home Page | Donate $ "I hear and I forget. I see and I remember. I do and I understand." -- Confucius |
|
|
|
|
|
#14 |
|
Forum King
Join Date: Mar 2006
Location: Ath. GR
Posts: 2,078
|
I think I got it. Allow me to explain it as I understand it.
In order to operate with accuracy, FileRead parses the empty string, so we're able to keep looping. Parses nothing when there is no string, so we're getting out of the loop. Contrariwise, when the empty string is parsed, FileWrite assumes that there is nothing to write, so if we want to reproduce the line break there is no need for TrimNewLines, otherwise, we do TrimNewLines and then manually add line break where and when it is necessary. Are these right? Thanks a lot! Quick AVI Creator - Quick and easy convert from DVD/MPEG/AVI/MKV to AVI/MP4/MKV Quick AVI Creator entirely edited with NSIS and entirely upgraded to Unicode NSIS |
|
|
|
|
|
#15 |
|
M.I.A.
[NSIS Dev, Mod] Join Date: Oct 2001
Location: Israel
Posts: 11,337
|
That's about right. Though I wouldn't say FileWrite parses anything. But that's just details.
NSIS FAQ | NSIS Home Page | Donate $ "I hear and I forget. I see and I remember. I do and I understand." -- Confucius |
|
|
|
![]() |
|
|||||||
| Thread Tools | Search this Thread |
| Display Modes | |
|
|