Monday, October 22, 2018

#1 2015-05-18 06:52:00 pm

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

[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/ap … ePlus.html


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

Offline

 

#2 2015-05-31 06:37:16 pm

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

Re: [ANN] BridgePlus script library

FYI, version 1.1.1 is now available.

www.macosxautomation.com/applescript/ap … ePlus.html


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

Offline

 

#3 2015-11-24 05:52:52 pm

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

Re: [ANN] BridgePlus script library

A new version of the BridgePlus scripting library is now available from www.macosxautomation.com/applescript/ap … ePlus.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/ap … Index.html.


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

Offline

 

#4 2018-05-11 09:30:14 am

publiclee
Member
Registered: 2012-08-07
Posts: 4

Re: [ANN] BridgePlus script library

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

Applescript:

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"?

Last edited by publiclee (2018-05-11 09:32:34 am)

Offline

 

#5 2018-05-11 05:18:11 pm

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

Re: [ANN] BridgePlus script library

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

Applescript:

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.


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

Offline

 

#6 2018-05-12 09:53:02 am

publiclee
Member
Registered: 2012-08-07
Posts: 4

Re: [ANN] BridgePlus script library

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

Offline

 

#7 2018-05-12 01:14:55 pm

Nigel Garvey
Moderator
From:: Warwickshire, England
Registered: 2002-11-20
Posts: 4696

Re: [ANN] BridgePlus script library

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:


Applescript:

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


NG

Offline

 

#8 2018-05-12 11:19:38 pm

publiclee
Member
Registered: 2012-08-07
Posts: 4

Re: [ANN] BridgePlus script library

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

Offline

 

#9 2018-05-13 05:45:12 am

Nigel Garvey
Moderator
From:: Warwickshire, England
Registered: 2002-11-20
Posts: 4696

Re: [ANN] BridgePlus script library

publiclee wrote:

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.


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.


NG

Offline

 

#10 2018-05-13 09:01:25 am

publiclee
Member
Registered: 2012-08-07
Posts: 4

Re: [ANN] BridgePlus script library

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.

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)