Old 16th February 2003, 20:50   #1
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
Extending $0 - $9 and $R0 - $R9

I have simply run out of all the $x and $Rx functions in my script, and am wondering if you can make up new ones that can be used in StrCpy, ReadINIstr etc

I know you can...
!define TEMP1 "$0"
StrCmp ${TEMP1} $0 "" +2
...but that uses up $0

-Stuart
Afrow UK is offline   Reply With Quote
Old 16th February 2003, 21:26   #2
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
Defining TEMP1 as $0 is nothing more but telling the compiler to replace every ${TEMP1} it sees with $0, it doesn't create a new variable.

The best way to clear up some variables for usage is to push them to the stack and when you are finished with them pop them back. For example:

PHP Code:
Push $0
Push 
$1
# use $1 and $0 here...
Pop $1
Pop 
$0
# $0 and $1 are same as before the push now 
Another way you might want to try is to read data from INI files or the registry only when you need it and not to keep it ready from the beginning. This also applies to section selections (use SectionGetFlags instead of setting a variable to 1 when the section executes).

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 16th February 2003, 22:25   #3
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
Thanks

I'll have a look into where I can push and pop them around!
Here is the script...

http://myweb.tiscali.co.uk/afrowuk/map-compiler.nsi


-Stuart
Afrow UK is offline   Reply With Quote
Old 17th February 2003, 01:27   #4
rainwater
Senior Member
 
Join Date: Aug 2000
Posts: 397
Send a message via ICQ to rainwater
Well, for functions, its always best to Push all the variables on the stack that you are going to use. Then when the function is over, pop them back in (making sure you use the right order). Then you will still have every variable available outside of the function since that function takes care of any previous variables that were used.
rainwater is offline   Reply With Quote
Old 21st March 2003, 22:58   #5
treaz
Member
 
Join Date: Jan 2003
Posts: 78
Question

Hi,

I guess I am a little slow at this pushing and popping idea.

Can someone explain a little more on when to use PUSH and when to use POP?

Do I Pop or Push a variable when I wish to know the value of that variable?

Thanks.
treaz is offline   Reply With Quote
Old 22nd March 2003, 11:20   #6
Joost Verburg
NSIS MUI Dev
 
Join Date: Nov 2001
Posts: 3,717
Push adds a value to the stack, Pop removes one and sets the variable.

For example, the value of $0 is 123.

Now you are going to call the function bla:
code:
Function bla

Push $0 ;123 added to the stack

...the function can use $0...

Pop $0 ;Remove 123 from the stack and set $0 back to 123

FunctionEnd


After calling the funtion, the variables contain the same value as before.


Note the order when using multiple variables (last-in first-out):

code:
Function bla

Push $0
Push $1

...code...

Pop $1
Pop $0

FunctionEnd

Joost Verburg is offline   Reply With Quote
Old 22nd March 2003, 14:38   #7
Joel
Debian user
(Forum King)
 
Joel's Avatar
 
Join Date: Jan 2003
Location: Arch land
Posts: 4,917
And how can we, for example, since $9 is for the Startmenu, use it once and then "empty" the value so startmenu use it.
In my case I use $9 for my name in the script; but I copy the value:
code:

StrCpy $9 "${MUI_PRODUCT}"


So the startmenu recognize.


* PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux-i686 with MATE.
* Laptop: Intel Core 2 DUO T6600 @ 2.20 GHz with 4 GB RAM: Archlinux-x86-64 with MATE.
Joel is offline   Reply With Quote
Old 23rd March 2003, 11:23   #8
Joost Verburg
NSIS MUI Dev
 
Join Date: Nov 2001
Posts: 3,717
The first option is to define MUI_STARTMENUPAGE_VARIABLE with another variable ($8 for example), so another variable will be used.

If you have to use all 20 variables, you can also Push/Pop it if you want to use the variable temporary.

code:
Push ${MUI_STARTMENUPAGE_VARIABLE}
...code...
Pop ${MUI_STARTMENUPAGE_VARIABLE}


Why are you using a variable for the name? The name is always the same, so you can use a define.
Joost Verburg is offline   Reply With Quote
Old 23rd March 2003, 15:02   #9
Joel
Debian user
(Forum King)
 
Joel's Avatar
 
Join Date: Jan 2003
Location: Arch land
Posts: 4,917
code:

!define MyName "Dude"



I already have done that
But checking my script, I forgot that
I'm using the System plugin to detect RAM and "stole" $9.
Yeah! I'll "Pop it"


* PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux-i686 with MATE.
* Laptop: Intel Core 2 DUO T6600 @ 2.20 GHz with 4 GB RAM: Archlinux-x86-64 with MATE.
Joel is offline   Reply With Quote
Old 22nd April 2003, 04:42   #10
mlm
Junior Member
 
Join Date: Apr 2003
Posts: 8
Clearing the stack...

Is there a way to clear the stack and start over?

mlm(aka digitalda)
mlm is offline   Reply With Quote
Old 22nd April 2003, 10:41   #11
virtlink
Major Dude
 
virtlink's Avatar
 
Join Date: Sep 2002
Location: At [4C69:6E6B]
Posts: 561
Here is an article about the stack: http://nsis.sourceforge.net/archive/...52&instances=0.

Try this code (may contain errors, couldn't test it) to clear the stack:
PHP Code:
LoopAgain:
Pop $R9
IfErrors Done LoopAgain
Done

This will use the $R9 variable.

"I'll quote you when you say something memorable."
- Claudia Pelsmaeker
virtlink 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