mIRC Home    About    Download    Register    News    Help

Print Thread
#142170 16/02/06 01:03 PM
Joined: Feb 2006
Posts: 22
B
BIGZIPZ Offline OP
Ameglian cow
OP Offline
Ameglian cow
B
Joined: Feb 2006
Posts: 22
Hi, probably a simple one but it has me stumped!

I have a var called %level

I am wondering how would I go about setting multiple strings in the var, so it would hold 1, and 2 and could be searched for example:

if (%user_level isin %level) /dosomething

I realise I could just manually write %level 1, 2, etc but I want some kind of command which will alow me to add a string to the end of the var.

Thanks!

#142171 16/02/06 01:07 PM
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
You'll have to use dynamic variable names or another form of data storage like a hashtable.

Vars:

/set %level.<level> <whatever>
/set %level.<another level> <whatever>

if ($eval($+(%,level.,<level>),2)) { do stuff }

Hashtables:

/hadd -m level <level> <whatever>
/hadd -m level <another level> <whatever>

if ($hget(level,<level>)) { do stuff }

#142172 16/02/06 01:14 PM
Joined: Feb 2006
Posts: 22
B
BIGZIPZ Offline OP
Ameglian cow
OP Offline
Ameglian cow
B
Joined: Feb 2006
Posts: 22
Thanks for your reply.

I actually figured it out a couple of years ago and now cannot remember how I did it, i do remember though i used an identifier of some kind and it really was alot simple to do than your way.

Thanks for the help

#142173 16/02/06 01:19 PM
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
Sorry I completely missed the point of your post first time I read it.

There are two ways you can add a string onto the end of a var, the first method will prevent duplicates, the second won't.

Method 1: set %var $addtok(%var,<new data>,32)
Method 2: set %var %var <new data>

Using method 1 the last parameter of $addtok is the ascii number of the separator you want to use, which in this case, is a space (32).

#142174 16/02/06 01:32 PM
Joined: Feb 2006
Posts: 22
B
BIGZIPZ Offline OP
Ameglian cow
OP Offline
Ameglian cow
B
Joined: Feb 2006
Posts: 22
thank you!

#142175 17/02/06 02:14 PM
Joined: Feb 2006
Posts: 22
B
BIGZIPZ Offline OP
Ameglian cow
OP Offline
Ameglian cow
B
Joined: Feb 2006
Posts: 22
Another question.... having added multiple string to a VAR using the simple command of /set %var %var [string] I have hit another roadblock... how does one remove an individual string from the same var without deleting the entire var itself?

Thanks

#142176 17/02/06 02:29 PM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Type /help token identifiers

and start reading. You'll find amongst others this identifier called $remtok which could be of interest to you. Code examples are provided in the help file.


Gone.

Link Copied to Clipboard