Comm@nder21
20th January 2004 20:35 UTC
edit text-file?
i think, i've seen some code to edit only one line in a textfile containing multiple lines in an older topic.
sorry, couldn't find it yet.
could someone post the code here?
and i've recognized, that this function isn't posted in the archive. i think, someone should do that (if noone wants to, i'll do, but i need the code first :)).
thx.
Jansemanden
20th January 2004 22:00 UTC
; $3=filename
; $4=line to replace
; $5=new line
Function ChangeLine
ClearErrors
FileOpen $0 "$3" "r"
GetTempFileName $R0
FileOpen $1 $R0 "w"
loop:
FileRead $0 $2
IfErrors done
StrCmp $2 $4$\r$\n 0 +3
FileWrite $1 "$5$\r$\n"
Goto loop
StrCmp $2 $4 0 +3
FileWrite $1 "$5"
Goto loop
FileWrite $1 $2
Goto loop
done:
FileClose $0
FileClose $1
Delete "$3"
CopyFiles /SILENT $R0 "$3"
Delete $R0
FunctionEnd
Yathosho
21st January 2004 14:24 UTC
using this myself
Comm@nder21
21st January 2004 16:23 UTC
big thanx, yathosho!!
that's exactly what i was searching for.
also thanx to u, jansemanden :)
mip
9th February 2004 14:04 UTC
I wonder if it is possible to suppress the display of the renaming an deletion action inside the logging window during replacement of a string (I'm using ReplaceInFile macro from NSIS archive which is similar to the function posted above).
Does anyone know how to do? I'm using NSIS 2.0.
http://prao.mine.nu/tmp/nsis.gif
kichik
9th February 2004 14:09 UTC
Use SetDetailsPrint to control where and if log text is shown.
Comm@nder21
9th February 2004 14:10 UTC
i'm sorry, i think, it's not possible.
mip
9th February 2004 14:20 UTC
Originally posted by kichik
Use SetDetailsPrint to control where and if log text is shown.
Thank you very much for your quick reply. This instruction did it.
Comm@nder21
10th February 2004 18:06 UTC
hmm, btw, is it possible to ONLY show lines set with "DetailPrint" OR normal lines created by NSIS ??