[ANN] BridgePlus script library

BridgePlus is an AppleScript script library designed to improve and simplify the use of AppleScriptObjC.

At its most basic, it provides a simple yet more powerful way to bridge between Applescript and Cocoa. It also includes lots of other utility methods, based on the functionality of ASObjC Runner.app and ASObjCExtras.framework.

You can read about it and download it here: www.macosxautomation.com/applescript/apps/BridgePlus.html

FYI, version 1.1.1 is now available.


A new version of the BridgePlus scripting library is now available from www.macosxautomation.com/applescript/apps/BridgePlus.html, with many new methods added to its included BridgePlus framework.

Version 1.3.0 of the framework has new methods covering array sorting and splitting, folder enumeration, file moving and copying, UTI discovery, Spotlight searches, and keychain access.

The new version also includes more detailed documentation of the framework’s methods, including sample code, available here: www.macosxautomation.com/applescript/apps/BridgePlus_Manual/Index.html.

I’ve been using BridgePlus to manipulate two lists but am failing at the final hurdle.

use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
--use framework "AppKit"
use BP : script "BridgePlus"

on run
	global TEXTList, NUMList,oneList, twinList
	set TEXTList to {"a", "b", "c", "d", "e"}
	set NUMList to {5, 4, 2, 1, 3}
	set twinList to {TEXTList, NUMList}
	set oneList to BP's colsToRowsIn:twinList
	set changedList to (BP's sublistsIn:oneList sortedByIndexes:{2, 1} ascending:{false} sortTypes:{"compare:"})
	set changedList to (BP's listByMergingTextAtIndexes:{1} inList:oneList inserting:" goes with --> ")
end run

I’m expecting the result to be: {“d goes with → 1”, “c goes with 2”, “e goes with 3”, etc}
but the final step regularly fails in SD with “Invalid merge indexes parameter; the list must contain only two integers.”
I have tried listByMergingTextAtIndexes:{}, {1}, {1,2}, {2,1} and even {10,20,30,40,50} to no avail.

The BridgePlus rtf instructs me to “Provide a list of the (one-based) indexes of the items to merge”
I am clueless as to the meaning of this instruction nor of the error either.

Could you clarify please and specify what values I should include in “listByMergingTextAtIndexes”?

The handler acts on a simple list of strings, not a list of lists. So:

set oneList to {"apples", "oranges", "lemons", "peaches"}
set toInsert to " and "
set changedList to (BP's listByMergingTextAtIndexes:{2, 3} inList:oneList inserting:toInsert)
--> {"apples", "oranges and lemons", "peaches"}

You appear to be trying to combine text and an integer, and I’m afraid BridgePlus is not going to be any help with that.

Thanks Shane
Now that I see how this handler works I’ll search for another solution.

One alternative would be to save this script (it doesn’t need the two demo handlers at the end) in your Script Libraries folder, say under the name “Custom Iterative Dual-pivot Quicksort.scpt”, and then use this:

use AppleScript version "2.3.1"
use scripting additions
use sorter : script "Custom Iterative Dual-pivot Quicksort"

on run
	set TEXTList to {"a", "b", "c", "d", "e"}
	set NUMList to {5, 4, 2, 1, 3}
	-- Sort items 1 thru -1 of NUMList, in place, rearranging TEXTList in parallel.
	tell sorter to sort(NUMList, 1, -1, {slave:{TEXTList}})
	set changedList to {}
	repeat with i from 1 to (count TEXTList)
		set end of changedList to (item i of TEXTList & " goes with --> " & item i of NUMList)
	end repeat
	return changedList
end run

Nigel, the underlying task was to order both lists and then do a pairwise comparison to find mismatches. The lists should have the same data, albeit from different sources, because they describe the same object.

In the end it turned out better to use a myriad table solution as its easier to eyeball and see why the mismatches have ocurred, especially where the differences confound a simple sort.
eg particle ≠ particulate → discernible in the sort since similar words
particle ≠ exogenous solids → virtully no chance of noticing

This doesn’t even remotely resemble the information you gave in post #4. While your query was specifically about a problem you were having with Bridge Plus, it would help people to help you if you didn’t give misleading information about what you were trying to do.

I disagree. My original question was specific to a particular handler and Shane clarified that for me quite nicely. Your response, while welcome, seemed to misconstrue what I was having problems with and as a consequence I felt I had to give a fuller explanation of what I’m trying to achieve. I’m sorry if that is vexing for you.