|
Joined: Aug 2003
Posts: 50
Babel fish
|
OP
Babel fish
Joined: Aug 2003
Posts: 50 |
I have this list:
[settings] Things=colorRed,colorBlue,colorBrown,nameTeddy,nameRosy,colorWhite,nameRod
How can I separate the color tokens from the name tokens, delteting the prefix parte (color) and put thenin a new token list or variable list?
|
|
|
|
Joined: Oct 2004
Posts: 8,330
Hoopy frood
|
Hoopy frood
Joined: Oct 2004
Posts: 8,330 |
alias convert {
var %settings = $readini(file.ini,Settings,Things)
var %counter = 1
while (%counter <= $gettok(%settings,0,44)) {
if (color* iswm $gettok(%settings,%counter,44)) {
var %colors = %colors $remove($gettok(%settings,%counter,44),color) $+ ,
}
if (name* iswm $gettok(%settings,%counter,44)) {
var %names = %names $remove($gettok(%settings,%counter,44),name) $+ ,
}
inc %counter
}
}
Just replace file.ini with the filename of where your settings are stored. Or just replace the entire $readini part with the data you have there. This will give you 2 variables to use as you want -- %colors and %names To use, just type /convert
Invision Support #Invision on irc.irchighway.net
|
|
|
|
Joined: Aug 2003
Posts: 50
Babel fish
|
OP
Babel fish
Joined: Aug 2003
Posts: 50 |
I tryed your script and it is perfetct thanks!
Last edited by Dylan666; 10/06/06 06:43 AM.
|
|
|
|
Joined: Aug 2003
Posts: 50
Babel fish
|
OP
Babel fish
Joined: Aug 2003
Posts: 50 |
Just a little more difficult:
[Settings] Categories=name,color,animal Things=colorRed,colorBlue,colorBrown,nameTeddy,nameRosy,colorWhite,nameRod,animalElephant,animalLion,nameMary,animalPenguin,colorBlack
How two divide the second list using the Categories tokens if I don't know their names (name, color, etc.)?
Well, I suppose I should use two "while" cycles, the first to try each Categories word and the second to extract the relative tokens from the Things list...
|
|
|
|
Joined: Oct 2004
Posts: 8,330
Hoopy frood
|
Hoopy frood
Joined: Oct 2004
Posts: 8,330 |
alias convert {
var %names = $readini(file.ini,Settings,Categories)
var %things = $readini(file.ini,Settings,Things)
var %name.cnt = 1
var %thing.cnt = 1
while (%name.cnt <= $gettok(%names,0,44)) {
var %name = $gettok(%names,%name.cnt,44)
while (%thing.cnt <= $gettok(%things,0,44)) {
if (%name $+ * iswm $gettok(%things,%thing.cnt,44)) {
var %data = %data $remove($gettok(%things,%thing.cnt,44),%name) $+ ,
}
inc %thing.cnt
if (%thing.cnt > $gettok(%names,0,44)) {
echo -a %name = %data
}
}
inc %name.cnt
}
}
That should separate your data the way you want and echo it. You'd just need to change the echo line to do whatever it is you want to actually happen (perhaps writeini or something).
Invision Support #Invision on irc.irchighway.net
|
|
|
|
|