You are here

GIMP: ReplaceInFile

2 posts / 0 new
Last post
Patrick Patience
Offline
Last seen: 4 years 4 months ago
DeveloperModerator
Joined: 2007-02-20 19:26
GIMP: ReplaceInFile

I don't know if it's like this for all the PortableApps.com Apps, but this is what i found in part of the GIMP ReplaceInFile file.

IfFileExists $2 +1 RIF_error ; knock-knock
FileOpen $R0 $2 "r" ; open the door

GetTempFileName $R2 ; who's new?
FileOpen $R1 $R2 "w" ; the escape, please!

RIF_loop: ; round'n'round we go
FileRead $R0 $R3 ; read one line
IfErrors RIF_leaveloop ; enough is enough
RIF_sar: ; sar - search and replace
Push "$R3" ; (hair)stack
Push "$1" ; needle
Push "$0" ; blood
Call StrReplace ; do the bartwalk
StrCpy $R4 "$R3" ; remember previous state
Pop $R3 ; gimme s.th. back in return!
StrCmp "$R3" "$R4" +1 RIF_sar ; loop, might change again!
FileWrite $R1 "$R3" ; save the newbie
Goto RIF_loop ; gimme more

RIF_leaveloop: ; over'n'out, Sir!
FileClose $R1 ; S'rry, Ma'am - clos'n now
FileClose $R0 ; me 2

Delete "$2.old" ; go away, Sire
Rename "$2" "$2.old" ; step aside, Ma'am
Rename "$R2" "$2" ; hi, baby!

ClearErrors ; now i AM a newborn
Goto RIF_out ; out'n'away

RIF_error: ; ups - s.th. went wrong...
SetErrors ; ...so cry, boy!

RIF_out: ; your wardrobe?

Haha, what?

Ryan McCue
Ryan McCue's picture
Offline
Last seen: 14 years 6 months ago
Joined: 2006-01-06 21:27
It's by someone else

It's a function available from the NSIS site somewhere, can't remember exactly what it's called.
----
Ryan McCue
Cube Games
Don't Live to Geek, Geek to Live
Lifehacker

"If you're not part of the solution, you're part of the precipitate."

Log in or register to post comments