Author Topic: Setting A Variable To Multiple Things  (Read 755 times)

Is it possible to set a variable to multiple things? like setting $Awesome::Variable to "jes00", "Crown", and "JoJo"?

No. I don't understand how that would work and how it could be useful.

You can however make it a list of all 3 of those things and then when checking it, go through the list and compare each thing in the list to something.

$variable = "jes infiniteloop chrono";

for(%i=0;%i<getWordCount($variable);%i++)
{
   %word = getWord($variable,%i);
   
   echo(%word);
}

$varCount = -1;
$variable[$varCount++] = "jes";
$variable[$varCount++] = "infiniteloop";
$variable[$varCount++] = "chrono";

for(%i=0;%i<$varCount;%i++)
{
   echo($variable[%i]);
}

$variable = "jes infiniteloop chrono";

for(%i=0;%i<getWordCount($variable);%i++)
{
   %word = getWord($variable,%i);
   
   echo(%word);
}

$varCount = -1;
$variable[$varCount++] = "jes";
$variable[$varCount++] = "infiniteloop";
$variable[$varCount++] = "chrono";

for(%i=0;%i<$varCount;%i++)
{
   echo($variable[%i]);
}

So which would I use to check the variable?


Use a for loop to put values into a string, separated by either SPC or TAB (TAB is better for things like position or vectors). Then use %blah=getWord(SPC list,#) or %blah=getField(TAB list,#) to get those values back out of the string.

OR

Use arrays.