#498 Add 'ClearStack' command

2.0 Series
open
Amir Szekely
Scripting (152)
5
2010-09-30
2010-09-30
Netsurfer24
No

After working now for some weeks with NSIS I was wondering that there is no 'ClearStack' command.
As NSIS do not support arrays the stack is a handy thing to use e.g. when you have an unknown number of values. Therefor you have to clear the stack first which can be done by:
ClearErrors
${Do}
Pop $0
IfErrors ${Break}
${Loop}
But a single command would be more pleasent.

Thanks,

Gunther

Discussion

  • Anders
    Anders
    2010-10-03

    Even if there was a ClearStack command, it could only be used at the "root" of a script, utility functions etc could not use it since the callers stack would be messed up

     
  • Netsurfer24
    Netsurfer24
    2010-10-03

    @Anders
    >> ... it could only be used at the "root"
    of a script, utility functions etc could not use it since the callers stack
    would be messed up

    Of course you are right. But this is one of the problematic things about the stack. I still do very much believe that there are situations where you need an empty stack (see given example). And this means that one has to be sure that there are no needed values on the stack - use user variables instead.

    And in combination with my request #3078769 (https://sourceforge.net/tracker/?func=detail&aid=3078769&group_id=22049&atid=373088) such a command would still make sense in my opinion.

    In other words: As long as NSIS does neither support arrays nor local variables using the stack (starting with an empty stack) is the only suitable way. And therefor this command would be helpful.

    Gunther