mIRC Home    About    Download    Register    News    Help

Topic Options
#234200 - 12/10/11 01:23 AM Re-assigning a var %variable
AD1C Offline
Pikka bird

Registered: 09/11/09
Posts: 17
Loc: Brighton, CO
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/

Top
#234203 - 12/10/11 03:14 AM Re: Re-assigning a var %variable [Re: AD1C]
Riamus2 Offline
Planetary brain

Registered: 13/10/04
Posts: 8327
Loc: MA, USA
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

Top
#234205 - 12/10/11 04:28 AM Re: Re-assigning a var %variable [Re: Riamus2]
Tomao Offline
Hoopy frood

Registered: 07/07/07
Posts: 1129
Loc: United States
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.

Top
#234207 - 12/10/11 11:12 AM Re: Re-assigning a var %variable [Re: Tomao]
Riamus2 Offline
Planetary brain

Registered: 13/10/04
Posts: 8327
Loc: MA, USA
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

Top