Myriad Tables Questions

This just keeps getting better and better! :slight_smile:

When I run this script a few times it breaks. instead of displaying a table it displays a window that is junk. Nothing to see, click or close. It leave SD in a bad state too. The script Stop button does not go away, and you canā€™t close the script (although saving worked. One time I had to force quit SD, the other time I could quit from the dock.

(Also it seems SD doesnā€™t show the crash reporter after a force quit, but the apple crash reporter does come up. Didnā€™t SD used to show a crash reporter after a FQ?
ā€“> SD 6.0.4 (6A198) OSX 10.11.6 (15G1217)

use AppleScript version "2.4"
use scripting additions
use script "Myriad Tables Lib" version "1.0.6"
--use framework "Foundation"
property lastTablePosition : {}
if lastTablePosition is {} then
   set {tableX, tableY, tableW, TableH} to {980.0, 26.0, 300.0, 250.0}
else
   set {tableX, tableY, tableW, TableH} to lastTablePosition
end if

set tablePosition to {"1. Set", tableX, tableY, tableW, TableH}
set tableData to {}
set AppleScript's text item delimiters to " "
set tableCount to 1
set countText to tableCount as text

repeat
   set the end of tableData to tablePosition
   set tablePrompt to {countText & ". Initial position:", "X:", tableX, "Y:", tableY, "W:", tableW, "H:", TableH} as text
   
   set theTable to make new table with data tableData Ā¬
      with prompt tablePrompt Ā¬
      empty selection allowed true Ā¬
      multiple lines allowed false Ā¬
      with double click means OK
   
   modify table theTable initial position the rest of tablePosition Ā¬
      with alternate backgrounds
   try
      set tableResult to display table theTable Ā¬
         with extended results
   on error
      return tablePosition
   end try
   set tableFinalPosition to final position of tableResult
   set the beginning of tableFinalPosition to countText & ". Result"
   set the end of tableData to tableFinalPosition
   set userSelecton to values selected of tableResult
   if userSelecton is not {} then
      set tableFinalPosition to item 1 of userSelecton
      set the item 1 of tableFinalPosition to countText & ". User Select"
      set the end of tableData to tableFinalPosition
   end if
   set tableFinalPosition to the rest of tableFinalPosition
   set {tableX, tableY, tableW, TableH} to tableFinalPosition
   --set tableX to tableX + 20
   --set tableY to tableY + 20
   --set tableW to tableW + 20
   --set TableH to TableH + 20
   if tableX < 1 then set tableX to 0
   if tableY < 1 then set tableY to 0
   set tableCount to tableCount + 1
   set countText to tableCount as text
   set lastTablePosition to {tableX, tableY, tableW, TableH}
   set tablePosition to {countText & ". Set", tableX, tableY, tableW, TableH}
end repeat

Iā€™m unable to reproduce that here (10.12.3). Anyone else?

(Also, youā€™re using v1.0.7 features, so it would be safer to change the version string in the use statement.)

Did I mention I was in debugging mode?

This is happening with some regularity Iā€™m going to reboot and see if that helps.

No ā€“ but I just tried, and gave up at 40.

I simplified the script. Notice that when I resize the table window it blows up.

Also, if I run it with a minor error (undermined variable, for example, note out the line that sets the variable lastTablePosition) The script errors out but then I canā€™t do anything with SD except force quit.

use AppleScript version "2.4"
use scripting additions
use script "Myriad Tables Lib" version "1.0.7"
--use framework "Foundation"
property lastTablePosition : {}
if lastTablePosition is {} then
   set {tableX, tableY, tableW, TableH} to {80.0, 26.0, 300.0, 300.0}
   set lastTablePosition to {tableX, tableY, tableW, TableH}
   
else
   set {tableX, tableY, tableW, TableH} to lastTablePosition
end if

set tableData to {{"Headline Text Box"}, {"Ingredients Group"}, {"Instructions Box"}}
set AppleScript's text item delimiters to " "
set tableCount to 1
set countText to tableCount as text

repeat
   set tablePrompt to {"text boxes"} as text
   set theTable to make new table with data tableData Ā¬
      with prompt tablePrompt Ā¬
      empty selection allowed true Ā¬
      with double click means OK
   
   modify table theTable initial position lastTablePosition Ā¬
      with alternate backgrounds
   try
      set tableResult to display table theTable Ā¬
         with extended results
   on error
      return tablePosition
   end try
   set lastTablePosition to final position of tableResult
   set userSelecton to values selected of tableResult
   
end repeat



Forgot about that link thing Try this: www.dropbox.com/s/575c0ifw648hrsg/TableScriptError.mov?dl=0

Sorry ā€“ which line?

set lastTablePosition to {tableX, tableY, tableW, TableH}

So something is definitely happening with SD and Myriad Tables.

First, if there is an error in the script that an on error block would catch, it leaves SD in bad state where I canā€™t do anything but force quit.

Second MT will get into a state where it doesnā€™t display a table window but the space where itā€™s window would be becomes a useless rectangle that wonā€™t go away, and again I have to force quit SD.

None of these issues happen when running the MT scripts in Script Editor.

I donā€™t doubt you, but for the life of me, I canā€™t reproduce your problemsā€¦

From my point of view there is a typo in line #32
Itā€™s
return tablePosition
(this variable isnā€™t defined)
better to use:
return lastTablePosition
With this change it will no longer issue an error when we click [Cancel]

Yvan KOENIG running Sierra 10.12.3 in French (VALLAURIS, France) mardi 7 mars 2017 15:27:45

Yes, that is an intentional error to demonstrate the point*. The point is that rather than catch simple AppleEvent errors in this and other MT scripts (it seems to only happen in MT) Script Debugger enters a weird, unstable state where it must be force quit.

*At least I think thatā€™s the intentional one, there may be others as this script is being copied from another and repurposed, so there could be others.

It may help to know what I got three times.
In message #26, I clicked [Open in Script Debugger]
I failed to click the compile button before clicking the Execute one.
The app crashed immediately.
When I take care to click the compile button, the execution behaves flawlessly - except of course the error due to the reported ā€œtypoā€.

Yvan KOENIG running Sierra 10.12.3 in French (VALLAURIS, France) mardi 7 mars 2017 18:02:20

@edstockly Do you see something similar?

Nope, and I just tried it a couple times.

FWIW, at work Iā€™m on Yosemite and at home El Capitan.

At work it behaves badly in SD but works fine from the Script Menu (not Fast Scripts).

At home it works fine in SD but behaves badly when run from the Scripts menu (again, not Fast Scripts, but the Mac OS Scripts menu).

ā€“>Script Debugger 6.0.4 (6A198) on Mac OS 10.10.4 (14E46)

As I am curious, this morning I grabbed the script available in message #22.
I clicked on the button Execute and a window appeared, I clicked the OK button and the application crashed.
I reloaded the script, I got a dialog asking me to file a report.
No need to click the compile button, the script was already compiled. I ran it and clicked OK about 40 times with no problem.

Yvan KOENIG running Sierra 10.12.3 in French (VALLAURIS, France) mercredi 8 mars 2017 10:20:34

I grabbed the two scripts and saved them on my HD.
I was able to run them from SD with no problem.
I executed them also from Apple Script Editor. They behaved flawlessly.

In case you missed the info given in my signature, every attempts were made under 10.12.3 in French.

Yvan KOENIG running Sierra 10.12.3 in French (VALLAURIS, France) mercredi 8 mars 2017 10:30:17

Thanks for the further reports. I think the workaround to deal with Script Debuggerā€™s threading is being stressed, leading to occasional crashes that canā€™t be pinned down to a single issue.

Iā€™m having an issue with the initial position and/or final position in an MT script.

The table is in a repeat loop. When the user makes their selection and the table closes the position is saved, and when the table reopens it should reopen in the same position (same height and width, too).

It works sometimes, but sometimes it opens in random places on the screen.

Is this a known thing?