Talk:Path Manipulation: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
No edit summary
No edit summary
Line 50: Line 50:
       -- The problem should be clear now --
       -- The problem should be clear now --


Pop $1      Stack: 0 1  
Pop $1      Stack: 1  
Pop $0      Stack 1
Pop $0      Stack: -empty-
</highlight-nsis>
</highlight-nsis>


Let me know if I'm mistaken.. if not, the wiki should be edited (I'd do it now, but I want to be sure I didn't goof up, first)
Let me know if I'm mistaken.. if not, the wiki should be edited (I'd do it now, but I want to be sure I didn't goof up, first)

Revision as of 15:35, 23 June 2006

Hi,

Here is a problem I fought with a long time.

The directory you want to add to path must exist before you call AddToPath. If it doesn't exists the path environment variable doesn't change, and you get no error message.

/Pontus Bergendahl




The stack manipulation in this article should be checked... I've always found it confusing to deal with, so I usually end up adding a lot of comments that keep track of the stack.

For the AddToEnvVar function, I end up with this:

      -- Beginning of function.  A and B are the ValueToAdd and EnvVarNames respectively --
             Stack: A B
 
Exch $1      Stack: 1 B
Exch         Stack: B 1
Exch $0      Stack: 0 1
Push $2      Stack: 2 0 1
Push $3      Stack: 3 2 0 1
Push $4      Stack: 4 3 2 0 1
 
      -- Put haystack (C) and needle (D) on stack --
Push "$2;"   Stack: C 4 3 2 0 1
Push "$1;"   Stack: D C 4 3 2 0 1
      -- StrStr is called, pops top two, pushes result (E) --
             Stack: E 4 3 2 0 1
Pop $3       Stack: 4 3 2 0 1
 
      -- Put haystack (C) and needle (D) on stack --
Push "$2;"   Stack: C 4 3 2 0 1
Push "$1\;"  Stack: D C 4 3 2 0 1
      -- StrStr is called, pops top two, pushes result (E) --
             Stack: E 4 3 2 0 1
Pop $3       Stack: 4 3 2 0 1
 
      -- IsNT is called, pushes result (F) --
             Stack: F 4 3 2 0 1
 
Pop $2       Stack: 4 3 2 0 1
Pop $4       Stack: 3 2 0 1
Pop $3       Stack: 2 0 1
Pop $2       Stack: 0 1
 
      -- The problem should be clear now --
 
Pop $1       Stack: 1 
Pop $0       Stack: -empty-

Let me know if I'm mistaken.. if not, the wiki should be edited (I'd do it now, but I want to be sure I didn't goof up, first)