Myriad Tables Questions

finder
asobjc
foundation

(Ed Stockly) #21

This just keeps getting better and better! :slight_smile:


(Ed Stockly) #22

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


(Shane Stanley) #23

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.)


(Ed Stockly) #24

Did I mention I was in debugging mode?

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


(Shane Stanley) #25

No – but I just tried, and gave up at 40.


(Ed Stockly) #26

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




(Ed Stockly) #27

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


(Shane Stanley) #28

Sorry – which line?


(Ed Stockly) #29
set lastTablePosition to {tableX, tableY, tableW, TableH}

(Ed Stockly) #30

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.


(Shane Stanley) #31

I don’t doubt you, but for the life of me, I can’t reproduce your problems…


(koenigyvan) #32

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


(Ed Stockly) #33

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.


(koenigyvan) #34

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


(Shane Stanley) #35

@edstockly Do you see something similar?


(Ed Stockly) #36

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)


(koenigyvan) #37

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


(koenigyvan) #38

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


(Shane Stanley) #39

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.


(Ed Stockly) #40

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?