• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: range of integers?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: range of integers?


  • Subject: Re: range of integers?
  • From: Shane Stanley <email@hidden>
  • Date: Fri, 31 Mar 2017 14:40:05 +1100

On 31 Mar 2017, at 2:06 pm, Christopher Stone <email@hidden> wrote:

 I'm not sure about AppleScriptObjC.

No. You can make what's called an index set easily:

set theIndexSet to current application's NSIndexSet's indexSetWithIndexesInRange:{1, 1000}

But there's no built-in way to convert that to an array, and hence coerce to an AS list. You can do it with BridgePlus, although that's just getting more long-winded, and slower for lists less than tens of thousands of items long:

use AppleScript version "2.4" -- Yosemite (10.10) or later
use framework "Foundation"
use theLib : script "BridgePlus" version "1.3.2"
use scripting additions

load framework
set theIndexSet to current application's NSIndexSet's indexSetWithIndexesInRange:{1, 1000}
set theList to (current application's SMSForder's arrayWithIndexSet:theIndexSet) as list

You could also do this, I suppose, although it probably no quicker:

use AppleScript version "2.4" -- Yosemite (10.10) or later
use framework "Foundation"
use theLib : script "BridgePlus" version "1.3.2"
use scripting additions

load framework
set theList to ((current application's SMSForder's arrayWithPattern:"%@" startNumber:1 endNumber:1000 minDigits:0)'s valueForKey:"integerValue") as list

OTOH, there are some (probably rare) cases where you can use an index set directly, and that might be faster (or not).

-- 
Shane Stanley <email@hidden>
<www.macosxautomation.com/applescript/apps/>, <latenightsw.com>


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: range of integers?
      • From: Phil Stokes <email@hidden>
References: 
 >range of integers? (From: Mitchell L Model <email@hidden>)
 >Re: range of integers? (From: Christopher Stone <email@hidden>)

  • Prev by Date: Re: Sierra 10.12.4 and JavaScript by AppleEvents in Safari
  • Next by Date: Re: Sierra 10.12.4 and JavaScript by AppleEvents in Safari
  • Previous by thread: Re: range of integers?
  • Next by thread: Re: range of integers?
  • Index(es):
    • Date
    • Thread