mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Apr 2003
Posts: 414
Fjord artisan
OP Offline
Fjord artisan
Joined: Apr 2003
Posts: 414
Both unset after script end .. Any other difference ?


mIRC Chm Help 6.16.0.3 Full Anchored!
Joined: May 2003
Posts: 730
S
Hoopy frood
Offline
Hoopy frood
S
Joined: May 2003
Posts: 730
yes, set -u0 %var (which will replace the GLOBAL variable (if there is) of %var) will added to the 'variables' section and then removed
var %var will not touch the variables section becuz it's just a local variable and it's not stored in the variable section, it's stored in other place and removed after the script ends

Last edited by ScatMan; 03/06/03 11:54 AM.
Joined: Apr 2003
Posts: 414
Fjord artisan
OP Offline
Fjord artisan
Joined: Apr 2003
Posts: 414
Huh .. Thanks .. Don't know that ..


mIRC Chm Help 6.16.0.3 Full Anchored!
Joined: Dec 2002
Posts: 2,809
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 2,809
Also (depending on how mIRC does it) /var has the potential to be faster. /set -u0 %var is more characters than /var %var, since mIRC parses the script on demand, that means there would be less stuff to parse with /var therefore it should be slightly (nanoseconds) faster.

Joined: Dec 2002
Posts: 774
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Dec 2002
Posts: 774
alias set {
echo -a /set $1-
set $1-
}

alias vartest {
var %thing something
}

so /var actually calls /set -l $1-...


Code:
//if ( khaled isgod ) echo yes | else echo no
Joined: Dec 2002
Posts: 2,809
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 2,809
But that is handled in C++ code which should be faster than mIRC scripting in all cases.

Joined: Feb 2003
Posts: 2,812
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,812
Local vars are always faster than global vars. set -u0 writes it to an INI file and then deletes it shortly after, /var likely keeps a reference in memory only. There are also other technical differences, such as set -u0 %var being useful if the variable is going to be used across multiple aliases in the same event, before the event dies, but you have to be weary about using a variable naming convention to reduce chances of conflict. a /var never leaves the scope of that specific alias, and you never have to worry about using variable names like %i.

- Raccoon
PS. ALWAYS use '=' in /var, NEVER use '=' in /set.
/var %var [color:blue]= DATA
/set %myscript.var DATA[/color]


Well. At least I won lunch.
Good philosophy, see good in bad, I like!
Joined: Dec 2002
Posts: 1,922
O
Hoopy frood
Offline
Hoopy frood
O
Joined: Dec 2002
Posts: 1,922
I don't think it has to do with the ini files. Variables are stored in the memory as long as mirc runs, and are saved into an ini file when the user exits. Writing into or accessing variables is even faster than using a hash table.

Joined: Jan 2003
Posts: 3,012
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
I have to disagree Online. If you open mirc, type /set %a 1, and look in the variables section %a is present (it wrote it, but mirc hasn't exited). Although you second comment as to which is faster with variable or hash, I'd have to write a script to test it, but I can almost bet that hash are faster.


-KingTomato
Joined: Apr 2003
Posts: 426
Fjord artisan
Offline
Fjord artisan
Joined: Apr 2003
Posts: 426
Quote:

Local Variables
Local variables are variables that exist only for the duration of the script in which they are created and can only be accessed from within that script. They can be created with the /var command:

/var %x

This creates the local variable %x in the current routine and can only be referenced from inside this routine.

/var %x = hello

This creates a local variable %x and assigns it the value hello.

You can create multiple local variables by separating them with commas:

/var %x = hello, %y, %z = $me

loop {
var %x = 1
:next
echo item %x
inc %x
if (%x < 10) goto next
}

Note: You can use /var -s to make a variable show the result when a value is set.

/help Variables


A global variable is accessable to any script currently loaded within a mIRC script.




Local variables (var %var) are normally used when you don't want to set a variable, and only need it for temporary data storage, such as in a while loop.


Global variables (set %var) are used when you want more than one script to access that variable. They are also stored (in remotes.ini) if the /unset or -u or -z switches aren't used.


--------
mIRC - fun for all the family (except grandma and grandpa)
Joined: Apr 2003
Posts: 414
Fjord artisan
OP Offline
Fjord artisan
Joined: Apr 2003
Posts: 414
Thanks guy's smile Now i know what is the difference ..


mIRC Chm Help 6.16.0.3 Full Anchored!

Link Copied to Clipboard