Archive: Reading ini string error - Strange error


Reading ini string error - Strange error
Hi all,
I am trying to read a particular value from the ini file.

a.ini (contents).
-----
data = c:\test

I got the following code from the nsis website and try to compiled it. It is compiling fine. But when it runs it gives error "Installer corrupted Invalid OpCode".

I want the value of key "data" into some variable which I can use it in my nsis script? Can anybody help me in this regard?

Regards
Pradeep

Code:
----


OutFile "test_ini.exe"
;${ReadINIStrNS} $R0 "D:\Build\Builds\Code\test.ini" "data"
Section "OgO Open File Association" SEC02
Push $0
Call ReadINIStrNS
;Pop $0
;${ReadINIStrNS} $0 "D:\Build\Builds\Code\test.ini" "data"
SectionEnd


Function ReadINIStrNS
Exch $R0 ; key
Exch
Exch $R1 ; ini file
Push $R2 ; ini file handle
Push $R3 ; key len
Push $R4
Push $R5

FileOpen $R2 $R1 r
IfErrors End

StrLen $R3 $R0
IntOp $R3 $R3 + 1 ; inc. "="

LoopRead:
ClearErrors
IfErrors End
FileRead $R2 $R1

StrCpy $R4 $R1 $R3
StrCmp $R4 "$R0=" 0 LoopRead

StrLen $R5 $R1
IntOp $R3 $R5 - $R3
StrCpy $R0 $R1 "" -$R3

Push $R0
; Call TrimNewLines
Pop $R0

Goto +2

End:
StrCpy $R0 "no value!"

FileClose $R2

Pop $R5
Pop $R4
Pop $R3
Pop $R2
Pop $R1
Exch $R0 ; output value
FunctionEnd

;!define ReadINIStrNS "!insertmacro ReadINIStrNS"
;!macro ReadINIStrNS Var File Key
; Push "${File}"
; Push "${Key}"
; Call ReadINIStrNS
; Pop "${Var}"
;!macroend


You need to pop the function's result off the stack, otherwise you're corrupting your stack.


Iam tried the following:
Section "OgO Open File Association" SEC02
Push $0
Call ReadINIStrNS
Pop $0

It still gives the "Installer Corruption Error". Could you please help me where I am doing wrong? I am basically want to get the value of key "data" in the ini file.

I tried the following as mentioned in the following example:

URL submitted by user.

Error:

Processing script file: "C:\reading_ini_file_3.nsi"
OutFile: "test_ini.exe"
Section: "OgO Open File Association" ->(SEC02)
Push: $0
Pop: $0
Invalid command: ${ReadINIStrNS}
Error in script "C:\reading_ini_file_3.nsi" on line 7 -- aborting creation process

Could you please help me in this regard?

Regards
Pradeep