Archive: macro params return garbage


macro params return garbage
  correctly whether I put significance from the macro?

!macro ConfigReadFrom _FILE _ENTRY _RESULT
StrCpy ${_RESULT} $0
Pop ${_RESULT}
MessageBox MB_OK $0
MessageBox MB_OK ${_RESULT} // 8.0.2342..

!macroend

You're copying $0 into ${_Result}. You probably want to do it the other way around.


$0 -is my result. how i can get this param

!insertmacro ConfigReadFrom "Filename" "prm" $R0

messagebox MB_OK $R0 // garbage

!macro ConfigReadFrom _FILE _ENTRY _RESULT 

>!define _LPrefix L${__LINE__}
StrCpy $0 ""
StrCpy $1 ""
StrCpy ${_RESULT} ""
StrCpy $0 ${_FILE}
StrCpy $1 ${_ENTRY}
ClearErrors

FileOpen$2 $0 r
IfErrors${_LPrefix}error
StrLen$0 $1
StrCmp$0 0 ${_LPrefix}error

${_LPrefix}readnext:
FileRead $2 $3
IfErrors${_LPrefix}error
StrCpy$4 $3 $0
StrCmp$4 $1 0 ${_LPrefix}readnext
StrCpy$0 $3 '' $0
StrCpy$4 $0 1 -1
StrCmp$4 '$\r' +2
StrCmp$4 '$\n' 0 ${_LPrefix}close
StrCpy$0 $0 -1
goto-4

${_LPrefix}error:
SetErrors
StrCpy$0 ''

${_LPrefix}close:
FileClose $2

StrCpy${_RESULT} $0
Pop${_RESULT}
!undef _LPrefix
>!macroend
>

The problem lies in the pop command at the end. You're popping something off the stack, while nothing has been pushed onto the stack first! So you're popping data that belongs to some other function. So it's not very strange that it's garbage, don't you agree?

You should remove the pop command entirely.


Thank work is good twice. when i call 3 not work. What is wrong?


macro ConfigReadFrom _FILE _ENTRY

>!define _LPrefix L${__LINE__}
>Exch $0
>...
>Exch $0
>!undef _LPrefix
>!macroend
>

"Filename" "prm"

>Pop $0
messagebox MB_OK $R0 // garbage

i rewrite this code from function http://nsis.sourceforge.net/ConfigRead to macro


Still wrong. If you want to back up the contents of $0, you should first push $0, and at the end pop $0.


ok i tray