Simply Maya User Community

Simply Maya User Community (https://simplymaya.com/forum/index.php)
-   Programming (https://simplymaya.com/forum/forumdisplay.php?f=32)
-   -   add substrings to an array (https://simplymaya.com/forum/showthread.php?t=20144)

jpdefkt 06-02-2006 08:13 AM

add substrings to an array
 
hi folks,

i have a string of numbers which i want seperated so that every figure has its own place in an array. i tried it this way, but i couldn't get it working:

Quote:

proc dothis()

{
print ("barcode" + "\n");
global string $barcode;

$barcode _= `textField -query -text barcode1`;

for ($i=1; $i<=(size($barcode)); $i++) {

$barpiece =`substring $barcode $i $i`;
global string $barc[];
string $barc[$i] = {$barpiece};

}

}
at least i think it should work like this, but well, being a newbie... :unsure:
anyway the error i get is:
Quote:

// Error: _string $barc[$i] = {$barpiece}; //
// Error: Syntax error //
i hope you can help me with this issue.
thanks in advance!

greetings
joh

Alan 06-02-2006 06:23 PM

use the tokenize command:


string $buffer[];
string $myNumbs = "1 2 3 4 5 6 7 8 9 10";

tokenize $myNumbs " " $buffer;

for($numb in $buffer)
{
print("numb: -->" + $numb +"<--\n");
}

:ninja:
A


All times are GMT. The time now is 08:01 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Simply Maya 2018