Previous Index Next

BridgePlus.framework, SMSForder Class Methods

Category

List manipulation methods

Method

subarraysIn:withItems:insertedAtIndex:error:

Summary

Assumes the array is a list of lists. The insertion list must have the same number of elements, and the first element will be inserted into the main list's first list, the second into the main list's second list, and so on. Where it is inserted is determined by the (zero-based) 'insertedAtIndex' parameter.

Signature

+ (NSArray *)subarraysIn:(NSArray *)listOrArray withItems:(NSArray *)insertArray insertedAtIndex:(NSInteger)atIndex error:(NSError *__autoreleasing *)outError

Parameters

listOrArray = list or array

insertArray = list or array of items to insert

atIndex = zero-based index of where to insert

outError = missing value or reference

Result

An array of arrays

Availability

Version 1.0.0

Notes

If you set outError to reference, the result will be a list of two items. If there is no error, the first item will be the result of the method and the second will be missing value. If there is an error, the first item will be missing value and the second item with be an NSError.

Sample

use scripting additions

use framework "Foundation"

use script "BridgePlus"

load framework


set listOrArray to {{1.1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}}

set insertList to {"x", "y", "z"}

set theResult to current application's SMSForder's subarraysIn:listOrArray withItems:insertList insertedAtIndex:0 |error|:(missing value)

ASify from theResult

--> {{"x", 1.1, 2, 3, 4}, {"y", 5, 6, 7, 8}, {"z", 9, 10, 11, 12}}

theResult as list -- 10.11 only

--> {{"x", 1.1, 2, 3, 4}, {"y", 5, 6, 7, 8}, {"z", 9, 10, 11, 12}}

theResult as list -- 10.9 and 10.10

--> {{"x", 1.100000023842, 2, 3, 4}, {"y", 5, 6, 7, 8}, {"z", 9, 10, 11, 12}}


set theResult to current application's SMSForder's subarraysIn:listOrArray withItems:insertList insertedAtIndex:4 |error|:(missing value)

ASify from theResult

--> {{1.1, 2, 3, 4, "x"}, {5, 6, 7, 8, "y"}, {9, 10, 11, 12, "z"}}

theResult as list -- 10.11 only

--> {{1.1, 2, 3, 4, "x"}, {5, 6, 7, 8, "y"}, {9, 10, 11, 12, "z"}}

theResult as list -- 10.9 and 10.10

--> {{1.100000023842, 2, 3, 4, "x"}, {5, 6, 7, 8, "y"}, {9, 10, 11, 12, "z"}}


set {theResult, theError} to current application's SMSForder's subarraysIn:listOrArray withItems:insertList insertedAtIndex:5 |error|:(reference)

if theResult = missing value then error (theError's localizedDescription() as text)

--> error number -2700  Invalid index.


Click here to open script in a script editor