More Myriad Table Questions

(Starting a new topic because Safari freezes when I scroll to the bottom of the original)

I’ve been having an issue using Myriad Tables from an Applet as an AppleScript Palette with inDesign. About every 10th time I launch a script, the applet crashes and I get an apple Crash notification.

I’ve been using the applet for months, and aside from this issue it works fine.

I can use this applet myself but I don’t think I can inflict a frequently crashing applet on users.

I don’t know if the issue is with Myriad Tables, the applet, inDesign or some combination of all three.

I’m not sure how to proceed.

Any suggestions?

Also, when I save it as an enhanced app there are other issues that I haven’t been able to track down. Errors that variables are not set that just don’t make sense.

And, it sometimes causes SD to crash if I run from SD (send crash report this morning).

Can you send me a crash report?

I’ll send you a bunch in the morning, I usually have half a dozen

So the app continued to crash, but without the appleCrash report appearing. I ran it from within SD and that generated the SD crash report which I sent from within the app.

Not so much a question but more of a feature request.

Would it be difficult to allow an icon to be displayed with a table? Not in the table itself, but in the window the way it’s done with display dialog and display alert.

(I have two identical scripts, one that controls Safari, the other Chrome, I’d like to have an icon displaying in the window to let the user know at a glance which one to click on)

It’s more work than I want to take on, honestly. But you can pretty much do what you like with the accessory view.

Create an image view and fill it with your pic (doesn’t need to be .icns file):

set theImage to current application's NSImage's alloc()'s initWithContentsOfURL:theFile
set theView to current application's NSImageView's alloc()'s initWithFrame:{{0, 0}, {64, 64}}
theView's setImage:theImage
theView's setImageScaling:(current application's NSImageScaleProportionallyUpOrDown)

Then pass that as the accessory view. The placement is a bit odd, above the buttons, but it should get the message across.

OK, I’ll try that. thanks.

Quick question about adding a row. Is it possible to ad a row with default values? I have a table where only one or two of several variables need to change when the user click +, but they have to fill them all in.

It’s theoretically possible…

When “OK Button is default” is set to true, shouldn’t the OK button be highlighted? It’s not, but it’s still default. (it activates when you hit return)

That’s the OS’s doing, I’m afraid.

The script below is part of a large script that’s nearly complete. But it has one nagging issue. It displays a table with two columns and the first column is basically labels and doesn’t need much space. The second column is data, and needs more space.

I’ve tried numerous combinations of
modify columns column width
and
modify table column widths pattern
But I can’t get the first column to be narrow and the second column to be wide.

Any suggestions?

use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "AppKit"
use script "Myriad Tables Lib"
use script "Dialog Toolkit Plus"
set initialPosition to {30, 30}

set titleLists to {¬
   {"dataTitle", "Category", "Channel", true, ¬
      "PreferredTitle", ¬
      "TitleOption1", ¬
      "TitleOption2", ¬
      "TitleOption3", ¬
      "TitleOption4", ¬
      "TitleOption5"}, ¬
   {"Two and a Half Men", "Series -- Syndicated", "", false, ¬
      "2 & 1/2 Men"}, ¬
   {"Last Man Standing", "Series -- First Run and Syndicated", "Fox", false, ¬
      "Last Man Standing", ¬
      "Last Standing"}, ¬
   {"The Daily Show With Trevor Noah", "Series -- First Run", "Comedy Central", false, ¬
      "The Daily Show With Trevor Noah", ¬
      "The Daily Show: Trevor Noah", ¬
      "Daily Show: Trevor Noah", ¬
      "The Daily Show", ¬
      "Trevor Noah", ¬
      "Daily Show"}, ¬
   {"Saturday Night Live", "Series -- First Run and Syndicated", "NBC", false, ¬
      "Saturday Night Live", ¬
      "SNL"} ¬
      }

