Talk:Path Manipulation: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
No edit summary
(question)
Line 56: Line 56:
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)
:You're correct. It seems the last two Pop commands are mixed. $0 should be popped first. The best test is setting $0-$9 with 0-9 (StrCpy $0 $$0, StrCpy $1 $$1, etc.) and checking them after the function returns. That test indeed shows they are mixed. Thanks, fixed. --[[User:Kichik|kichik]] 14:03, 30 June 2006 (PDT)
:You're correct. It seems the last two Pop commands are mixed. $0 should be popped first. The best test is setting $0-$9 with 0-9 (StrCpy $0 $$0, StrCpy $1 $$1, etc.) and checking them after the function returns. That test indeed shows they are mixed. Thanks, fixed. --[[User:Kichik|kichik]] 14:03, 30 June 2006 (PDT)
* why AddToPath is not calling AddToVarEnv, if they are equvalent?

Revision as of 11:45, 19 December 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)

You're correct. It seems the last two Pop commands are mixed. $0 should be popped first. The best test is setting $0-$9 with 0-9 (StrCpy $0 $$0, StrCpy $1 $$1, etc.) and checking them after the function returns. That test indeed shows they are mixed. Thanks, fixed. --kichik 14:03, 30 June 2006 (PDT)
  • why AddToPath is not calling AddToVarEnv, if they are equvalent?