Why is it that when the stack_test
function is called by ${GetDrives}
the stack doesn't retain "Hello", but when using Call stack_test
, "Hello" is there on the stack?
I expect to see this:
$0 = Hello
$0 = Hello
but instead I see this:
$0 = Goodbye
$0 = Hello
Here's the test case I'm using:
!include FileFunc.nsh
Name stack_test
OutFile stack_test.exe
ShowInstDetails show
Page instfiles
Function stack_test
Push "Hello"
FunctionEnd
Section section1
Push "Goodbye"
${GetDrives} "HDD" stack_test
Pop $0
DetailPrint "$$0 = $0"
Push "Goodbye"
Call stack_test
Pop $0
DetailPrint "$$0 = $0"
SectionEnd
GetDrives requires the callback function to push something to the stack and will pop after your callback returns. If you push "StopGetDrives" then the drive enumeration is aborted, otherwise it continues if there are more drives.
You should not expect your stack changes to survive if they are in a callback function like this and the number of pushes depends on how many drives the end-user has in this case...