Hello Shane,
I am a newby. Can you advise me where to located the Lib in my system?
I put the folder in my /Library/scripts folder, but the sample scripts arenāt able to access the Lib.
Thanks for any help.
Hello Shane,
I am a newby. Can you advise me where to located the Lib in my system?
I put the folder in my /Library/scripts folder, but the sample scripts arenāt able to access the Lib.
Thanks for any help.
Open your ~/Library folder. If you have never used script libraries before, you will need to crate a new folder called Script Libraries in it. Put the file Myriad Tables Lib.scptd inside the Script Libraries folder.
Thanks Shane, that worked.
Shane, this is totally awesome!
Thank you so very, very much for sharing this script library. I donāt know why you donāt sell stuff like this. I would easily pay $10 (or more). At least you should have a ācontributionsā web page.
I have been looking for over a year for a way to have more complex dialogs in AppleScript, particularly one with a drag/drop feature. There are so many things that you have enabled with your script library.
And not only did you give us a great script lib, you provided an outstanding scripting dictionary, and examples. Wow!!!
You have my undying gratitude.
Best Regards,
JMichaelTX
Iām glad you like it. Iāve been wanting something similar for a long time myself, so Iām pleased with how it worked out. Tables are complex, but they can also serve a range of purposes.
Iām open to donations, but Iād prefer people buy a copy of my book or app ā that way they get something extra they hopefully find useful.
Thanks again Shane.
To add a little, and get some feedback, here is a simple example I have modified to show how to process the results of the table dialog. Very easy, really. I found it easy to understand and modify Shaneās code.
Iām sure my code is far from optimized, so if anyone has suggestions for improvement, donāt hesitate to post.
use AppleScript version "2.4"
use scripting additions
use script "Myriad Tables Lib"
set theHeads to {"First Name", "Last Name", "Index", "Police", "Score", "Some Date"}
set theDate to current date
set someData to {{"Saga", "NorĆĀ©n", 1, true, 12.0, theDate}, Ā¬
{"Rasmus", "Larsson", 2, true, 13.5, missing value}, Ā¬
{"Freddie", "Holst", 3, false, 9.0, theDate + 40000}, Ā¬
{"Claes", "Sandberg", 4, false, 1.23456789E+4, theDate + 50000}, Ā¬
{"John", "Lundqvist", 5, true, 13.4567, theDate + 30000}, Ā¬
{"Annika", "Melander", 6, false, 22.0, theDate + 60000}}
-- typical process: make it with "table dialog with data", modify if required, then display
set myTable to Ā¬
make new table with data someData Ā¬
with title "Sample table" column headings theHeads Ā¬
with prompt Ā¬
"You can drag/drop, select multiple rows. Everything is editable. Uses a row template" editable columns {} Ā¬
row template {"", "", 1, true, 1.0, current date, missing value} Ā¬
with multiple selections allowed, row numbering and empty selection allowed
modify table myTable Ā¬
highlighted rows {2, 4} grid style grid both dashed between rows Ā¬
OK button name "Cool"
modify table myTable with row dragging -- CHG: dragging
set theResult to display table myTable with extended results -- CHG: ext res
--- PROCESS THE RESULTS IN THE ORDER SET BY USER ---
set rowOrder to order of rows of theResult
log rowOrder
set numRows to count of someData
log numRows
set AppleScript's text item delimiters to {" | "}
repeat with iRow from 1 to numRows
set rowNum to item iRow of rowOrder
log ("[" & rowNum & "]: " & (item rowNum of someData))
end repeat
The log looks like this:
(*6, 1, 4, 3, 2, 5*)
(*6*)
(*[6]: Annika | Melander | 6 | false | 22.0 | Sun, Feb 14, 2016 at 3:29 PM*)
(*[1]: Saga | NorĆĀ©n | 1 | true | 12.0 | Sat, Feb 13, 2016 at 10:49 PM*)
(*[4]: Claes | Sandberg | 4 | false | 1.23456789E+4 | Sun, Feb 14, 2016 at 12:42 PM*)
(*[3]: Freddie | Holst | 3 | false | 9.0 | Sun, Feb 14, 2016 at 9:56 AM*)
(*[2]: Rasmus | Larsson | 2 | true | 13.5 | missing value*)
(*[5]: John | Lundqvist | 5 | true | 13.4567 | Sun, Feb 14, 2016 at 7:09 AM*)
Which properties of the result you use depends a lot on what youāre using the table for. For instance, if everything is editable, as it is in your example, you probably want the values returned property. If youāre using it to have a user just reorder things, order of rows will be what matters to you. If youāre putting up information for the user to check and correct, you might find altered rows is quicker than comparing before and after. Because tables perform different roles, the results need to be flexible.
Excellent point. I wasnāt trying to suggest that my code was the only way to process the results. It is clearly just one way ā a very simple example.
Maybe others will post how they have used the results in other ways.
One question while Iām here: I know you are not a big fan of JXA, but I have some JXA scripts that I would like to use Myriad Tables with. Is there any reason your script lib wonāt work with JXA?
Have you tried it?
FWIW, the script is just a small amount of ASObjC code acting as a wrapper around an Objective-C framework ā the framework does all the actual work.
Yep. Getting this error:
Script Error
Error on line 45: Error: Script error.And in the Result panel:
Result:
Error -1753: Script error.
Any ideas/suggestions?
One Note: Where you had āmissing dataā in AppleScript, I used ānullā in JavaScript.
Is this correct?
I also tried an empty string āā, but got same results.
Actually JavaScript
'use strict';
var app = Application.currentApplication()
app.includeStandardAdditions = true
var myLib = Library('JMichael.Lib.JXA')
var MTLib = Library('Myriad Tables Lib')
myLib.helloJS("Called by JXA script") // works fine
var theHeads = ["First Name", "Last Name", "Index", "Police", "Score", "Some Date"]
var theDate = new Date()
var someData = [
["Saga", "NorĆĀ©n", 1, true, 12.0, theDate],
["Rasmus", "Larsson", 2, true, 13.5, null],
["Freddie", "Holst", 3, false, 9.0, (theDate + 40000)],
["Claes", "Sandberg", 4, false, 1.23456789E+4, theDate + 50000],
["John", "Lundqvist", 5, true, 13.4567, theDate + 30000],
["Annika", "Melander", 6, false, 22.0, theDate + 60000]
];
console.log(someData)
/*
--- AppleScript Code ---
set myTable to Ā¬
make new table with data someData Ā¬
with title "Sample table" column headings theHeads Ā¬
with prompt Ā¬
"You can drag/drop, select multiple rows. Everything is editable. Uses a row template" editable columns {} Ā¬
row template {"", "", 1, true, 1.0, current date, missing value} Ā¬
with multiple selections allowed, row numbering and empty selection allowed
*/
var myEditCol = []
var myRowTemplate = ["", "", 1, true, 1.0, theDate, null]
//*** NEXT LINE GIVES ERROR ***
// Script Error
// Error on line 45: Error: Script error.
var myTable = MTLib.makeNewTableWithData(someData,
{withTitle: "Sample table",
columnHeadings: theHeads,
withPrompt: "You can drag/drop, select multiple rows. Everything is editable. Uses a row template",
editableColumns: myEditCol,
rowTemplate: myRowTemplate,
multipleSelectionsAllowed: true,
rowNumbering: true,
emptySelectionAllowed: true
}
);
REPLIES PANEL:
app = Application("Script Editor")
app.displayAlert("From My JXA Lib: Called by JXA script")
--> {"buttonReturned":"OK"}
/* Saga,NorĆĀ©n,1,true,12,Sun Feb 14 2016 20:31:23 GMT-0600 (CST),Rasmus,Larsson,2,true,13.5,,Freddie,Holst,3,false,9,Sun Feb 14 2016 20:31:23 GMT-0600 (CST)40000,Claes,Sandberg,4,false,12345.6789,Sun Feb 14 2016 20:31:23 GMT-0600 (CST)50000,John,Lundqvist,5,true,13.4567,Sun Feb 14 2016 20:31:23 GMT-0600 (CST)30000,Annika,Melander,6,false,22,Sun Feb 14 2016 20:31:23 GMT-0600 (CST)60000 */
app = Application("Script Editor")
app.alloc([])
--> Error -1708: Message not understood.
Result:
Error -1753: Script error.
I suspect youāre out of luck. The ātableā returned is an AppleScript script object wrapping a pointer, and it looks like js canāt deal with that.
I suspect youāre out of luck. The ātableā returned is an AppleScript script object wrapping a pointer, and it looks like js canāt deal with that.
Thanks for the info. Not what I wanted to hear, but at least I can quit butting my head against a brick wall.
How to we report this issue to Apple? Surely they intend for AppleScript and JXA to support the same objects.
Surely they intend for AppleScript and JXA to support the same objects.
Not in this sort of case. There are probably workarounds, but to be honest, I donāt think theyāre worth my while.
FYI, version 1.0.1 is now available. Fixes an issue where boolean values would sometimes be returned as 0 or 1 rather than true or false.
FYI, version 1.0.6 is now available. Changes are:
Ability to show cells containing more than one line;
Ability to hide the Cancel button;
Improved handling of threading issues with accessory views;
Ability to specify monospaced digits (10.11 and later only);
Ability to have negative numbers appear in red;
Ability to have column(s) appear in bold;
Japanese localization.
You can download it here:
Version 1.0.7 of Myriad Tables Lib is now available from:
www.macosxautomation.com/applescript/apps/Script_Libs.html
Introduces the ādouble click means OK parameterā to the āmake new table with dataā and ādisplay table with dataā commands.
The āmodify tableā command has a new āinitial positionā parameter.
The ātable replyā and āextended table replyā records include a new āfinal positionā value.
FYI, Iāve just released version 1.0.8. It fixes a problem that occurs in scripts run from the Scripts menu in some versions of Script Debugger.
Version 1.0.9 of Myriad Tables Lib is now available here:
https://www.macosxautomation.com/applescript/apps/Script_Libs.html
This version fixes issues in Dark Mode when running in macOS 10.14. It also adds the ability to have a text column displayed securely with letters appearing as bullet characters, and German localization has been added.
Dear all
a quick question:
I might have miss this, but I couldnāt find a ābuilt-inā method for sorting the table (based on a specific column) prior display to the user ā¦
I this possible?
It seems to me the the āsorting data columnā should do this, but I couldnāt make to work.
Thanks
I might have missed this, but I couldnāt find a ābuilt-inā method for sorting the table (based on a specific column) prior display to the user ā¦
You didnāt miss it: preparing the initial data is left to the user.