PDA

View Full Version : a basic mel question


underpatch
12-08-2010, 11:37 AM
i am starting the learning prosess and i could use a little help

string $all[]=`ls -sl`;
float $amount = size($all);
for ( $i = $amount-1; $i > -1; $i -- )
{
print ($all[$i]+" \n");
}

in the print command there is a error .... i just want to list the items that is in $all[] one at a time but it does not seem to like me pulling $i in there .... any advice ?

also is there some way i could get this to work ?

for ( $i = size($all)-1; $i > -1; $i -- )
{
}

because i would love to learn how to remove as many lines as posable early on ..


cheers :)

Kecal
12-08-2010, 02:59 PM
Hi,
error appear because of the arraySize definition as float. It has to be integer. It force $i to be also float and index of array has to be integer.

string $all[]=`ls -sl`; int $amount = size($all);
print $amount;
for ( $i = $amount -1; $i > -1; $i -- )
{
print ($all[$i]+" \n");
};


to simplify you have to use this:
for ( $i = `size($all)`-1; $i > -1; $i -- )
{
print ($all[$i]+" \n");
};

underpatch
12-08-2010, 03:36 PM
thank you :) having a play right now

CGTalk Moderation
12-08-2010, 03:36 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.