Myriad Tables Questions

Script Editor does not support loading third-party frameworks, which is how Myriad Tables works. The solution is to write your scripts in Script Debugger.

1 Like

Thank you, Shane.

I now realise that you’ve had to type the same answer repeatedly to different questions addressing the same issue. So thank you for your tolerance in doing it again for a newbie!

2 Likes

It’s a lot easier to answer the same question than new ones :wink:

2 Likes

This is odd. The alignments in modify columns seem odd.

Align right and align center seem reversed.

In the script below the text in the column headings say how each heading/column should be aligned, but they don’t match how they are actually aligned. At least not for right and center.

I’m not sure how align natural works so I can’t say about that.

→ Mac OS Version 11.6.8 (20G730)
→ Script Debugger 8.0.5 (8A61)
→ Myriad Tables Lib 1.0.12

use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions

use script "Myriad Tables Lib" version "1.0.12"
set tableData to {}
set theNames to {"Harry", "Warren", "Glenn", "Zak", "Clint", "Clark", "Harry", "Warren", "Glenn", "Zak", "Clint", "Clark"}

repeat 5 times
	set thisRow to {}
	repeat 8 times
		set the end of thisRow to some item of theNames
	end repeat
	set the end of tableData to thisRow
end repeat

set columnHeadings to {"1-left, left", "2-right,right", "3-center, center", "4-natural, natural", "5-left,right", "6-right,Left", "7-right,center", "8-center,right"}
set columnWidth to 125
set newTable to ¬
	make new table with data tableData ¬
		column headings columnHeadings

modify columns in table newTable ¬
	columns list {1} ¬
	head alignment align left ¬
	entry alignment align left ¬
	column width columnWidth ¬
	
modify columns in table newTable ¬
	columns list {2} ¬
	head alignment align right ¬
	entry alignment align right ¬
	column width columnWidth ¬
	
modify columns in table newTable ¬
	columns list {3} ¬
	head alignment align center ¬
	entry alignment align center ¬
	column width columnWidth ¬
	
modify columns in table newTable ¬
	columns list {4} ¬
	head alignment align natural ¬
	entry alignment align natural ¬
	column width columnWidth ¬
	
modify columns in table newTable ¬
	columns list {5} ¬
	head alignment align left ¬
	entry alignment align right ¬
	column width columnWidth ¬
	
modify columns in table newTable ¬
	columns list {6} ¬
	head alignment align right ¬
	entry alignment align left ¬
	column width columnWidth ¬
	
modify columns in table newTable ¬
	columns list {7} ¬
	head alignment align right ¬
	entry alignment align center ¬
	column width columnWidth ¬
	
modify columns in table newTable ¬
	columns list {8} ¬
	head alignment align center ¬
	entry alignment align right ¬
	column width columnWidth ¬
	
set tableResult to display table newTable

Update: Added a couple columns to better illustrate the issue.

Oddly enough, I ran the script above from my desktop and it worked perfectly.

→ Script Debugger 8.0.6 (8A64)
→ MacOS 12.6.2
→ Myriad Tables 1.0.12

It depends on your version of macOS. Unfortunately Apple defined the values for the alignment enums differently in iOS and macOS, and they’ve more recently changed those used in macOS to match iOS. To keep the code shorter I used hard-coded integer values instead, which has turned out to be a bad idea.

I’ll have to do a fix. In the meantime, you can add code to check at runtime, and use different code accordingly, like this:

use AppleScript version "2.4" -- Yosemite (10.10) or later
use framework "Foundation"
use script "Myriad Tables Lib" version "1.0.12"
use scripting additions

