Archive: Function Replace Text help......


Function Replace Text help......
i have spent like 5 hours now trying to figure this out
but to no avail

I need to Replace text at line number BLAH

and i found afrows function to work but there was a problem
i don't need to add extra lines and such i need to replace exactly where it is
so what do i need to change in this script ?

Function WriteToFileLine
Exch $0 ;file
Exch
Exch $1 ;line number
Exch 2
Exch $2 ;string to write
Exch 2
Push $3
Push $4
Push $5
Push $6
Push $7

GetTempFileName $7
FileOpen $4 $0 r
FileOpen $5 $7 w
StrCpy $3 0

Loop:
ClearErrors
FileRead $4 $6
IfErrors Exit
IntOp $3 $3 + 1
StrCmp $3 $1 0 +3
FileWrite $5 "$2$\r$\n$6"
Goto Loop
FileWrite $5 $6
Goto Loop
Exit:

FileClose $5
FileClose $4

SetDetailsPrint none
Delete $0
Rename $7 $0
SetDetailsPrint both

Pop $7
Pop $6
Pop $5
Pop $4
Pop $3
Pop $2
Pop $1
Pop $0
FunctionEnd
:hang: I have tried differn't things with the text
but have come across whiping the file out or doing wierd things to it :(


afrow has a function for this in the archive


yes that is the function from the archive
but it moves down the text being replaced by a line
it shifts a line.

I don't know this language as well as i would like to

but it's somthing in the funtion that's not replacing
the text where it is at and instead is putting the text there.


tried removing the the $\r$\n$6 part ? didn't take a look at the entire function, but that was my first intension.


thanx it worked

but this is wht really worked and returned then line below it to normal

FileWrite $5 "$2$\r$\n"

That was like a needle in haystack for me after coding for 9 hours straight.
ty:D


Is there a Forward to back slash convertor

like say you have
<Directory "C:\Program Files\PrositeXL/www/phpwebsite_en/">
and need to go through the entire file
to replace throught the entire file
rather then reading the file writing to it over and over again
But to read the file and write to it every where it finds the \ making it go /

I have tried 5 differn't Functions actually written
to do just this action but have not found a 1 to work yet
Does anyone have a Function they know that works or a link
to some code that actually works and does this ?

I notice that several scripts don't work but at 1 time they might have ?

that's kind of wierd


Is there a script out there that replaces
text based on the text type found on that line ?
I'm hoping I won't have to code this from scratch:igor:


search for ReplaceInFile on the archive


here is what i'm having to do because the source code in the
Archive does not work except sme examples concerning this

Push "<Directory $\"$INSTDIR/www/phpwebsite_en/$\">" ;replace with
Push 1118 ;line to replace on
Push "$INSTDIR\Apache\conf\httpd.conf" ;file to replace in
Call WriteToFileLine

Push "\" ;text in line to replace
Push "/" ;replace with
Push 1118 ;line to replace on
Push "$INSTDIR\Apache\conf\httpd.conf" ;file to replace in
Call ReplaceOnLine

Push "" ;text in line to replace
Push "" ;replace with
Push 1118 ;line to replace on
Push "$INSTDIR\Apache\conf\httpd.conf" ;file to replace in
Call ReplaceOnLine

I have to do this 28 times 3 and that is causing me to
Open and close the same file 84 Times........

Belive me you can actually watch the installer
change every section with the human eyeball 84 times looks
like 45 times this go's on for about 9 seconds
watching \ go to / then it finishes real fast

Here is why this is happening to me
the first code replaces the inline
then the \ to / pushes a correct 1 Down a line

then the 3rd thing Deletes the top line allowing the 2n line
to become the first......

To me that's real crappy programming.

to me i'm already busting 2018 lines as it is right now
that section is taking up a good couple hundred
just to get what i want :( done that could be done in 1
line replacing on the line and at the edn of all the replacing have it sarch and replace a number of those instances. thus shortening up the time execution of the whole thing :)

any ideas ?
want to see the code ? mabey you could show me a better way ?

Well i can show the file right now because it's only 25% done there are still like 45 more sections i need to add
and 8 other programs to install bigger then the rest

:igor: