mIRC Home    About    Download    Register    News    Help

Print Thread
Any difference between set -u0 %Var and var %Var ? #27871 03/06/03 11:40 AM
Joined: Apr 2003
Posts: 414
Adrenalin Offline OP
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!
Re: Any difference between set -u0 %Var and var %Var ? #27872 03/06/03 11:53 AM
Joined: May 2003
Posts: 730
S
ScatMan Offline
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.
Re: Any difference between set -u0 %Var and var %V #27873 03/06/03 12:53 PM
Joined: Apr 2003
Posts: 414
Adrenalin Offline OP
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!
Re: Any difference between set -u0 %Var and var %V #27874 03/06/03 06:08 PM
Joined: Dec 2002
Posts: 2,809
C
codemastr Offline
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.

Re: Any difference between set -u0 %Var and var %V #27875 03/06/03 07:55 PM
Joined: Dec 2002
Posts: 774
T
theRat Offline
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
Re: Any difference between set -u0 %Var and var %V #27876 03/06/03 08:11 PM
Joined: Dec 2002
Posts: 2,809
C
codemastr Offline
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.

Re: Any difference between set -u0 %Var and var %Var ? #27877 03/06/03 11:10 PM
Joined: Feb 2003
Posts: 2,669
Raccoon Offline
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,669
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!
Re: Any difference between set -u0 %Var and var %Var ? #27878 03/06/03 11:21 PM
Joined: Dec 2002
Posts: 1,922
O
Online Offline
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.

Re: Any difference between set -u0 %Var and var %Var ? #27879 04/06/03 08:23 AM
Joined: Jan 2003
Posts: 3,012
KingTomato Offline
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
Re: Any difference between set -u0 %Var and var %Var ? #27880 04/06/03 09:08 AM
Joined: Apr 2003
Posts: 426
neophyte Offline
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)
Re: Any difference between set -u0 %Var and var %V #27881 04/06/03 12:29 PM
Joined: Apr 2003
Posts: 414
Adrenalin Offline OP
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!