repeat
   set titleInfo to some item of titleLists
   set {thisTitle, category, channel, episodeTitles} to titleInfo
   set titleOptionlist to items 5 through -1 of titleInfo
   set item 1 of titleOptionlist to {"Preferred", item 1 of titleOptionlist}
   repeat with x from 2 to count of titleOptionlist
      set thisTitleOption to item x of titleOptionlist
      set thisTitleOption to {"Alt-" & ((x - 1) as text), (thisTitleOption as text)}
      set item x of titleOptionlist to thisTitleOption
   end repeat
   
   set rowTemplate to {"", ""}
   set selectedRows to {}
   set tableTitle to thisTitle & " title options"
   set theCategory to category
   set theChannel to channel
   
   --set viewParams to BuildAcceccoryView(episodeTitles, theCategory, theChannel)
   --   
   --my CreateAccessory(viewParams)
   --   
   -- create accessory view, passing controls plus size (as {width, height})
   set tablePrompt to "Edit info and options for " & thisTitle
   
   set theTable to make new table with data titleOptionlist ¬
      with title tableTitle ¬
      with prompt tablePrompt ¬
      multiple selections allowed false ¬
      empty selection allowed true ¬
      row template rowTemplate ¬
      can add and delete true ¬
      editable columns {2} ¬
      column headings {"", "Title Options"} ¬
      row numbering false ¬
      initially selected rows selectedRows
   
   set OKButton to "Save" --1
   set CancelButton to "Cancel (without saving)" --ERROR
   set extraButton to "Edit" --2
   modify table theTable ¬
      OK button name OKButton ¬
      cancel button name CancelButton ¬
      extra button name extraButton ¬
      highlighted rows {} ¬
      grid style grid between columns ¬
      column widths pattern {1, 2} ¬
      alternate backgrounds true ¬
      initial position initialPosition ¬
      row dragging false ¬
      without column reordering
   --   modify table theTable accessory view theAccessoryView
   modify columns in table theTable ¬
      columns list {1} ¬
      column width 5
   modify columns in table theTable ¬
      columns list {2} ¬
      column width 35
   
   try
      set tableResult to display table theTable ¬
         with extended results
   on error errMsg number errNum
      exit repeat
   end try
end repeat

The ‘column widths pattern’ parameter is to set equal columns; it’s no use for what you’re trying to do. And your column width values are being ignored because they’re way too small. Try values of 50 and 350 instead.

Thanks, that put me on the right track.

modify columns in table theTable ¬
			columns list {2} ¬
			column width 480
		--modify columns in table theTable ¬
		--	columns list {1} ¬
		--	column width 10
		

So, I figured out that if I drop the column widths patterns parameter, and just set the width of the longer column, the shorter column will fill the rest of the space.

Thanks!

Now I’m off to storing and retrieving from multiple applications in SQL Lite!

I have a script using Myriad Tables that I have been using for years, with a few updates or added features now and then. (This go around I added a Dialog toolkit dialog).

It has worked fine as an applet and in ScriptDebugger.

But with my last edit there’s a bug, so I need to use the debugger.

As soon as it reaches the “Display table with data” command I get this AppleScript Execution error message:

Couldn’t write data because C and Objective-C pointers cannot be saved in scripts.

I believe all the variables used in the command are local to its hander.

Plus, when it’s not in debugging mode the table displays perfectly, and, in this script, it’s in a repeat loop so the user can verify the changes, and it displays correctly subsequently. The bug comes later in execution.

How can I track down what’s causing this?

→ Script Debugger 7.0.13 (7A125)
→ Mac OS 10.13.6 (17G14042)
→ “Myriad Tables Lib” version “1.0.9”

Dang, I thought this looked familiar. A search turned up the answer that tables use pointers that can’t be saved.

It’s strange because I use debugging so much and Myriad Tables so much I’m surprised I don’t see this all the time.

My workaround is to save an applet with the handler in it’s own app (tableapp.app) and, when debugging, call the handler in that app.

Funny thing is I am able to debug MT scripts on my work Mac.

→ Script Debugger 7.0.13 (7A125)
→ Mac OS 10.11.6 (15G22010)
–>“Myriad Tables Lib” version “1.0.11”

(Just realized I need to upgrade MT on my laptop too)

OK, This is weird.

I would get the pointers message on my old Laptop

→ Script Debugger 7.0.13 (7A125)
→ Mac OS 10.13.6 (17G14042)
→ “Myriad Tables Lib” version “1.0.9”

But not on my Mac mini

→ Script Debugger 7.0.13 (7A125)
→ Mac OS 10.11.6 (15G22010)
–>“Myriad Tables Lib” version “1.0.11”

But I get it on my new laptop

→ Script Debugger 8.0.1 (8A36)
→ Mac OS 11.6 (20G165)
–>“Myriad Tables Lib” version “1.0.12”

I understand why it doesn’t work on the laptops, but how is it that it works on the Mac mini?