Myriad Tables anomaly

I’ve been working on a Myriad Tables project, and I noticed something strange. I’m going to demonstrate with an adapted version of the “Menu, combo box samples” sample. If I designate a row template, and there is a column with numbers in it, if I use the class name “integer” for that column, the table is displayed correctly. However, if I use the class name “number”, the column with the numbers disappears and the columns get shifted to the left.

use AppleScript version "2.4"
use scripting additions
use script "Myriad Tables Lib" version "1.0.9"

--table with column of popup menus
display table with data {{1.1, true, 1, "One"}, {2, false, 2, "Two"}, {3.3, true, 3, "Three"}, {4, false, 4, "Four"}, {5, true, 5, "Five"}} editable columns {1, 2, 3} column headings {"Number", "", "Digit", "Match"} row template {number, true, 1, {popup menu, {"One", "Two", "Three"}}} with title "Sample table" with prompt "This table has a column with popup menus" with row numbering

This happens on all of my Macs (2 Minis and a MacBook Air). Any ideas as to what’s going on? Thanks.

AppleScript doesn’t have a class called number – it’s just a term that (sometimes) works in coercions. Use one of the actual classes, integer or real.

Wow, all these years I’ve been using “number”. Who knew? (Well, I guess at least you did!) Thanks so much!

I recently started using Myriad Tables in a new project, but I was bumping into a problem, that I solved through in an unexpected manner. I’m posting it here because of the “AppleScript doesn’t have a class called number” discussion point, in case someone else encounters the same opaque error message I was seeing…

My script builds lists of 4 items:

  1. Ticker symbol from an internal database
  2. num of shares held from the same internal database: sharesHeld
  3. current stock quote pulled from the web: currentQuote
  4. (sharesHeld * currentQuote): currentValue
    Each of those lists goes into a list (a list of lists) that ultimately gets sent to the table.

So now, the error: when I pass this list to Myriad Tables, it throws this error:

Error: -11010 Provided data: expected a number, but found some other class.

(FWIW, The Script Debugger reply pane reports the error as a list of 2 items: ‘false’ and ‘(NSError) Error Domain=au.com.myriad-com.SMSTableDialogBuilder.ErrorDomain Code=-11010 “Provided data: expected a number, but found some other class.” UserInfo={NSLocalizedDescription=Provided data: expected a number, but found some other class.}’)

Checking the class of the values confirms that AS is handling them all as real, so what to do? Coercing the incoming data to text works, but an incoming value such as 10.30 ends up as “10.3” which is less appealing, visually.

Now, it would have been nice if the error would report what the “other class” is, but in the back of my mind, I suspect the error would then read “expect a number, but found a number.” :face_with_raised_eyebrow:

When that thought occurred to me, it dawned on me that the issue is probably somewhere in the coercion between an AppleScript ‘real’ and whatever the ‘other class’ might be (NSNumber maybe, but I’m not manipulating these values with ASOC anywhere along the way.)

In debugging it, I noticed that the sharesHeld & currentQuote data was triggering the error, but the current value data was not. So I got an unconventional idea:

set sharesHeld to (sharesHeld * 1)
set currentQuote to (currentQuote * 1)
and then add them to the list… and that works around the error!

In debugging this, I wrote this…

get class of sharesHeld – returns real
set sharesHeld to (sharesHeld * 1)
get class of sharesHeld – returns real
So as far as AppleScript is concerned, it starts with a real and ends with a real but for some reason, Myriad Tables dislikes the first real but accepts the second real

Anyhow, that’s my story and I’m sticking to it. I hope this helps anyone else who may bump up against this mysterious error.

Myriad Tables expects all items to be the same class, so mixing reals and integers can cause problems.

Yes, but there are no integers involved. Everything was explicitly coerced to real – I mean, you can see it right in the debugging line I wrote above: I tested the class of everything and everything (except the column of text) reports as being a real – it’s somewhere in the handoff of the list into Myriad Tables that the error occurs.

Here’s another wrinkle: after I solved the problem and wrote my notes here, I left for a few hours. When I returned, I sat down and ran the script again to re-engage my brain and… it was broken again.

I’m back to looking for a workaround.

I think you misunderstood Shane’s explanation. Here’s an excerpt of the Read Me file:

The type of column is dictated by the class of the first row in the column, and normally you cannot mix different classes in a column; the exception is that integers, reals and booleans can be mixed, because they all represent numbers.

That seems to directly contradicts what Shane just wrote:

Shane (above): “mixing reals and integers can cause problems”
Read Me (per ionah): “integers, reals and booleans can be mixed”

Besides, as I stated, I have explicitly coerced everything to real. If everything in a column (except the header) is a real, where is the conflict?

I’m going to rewrite the list to coerce everything to text, and pad the decimals to provide consistent formatting before passing the list to Myriad Tables. That should resolve it for me. Again, my primary intent is to document this behavior in case others run into the same issue.

You’re talking about rows, were’ talking about columns.

Try this:

use scripting additions
use script "Myriad Tables Lib" version "1.0.9"

-- This is a table of integer entries
display table with data {1, 2, 3, 4, 5} with prompt "Pick an integer"

-- This is a table of real entries
display table with data {1.1, 2.2, 3.3, 4.4, 5.5} with prompt "Pick a real"

-- Because the first item is a real, this is also a table of reals
display table with data {1.0, 2, 3, 4, 5} with prompt "Pick a real"

-- this one will error because there's numbers and textes mixed
display table with data {1.0, "2", 3, "4.4", 5} with prompt "Pick a real"