mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Nov 2009
Posts: 17
A
AD1C Offline OP
Pikka bird
OP Offline
Pikka bird
A
Joined: Nov 2009
Posts: 17
I found this code in the script I'm modifying (see at end). Yes, I realize it could be re-written using regular expression parsing, but I digress. Because %commapos is local to this alias, I was thinking of changing this line:

set %commapos $pos(%bingocheckline,$chr(44))
to
var %commapos $pos(%bingocheckline,$chr(44))

But later on, %commapos is reassigned:

set %commapos $pos(%bingocheckline,$chr(44),2)

Do I change "set" to "var" here as well?


alias whatever {
set %commapos $pos(%bingocheckline,$chr(44))
dec %commapos
set %bingocounty1 $left(%bingocheckline,%commapos)
%commapos = $calc(%commapos * -1)
dec %commapos
dec %commapos
set %bingostate1 $right(%bingocheckline,%commapos)
set %bingostate1 $left(%bingostate1,2)
set %commapos $pos(%bingocheckline,$chr(44),2)
dec %commapos
set %bingocounty2 $left(%bingocheckline,%commapos)
%commapos = $calc(%commapos * -1)
dec %commapos
dec %commapos
set %bingostate2 $right(%bingocheckline,%commapos)
set %bingostate2 $left(%bingostate2,2)
set %strokepos $pos(%bingocheckline,$chr(47))
%strokepos = $calc(%strokepos * -1)
set %bingocounty2 $right(%bingocounty2,%strokepos)


Jim Reisert
http://www.ad1c.us/
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
If you want the variable to be local, then you need to change every location to use /var instead of /set.

That could definitely be improved if you felt like it. For example, combining your /dec lines into one (/dec %variable 2).


Invision Support
#Invision on irc.irchighway.net
Joined: Jul 2007
Posts: 1,129
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
Riamus2, I'm fairly certain you already know this. A quick fix to make all the variables local is to add the -l switch after the command
Code:
/set -l %var
. The switch is undocumented in the help file but works just the same as /var.

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Yes, but the question was referring to whether or not you had to change all references to the variable to local. Whether you do this with -l or /var, it still needs to be done. smile


Invision Support
#Invision on irc.irchighway.net

Link Copied to Clipboard