|
|
#1 |
|
Junior Member
Join Date: Mar 2003
Posts: 6
|
Code is from Archive.What I need to do it to call this script from my main installer file to make changes in my 2 XML files.
This is code in my main installer file but it's not working,i am doing something wrong but can't figure out In WriteXML I get script,StringA,StringB value coorect but file.name and filnenew.xml comes as null.Please help. Code attached. What I need is that I should be able to send sourcefile name,destination file name,string to be replaced,new string from my main installer file to Writexml and get the final output in destination file name. Thank in advance push "StringA" push "StringB" push "file.xml" push "filenew.xml" ; Some code to adjust settings in XML file. ; ; By Hendri Adriaens. ; HendriAdriaens@hotmail.com !define TEMP1 $R0 ;Temp variable !define TEMP2 $R1 ;Temp variable !define TEMP3 $R2 ;Temp variable !define TEMP4 $R3 ;Temp variable ;outfile WriteXML.exe ;name WriteXML ; push sourcefile ; push destfile ; push search string ; push new string function ParseXML ;MessageBox MB_YESNO "This will modify studio.txt and put output to temp.tmp.$\r$\nContinue?" IdNo Quiting Exch $0 ;newString MessageBox MB_OK $0 Exch Exch $1 ;search string MessageBox MB_OK $1 Exch Exch $2 ;source file MessageBox MB_OK $2 Exch Exch $3 ;destfile MessageBox MB_OK $3 FileOpen $R0 "$3" "r" FileOpen $R1 "$4" "w" MessageBox MB_OK $R0 MessageBox MB_OK $R1 Loop: FileRead $R0 $R2 StrCmp $R2 "" ExitLoop push $R2 push $1 Call StrStrH Pop $R3 StrCmp $R3 $R2 NotFound FileWrite $R1 '$R3"$1" value="$2" />$\r$\n' GoTo Loop NotFound: FileWrite $R1 $R2 Goto Loop ExitLoop: FileClose $R0 FileClose $R1 Quiting: Quit functionend Function StrStrH ;Modified StrStr function from functions.htm Exch $1 Exch Exch $2 Push $3 Push $4 Push $5 StrLen $3 $1 StrCpy $4 0 loop: StrCpy $5 $2 $3 $4 StrCmp $5 $1 done StrCmp $5 "" done IntOp $4 $4 + 1 Goto loop done: StrCpy $1 $2 $4 Pop $5 Pop $4 Pop $3 Pop $2 Exch $1 FunctionEnd section sectionend |
|
|
|
|
|
#2 |
|
NSIS Dev
Join Date: Feb 2003
Location: Boston, MA, U.S.A.
Posts: 455
|
In the first place, you seem to be pushing your arguments in the wrong order.
The documentation for the script says: code: So you should push in that order. Secondly, the ParseXML function seems to be extracting the arguments incorrectly. It should be doing: code: Please correct me if I am wrong. |
|
|
|
|
|
#3 |
|
Junior Member
Join Date: Mar 2003
Posts: 6
|
I put that documentation in and I think stack is LAST IN FIRST OUT, correct me if I am wrong. That's what I assume and I get the valye for STRINGA and STRINGB correct in the function but just not the 2 files. It could be the extraction problem,I will look into it more.Anybody else ?
Thanks for your reply |
|
|
|
|
|
#4 |
|
Major Dude
Join Date: Sep 2002
Location: At [4C69:6E6B]
Posts: 561
|
I think that you should use Pop to get the value on the stack instead of Exch. Exch exchanges the top value on the stack with the value in the variable. Pop moves the value on the stack to the variable, so that the next value on the stack becomes the top value:
PHP Code:
code: Then, using Pop: PHP Code:
code: And the message box should show: filenew.xml Then pop again, and so on. I'm not sure about the order in which the items come on the stack and leave stack. But I think that Push puts the item on top of the stack, and Pop takes the top item of the stack. - Claudia Pelsmaeker |
|
|
|
|
|
#5 |
|
NSIS Dev
Join Date: Feb 2003
Location: Boston, MA, U.S.A.
Posts: 455
|
If Pop is used to get the values from the stack, you lose the current values in the registers- which could have bad consequences later.
Another problem I noticed with ParseXML is that it is not restoring the register values when it completes. |
|
|
|
|
|
#6 |
|
M.I.A.
[NSIS Dev, Mod] Join Date: Oct 2001
Location: Israel
Posts: 11,336
|
The stack operations in this function are wrong. Where did you take it from? I can't find it in the archive...
Please attach large scripts next time. 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 | |
|
|