Friday, November 16, 2018

#1 2018-09-04 07:07:05 am

technomorph
Member
Registered: 2017-12-14
Posts: 72

Getting Objects via a list of indexes created from BridgePlus

when using BridgePlus's
indexesOfItems:inArray:inverting:

Applescript:

use scripting additions
use framework "Foundation"
use script "BridgePlus"
load framework

set listOrArray to {1, 2, 3, 2, 4, 2, 5, 3}
set theItem to {2, 4}
set theResult to current application's SMSForder's indexesOfItems:theItem inArray:listOrArray inverting:false
ASify from theResult
-->    {1, 3, 4, 5}

how can I now use this result in reverse?

IE:

Applescript:


set theResult to anotherListOrArray's objectsAtIndex:{1,3,4,5}

i realize it's zero based so I've used the arrayByAddingInteger:inArray:
but still no go?

thanks

Offline

 

#2 2018-09-04 07:24:46 am

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 5470

Re: Getting Objects via a list of indexes created from BridgePlus

NSArray has an -objectsAtIndexes: method, which requires an NSIndexSet, and BridgePlus has an -indexSetWithArray: method to build one. So:

Applescript:

use scripting additions
use framework "Foundation"
use script "BridgePlus"
load framework

set theIndexSet to current application's SMSForder's indexSetWithArray:{1,3,4,5}
set theResult to anotherListOrArray's objectsAtIndexes:theIndexSet


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/
latenightsw.com

Offline

 

#3 2018-09-06 12:01:18 am

technomorph
Member
Registered: 2017-12-14
Posts: 72

Re: Getting Objects via a list of indexes created from BridgePlus

Perfect thanks and easy.

I thought that function was
To set up just a straight indexed array.

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)