mIRC Home    About    Download    Register    News    Help

Print Thread
Keep first word of variables #252287 01/04/15 04:49 PM
Joined: Apr 2015
Posts: 8
F
FRAG_B Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
F
Joined: Apr 2015
Posts: 8
Hi, I'm writing a script in mIRC and I'd like to create a list of variables based on an existing list of variables. The new variables would only contain the first word of the original variables and I want this to be done automatically.

If these are my original variables for example:

var %a1 = firstword1 secondword1
var %a2 = firstword2 secondword2 thirdword2
var %a3 = firstword3 secondword3

etc.

Then I want my new variables to be for example:

var %b1 = firstword1
var %b2 = firstword2
var %b3 = firstword3

etc.

I'm looking for a way to 'convert' the original variables so only the first word remains, and then repeat that process for each of the original variables with a while loop. Something like this:

var %i = 1
while (%a [ $+ [ %i ] ] != $null) {
var %b [ $+ [ %i ] ] = ???????
inc %i
}

Note that the words in the original variables can have different lenghts (unlike the example) and the amount of words in it isn't always the same, so using $left(%a [ $+ [ %i ] ],<amount of characters>) to remove a certain amount of characters wouldn't be a solution.

Apologies if this was already asked or explained somewhere. I always search the internet for my issues and usually find solutions, but this time couldn't find anything.

Last edited by FRAG_B; 01/04/15 04:51 PM.
Re: Keep first word of variables [Re: FRAG_B] #252288 01/04/15 05:11 PM
Joined: Sep 2014
Posts: 259
S
Sakana Offline
Fjord artisan
Offline
Fjord artisan
S
Joined: Sep 2014
Posts: 259
You're looking for

$gettok(%variable,1,32)


The rest looks correct

Re: Keep first word of variables [Re: FRAG_B] #252289 01/04/15 05:12 PM
Joined: Apr 2015
Posts: 8
F
FRAG_B Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
F
Joined: Apr 2015
Posts: 8
Nevermind, I found that it's simply with $gettok(%a [ $+ [ %n ] ],1,32) (which is new to me).

Edit: Thanks Santana, I figured it out about the exact same time you replied. Thanks for helping.

Last edited by FRAG_B; 01/04/15 05:13 PM.