SimplyMaya Forums

Welcome to the forum, feel free to ask questions here.

Home / forum / Animation / Mel Scripts & Programming / add substrings to an array
Register FAQ Members List Calendar Mark Forums Read

New Thread
 
Thread Tools
Old 06-02-2006, 07:13 AM   #1
jpdefkt
Registered User
 
Join Date: Feb 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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
jpdefkt is offline   Reply With Quote
Old 06-02-2006, 05:23 PM   #2
Alan
Moderator
 
Alan's Avatar
 
Join Date: Oct 2002
Location: London, UK
Posts: 2,800
Thanks: 0
Thanked 5 Times in 5 Posts
Default

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");
}


A
__________________
Technical Director - Framestore

Currently working on: Your Highness

IMDB
Alan is offline   Reply With Quote
New Thread

« Previous Thread | Next Thread »

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off

1 Month

$34

Month-to-month billing
$34/month
Unlimited access to all videos
Project files to download
Easy to cancel at anytime
 
 

3 months

$87

Billing every 3 months
$29/month
Unlimited access to all videos
Project files to download
Easy to cancel at anytime
Save $5 per month or $15 in total compared to monthly billing with this package.

12 months

$288

Billing every 12 months
$24/month
Unlimited access to all videos
Project files to download
Easy to cancel at anytime
Save $10 per month or $120 in total compared to monthly billing with this package.

Your plan will automatically renew. You can cancel at any time via your PayPal account to avoid being charged again.

You can view the FAQ on our video plans here. You can contact us directly here. By clicking one of the buttons above, you agree to our Terms and Privacy Policy.