Myriad Tables Questions

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

Same thing was happening to me, and I was able to determine I had multiple copies of Shane’s library app installed. Look in:

User Script Libraries
System Script Libraries

And maybe do a search for “Shane’s Script Library Pack” and delete all but the most recent. (The ones in the Library folders may not show up in a spotlight search)

You could also change this line of the script

use script "Myriad Tables Lib" version "1.0.13

to this

use script "Myriad Tables Lib"

That would use the first version of Myriad Tables if finds, regardless of the version.

I had a couple old versions of the App in a folder but none were in Applications…deleted now. No old copies in User Script Libraries or System Script Libraries. I think the OS must cache the Library until rebooted or something. Script Debugger quit and restart didn’t resolve but restart fixed it.

I’ve noticed a couple issues with setting column widths in tables.

  • The dictionary says real for column width, but it should be integer
  • If I use any value for column width from 1 to 9, it errors. It works with 0 or 10 and any number more than 10
  • If the MT window is wide, and I want the first column to be narrow and the extra width taken up in the later columns, it doesn’t work. The first column always appears to wide.

Here an example that illustrates the issue (with comments in the script)

use scripting additions
use script "Myriad Tables Lib"
set playerRoster to {¬
   {"1", "Clint", "Eastwood"}, ¬
   {"2", "Mel", "Brooks"}, ¬
   {"3", "Woody", "Allen"}, ¬
   {"4", "Woody", "Harrelson"}, ¬
   {"5", "Mel", "Gibson"}, ¬
   {"6", "Mary", "Tyler Moore"}, ¬
   {"7", "Katharine", "Hepburn"}, ¬
   {"8", "Lauren", "Bacall"}, ¬
   {"9", "James", "Stewart"}, ¬
   {"10", "Clark", "Gable"}, ¬
   {"11", "Carey", "Grant"}, ¬
   {"12", "Colin", "Firth"}, ¬
   {"13", "Henry", "Fonda"}, ¬
   {"14", "Humphrey", "Bogart"} ¬
      }

set tableData to playerRoster
set tableTitle to "Edit Roster"
set tablePrompt to "Add/Delete or Edit Player names and numbers. Click column headings to sort"

set newTable to make new table with data tableData ¬
   with title tableTitle ¬
   with prompt tablePrompt ¬
   with empty selection allowed

--modify column
set columnsToModify to {1} 
set columnWidth to 0
-- Does not accept numbers from 1 to 9
--Will not allow a narrow first column if the window is wide


modify columns in table newTable ¬
   columns list columnsToModify ¬
   column width columnWidth ¬
   
--Modify table
set OKButtonName to "Accept"
set OKButtonIsDefault to true
set cancelButtonName to "Cancel (Without Saving)"

modify table newTable cancel button name cancelButtonName
--If you note out the modify table line above you'll see how it works when the window in not unusually wide.

set tableResult to display table newTable ¬
   with extended results

→ Mac OS Version 11.6.8 (20G730)

–Applications
→ Script Debugger 8.0.5 (8A61)

–Script Libraries
→ Myriad Tables Lib 1.0.13

It should accept either.

The dictionary says:

A width of 0 means automatic sizing, and the minimum is 10 points.

Then don’t set its width to automatic (0).

If I set its width to 10, and the buttons are wide, it adds space to the columns (including the first one, where the width is set). If the buttons are narrow, it displays correctly.

This version displays two tables. The only difference the width of the buttons. (and the title and prompt, but those have no effect)

Ideally, if space is added to columns to fit a wider window, it should be added to those whose widths are not set.

If widths are set in all columns, then no space should be added and the window should simply have a margin from the right side of the table to the right side of the window.

use scripting additions
use script "Myriad Tables Lib"
set playerRoster to {¬
   {"1", "Clint", "Eastwood"}, ¬
   {"2", "Mel", "Brooks"}, ¬
   {"3", "Woody", "Allen"}, ¬
   {"4", "Woody", "Harrelson"}, ¬
   {"5", "Mel", "Gibson"}, ¬
   {"6", "Mary", "Tyler Moore"}, ¬
   {"7", "Katharine", "Hepburn"}, ¬
   {"8", "Lauren", "Bacall"}, ¬
   {"9", "James", "Stewart"}, ¬
   {"10", "Clark", "Gable"}, ¬
   {"11", "Carey", "Grant"}, ¬
   {"12", "Colin", "Firth"}, ¬
   {"13", "Henry", "Fonda"}, ¬
   {"14", "Humphrey", "Bogart"} ¬
      }
set tableData to playerRoster

set firstColumnWidth to 10
set OKButtonName to "Accept"
set OKButtonIsDefault to true
set cancelButtonName to "Cancel (Without Saving)"
set tableTitle to "With Wide Buttons"
set tablePrompt to "Column width for first column is set to 10 and no space is added. Space is added to all three columns"


set newTable to make new table with data tableData ¬
   with title tableTitle ¬
   with prompt tablePrompt ¬
   with empty selection allowed

--modify column
set columnsToModify to {1}
set columnWidth to firstColumnWidth
--Will not allow a narrow first column if the window is wide

modify columns in table newTable ¬
   columns list columnsToModify ¬
   column width columnWidth ¬
   
--Modify table


modify table newTable cancel button name cancelButtonName
--If you note out the modify table line above you'll see how it works when the window in not unusually wide.

set tableResult to display table newTable ¬
   with extended results

set OKButtonName to "OK"
set cancelButtonName to "Cancel"

set tableTitle to "With Narrow Buttons"
set tablePrompt to "Column width for first column is set to 10. No space is added to the columns."

set newTable to make new table with data tableData ¬
   with title tableTitle ¬
   with prompt tablePrompt ¬
   with empty selection allowed

--modify column
set columnsToModify to {1}
set columnWidth to firstColumnWidth
--Will not allow a narrow first column if the window is wide

modify columns in table newTable ¬
   columns list columnsToModify ¬
   column width columnWidth ¬
   
--Modify table


modify table newTable cancel button name cancelButtonName
--If you note out the modify table line above you'll see how it works when the window in not unusually wide.

set secondTableResult to display table newTable ¬
   with extended results

That’s right – width required to show the buttons takes precedence.

That’s just not going to happen. If you need strict control over column widths, you need to first make sure your buttons will accommodate it.