Last Item Of Array

well, I' am bigginer in mel and I have create an UI and in this UI the user get selction of joints but I dont know how many.

my question is : how I can get the last joint selected ?
Can I use a variable in array as:

string $test[] = ls -sl;
$size = size $test;
print $test[ $size ] ;

thinks a lot for your help

QUOTE(lutin @ 08/24/07, 01:58 AM) [snapback]272189[/snapback]
well, I' am bigginer in mel and I have create an UI and in this UI the user get selction of joints but I dont know how many.

my question is : how I can get the last joint selected ?
Can I use a variable in array as:

string $test[] = ls -sl;
$size = size $test;
print $test[ $size ] ;

thinks a lot for your help

it's -> print $test [$size - 1]; <- , because the indexing starts with 0 and not with 1 .

Except you don't need these extra lines the ls has a -tl short for -tail which you can use to limit the amount of selected to be listed form en of list. So the whole code boils down to:

string $test[] = ls -sl -tl 1;

its still a array but is guaranteed to either be 0 length or 1 length.

Anyway, this should teach you to read the mel command reference daily.