if (current application's NSTextAlignmentRight = 2) then
	set rAlign to align center
	set cAlign to align right
else
	set cAlign to align center
	set rAlign to align right
end if

set tableData to {}
set theNames to {"Harry", "Warren", "Glenn", "Zak", "Clint", "Clark", "Harry", "Warren", "Glenn", "Zak", "Clint", "Clark"}

repeat 5 times
	set thisRow to {}
	repeat 8 times
		set the end of thisRow to some item of theNames
	end repeat
	set the end of tableData to thisRow
end repeat

set columnHeadings to {"1-left, left", "2-right,right", "3-center, center", "4-natural, natural", "5-left,right", "6-right,Left", "7-right,center", "8-center,right"}
set columnWidth to 125
set newTable to ¬
	make new table with data tableData ¬
		column headings columnHeadings

modify columns in table newTable ¬
	columns list {1} ¬
	head alignment align left ¬
	entry alignment align left ¬
	column width columnWidth ¬
	
modify columns in table newTable ¬
	columns list {2} ¬
	head alignment rAlign ¬
	entry alignment rAlign ¬
	column width columnWidth ¬
	
modify columns in table newTable ¬
	columns list {3} ¬
	head alignment cAlign ¬
	entry alignment cAlign ¬
	column width columnWidth ¬
	
modify columns in table newTable ¬
	columns list {4} ¬
	head alignment align natural ¬
	entry alignment align natural ¬
	column width columnWidth ¬
	
modify columns in table newTable ¬
	columns list {5} ¬
	head alignment align left ¬
	entry alignment rAlign ¬
	column width columnWidth ¬
	
modify columns in table newTable ¬
	columns list {6} ¬
	head alignment rAlign ¬
	entry alignment align left ¬
	column width columnWidth ¬
	
modify columns in table newTable ¬
	columns list {7} ¬
	head alignment rAlign ¬
	entry alignment cAlign ¬
	column width columnWidth ¬
	
modify columns in table newTable ¬
	columns list {8} ¬
	head alignment cAlign ¬
	entry alignment rAlign ¬
	column width columnWidth ¬
	
set tableResult to display table newTable

1 Like

Thanks, Shane!

I’ll try something like that. But that does not work with

head alignment rAlign

For some reason that stays centered.

But that’s also one of the least used in my tables, and where it is used I can add spaces or something.

Version 1.0.13, containing the fix, is now available for download.

1 Like

Hi @ShaneStanley

The link seems to be broken. Here is what I get:

Sorry, should be good now.

Installed, but I see no difference. (Recomiled and then relaunched). I installed the new version in “Shane’s Script Library Pack” and launched that, then recompiled and relaunched, still no difference.

→ Mac OS Version 11.6.8 (20G730)
–Applications
→ Script Debugger 8.0.5 (8A61)
–Script Libraries
→ Myriad Tables Lib 1.0.13

Did you relaunch Script Debugger?

Yes, a relaunched couple times

Change the version string in your script to "1.0.13’ tomake sure it’s loading the latest version.

Turns out I had a copy of the library app in the system script libraries folder too. Trashed that and it almost worked.

There remains one issue:

	head alignment align right ¬

Still centers the text in the heading.

All other alignments in the heading row and the table now work properly.

I can’t reproduce that. Anyone else?

Send a snippet and I’ll test

@estockly’s post from a couple of days ago has it all.

Not sure why but whatever I do after putting the file Myriad Tables Lib.scptd into ~/Library/Script Libraries I cannot compile the script

use AppleScript version "2.5"
use scripting additions

use script "Myriad Tables Lib" version "1.0.13"
set tableData to {}
set theNames to {"Harry", "Warren", "Glenn", "Zak", "Clint", "Clark", "Harry", "Warren", "Glenn", "Zak", "Clint", "Clark"}

repeat 5 times
	set thisRow to {}
	repeat 8 times
		set the end of thisRow to some item of theNames
	end repeat
	set the end of tableData to thisRow
end repeat

set columnHeadings to {"1-left, left", "2-right,right", "3-center, center", "4-natural, natural", "5-left,right", "6-right,Left", "7-right,center", "8-center,right"}
set columnWidth to 125
set newTable to ¬
	make new table with data tableData ¬
		column headings columnHeadings

modify columns in table newTable ¬
	columns list {1} ¬
	head alignment align left ¬
	entry alignment align left ¬
	column width columnWidth ¬
	
modify columns in table newTable ¬
	columns list {2} ¬
	head alignment align right ¬
	entry alignment align right ¬
	column width columnWidth ¬
	
modify columns in table newTable ¬
	columns list {3} ¬
	head alignment align center ¬
	entry alignment align center ¬
	column width columnWidth ¬
	
modify columns in table newTable ¬
	columns list {4} ¬
	head alignment align natural ¬
	entry alignment align natural ¬
	column width columnWidth ¬
	
modify columns in table newTable ¬
	columns list {5} ¬
	head alignment align left ¬
	entry alignment align right ¬
	column width columnWidth ¬
	
modify columns in table newTable ¬
	columns list {6} ¬
	head alignment align right ¬
	entry alignment align left ¬
	column width columnWidth ¬
	
modify columns in table newTable ¬
	columns list {7} ¬
	head alignment align right ¬
	entry alignment align center ¬
	column width columnWidth ¬
	
modify columns in table newTable ¬
	columns list {8} ¬
	head alignment align center ¬
	entry alignment align right ¬
	column width columnWidth ¬
	
set tableResult to display table newTable

I get the following error

Can’t get script “Myriad Tables Lib” whose version ≥ “1.0.13”.

I have verified the version in the folder is “1.0.13”.

Restart seems to have resolved the issue.
Head Alignment Right seems to work for me.
@estockly @ShaneStanley