Archive: edit text-file?


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.


; $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


using this myself


big thanx, yathosho!!
that's exactly what i was searching for.
also thanx to u, jansemanden :)


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


Use SetDetailsPrint to control where and if log text is shown.


i'm sorry, i think, it's not possible.


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.

hmm, btw, is it possible to ONLY show lines set with "DetailPrint" OR normal lines created by NSIS ??