0

I want to get the user selection and assign all but the last object to one array variable and the last selected object to another variable.

how can I do this?

Thank you

SAF
  • 309
  • 2
  • 13
  • What code do you have so far? – Andy Wiesendanger Mar 25 '16 at 17:41
  • I had a working code but it wasn't that nice. so I am changing the first lines which are like this now string $sel[] = `ls -sl`; int $lastSel = size ($sel); stringArrayRemoveAtIndex(($lastSel - 1), $sel); string $targetSel[] = $sel; string $base = $lastSel; string $baseCopy[] = `duplicate $base`; – Orkhan Ashrafov Mar 25 '16 at 17:47
  • @Andy `string $wholeSel[] = `ls -sl`; string $targetList[] = `ls -sl -hd (size($iniSel1) - 1)`; string $base = $wholeSel[size($wholeSel) - 1];` I redid it like this and it works. But maybe there is a more elegant way? – Orkhan Ashrafov Mar 25 '16 at 21:36

1 Answers1

0
$first = `ls -sl -head 1`;
$last = `ls -sl -tail 1`;
string $all_except_last[] = stringArrayRemove(`ls -sl -tail 1`, `ls -sl -fl`);
string $all_except_first[] = stringArrayRemove(`ls -sl -head 1`, `ls -sl -fl`);
//don't forget to use -fl (flat list) flag
SAF
  • 309
  • 2
  • 13
  • thank you. what does the 'flat list' flag do? I didn't find it in the reference. also can we use $list[0] for the first item here? – Orkhan Ashrafov Mar 26 '16 at 09:20
  • Of course you can use $list[0]. Flat list more for components (pSphere1.f[255:258] vs pSphere1.f[255] pSphere1.f[256] pSphere1.f[257] pSphere1.f[258]). Flattens the returned list of objects so that each component is identified individually. – SAF Mar 26 '16 at 09:58