Old 30th November 2011, 08:43   #1
NOCaut
Senior Member
 
Join Date: Sep 2011
Posts: 106
macro params return garbage

correctly whether I put significance from the macro?

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

!macroend
NOCaut is offline   Reply With Quote
Old 30th November 2011, 10:37   #2
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,892
You're copying $0 into ${_Result}. You probably want to do it the other way around.
MSG is offline   Reply With Quote
Old 30th November 2011, 10:39   #3
NOCaut
Senior Member
 
Join Date: Sep 2011
Posts: 106
$0 -is my result. how i can get this param

PHP Code:
!insertmacro ConfigReadFrom "Filename" "prm" $R0
 messagebox MB_OK $R0 
// garbage 
NOCaut is offline   Reply With Quote
Old 30th November 2011, 10:46   #4
NOCaut
Senior Member
 
Join Date: Sep 2011
Posts: 106
PHP Code:
!macro ConfigReadFrom _FILE _ENTRY _RESULT 
!define _LPrefix L${__LINE__}    
    
StrCpy $""
    
StrCpy $""
    
StrCpy ${_RESULT""
    
StrCpy $${_FILE
    
StrCpy $${_ENTRY}     
    
ClearErrors
 
    FileOpen 
$$0 r
    IfErrors 
${_LPrefix}error
    StrLen 
$$1
    StrCmp 
$0 0 ${_LPrefix}error
 
    
${_LPrefix}readnext:
    
FileRead $$3
    IfErrors 
${_LPrefix}error
    StrCpy 
$$$0
    StrCmp 
$$1 0 ${_LPrefix}readnext
    StrCpy 
$$'' $0
    StrCpy 
$$0 1 -1
    StrCmp 
$'$\r' +2
    StrCmp 
$'$\n' ${_LPrefix}close
    StrCpy 
$$-1
    
goto -4
 
    
${_LPrefix}error:
    
SetErrors
    StrCpy 
$''
 
    
${_LPrefix}close:
    
FileClose $2     
    
    StrCpy 
${_RESULT} $0
    Pop 
${_RESULT}    
!
undef _LPrefix              
!macroend 
NOCaut is offline   Reply With Quote
Old 30th November 2011, 11:59   #5
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,892
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.
MSG is offline   Reply With Quote
Old 30th November 2011, 12:54   #6
NOCaut
Senior Member
 
Join Date: Sep 2011
Posts: 106
Thank work is good twice. when i call 3 not work. What is wrong?
PHP Code:
!macro ConfigReadFrom _FILE _ENTRY
!define _LPrefix L${__LINE__}   
Exch $0
...
Exch $0
!undef _LPrefix               
!macroend 
PHP Code:
!insertmacro ConfigReadFrom "Filename" "prm"
Pop $0
 messagebox MB_OK $R0 
// garbage 
NOCaut is offline   Reply With Quote
Old 30th November 2011, 13:17   #7
NOCaut
Senior Member
 
Join Date: Sep 2011
Posts: 106
i rewrite this code from function http://nsis.sourceforge.net/ConfigRead to macro
NOCaut is offline   Reply With Quote
Old 30th November 2011, 14:12   #8
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,892
Still wrong. If you want to back up the contents of $0, you should first push $0, and at the end pop $0.
MSG is offline   Reply With Quote
Old 30th November 2011, 14:34   #9
NOCaut
Senior Member
 
Join Date: Sep 2011
Posts: 106
ok i tray
NOCaut is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump