Supertalk Error 15?

Using Standalone Maker to build executables or delivering projects for use with the SuperCard Player? Discuss it here.

Supertalk Error 15?

Postby drpitcairn » Fri Nov 11, 2011 12:08 pm

I am testing a standalone project with another person helping me. When she runs it she gets this error 15. I cannot reproduce it at my end. Anyone know what it means? The user manual says "expected boolean but found something else" but I am not smart enough to interpret this.
User avatar
drpitcairn
 
Posts: 1023
Joined: Thu Apr 02, 2009 9:39 am
Location: Sedona, Arizona

Re: Supertalk Error 15?

Postby FourthWorld4444 » Fri Nov 11, 2011 2:48 pm

In SuperTalk, Boolean expressions are those that evaluate to "true" or "false". So somewhere in the line of code indicated the interpreter expected an expression that could be evaluated to one of those two values, but found something else.

HTH -
-
Richard Gaskin
Fourth World Media Corporation
http://www.fourthworld.com
FourthWorld4444
 
Posts: 16
Joined: Thu Aug 14, 2008 8:29 am
Location: Los Angeles

Re: Supertalk Error 15?

Postby drpitcairn » Fri Nov 11, 2011 7:38 pm

That's helpful. Wonder if anyone has every figured out a way for testing a standalone such that it would identify in the script where the problem is. Would be useful.
User avatar
drpitcairn
 
Posts: 1023
Joined: Thu Apr 02, 2009 9:39 am
Location: Sedona, Arizona

Re: Supertalk Error 15?

Postby Lisa » Sat Nov 12, 2011 3:56 am

You know how the iPhone's slogan is "There's an app for that!"? SuperCard's slogan should be "There's a message for that!" :D See the entry on scriptError in the language guide:

It is very common to have a scriptError handler in the project script of a project. This provides a central location where all script error messages can be processed. To determine what object generated the script error, use the errorObject function. To determine the location in the script where the error occurred, use the errorOffset function.

You can gather the necessary info in a scriptError handler and show it in a dialog, or write it to file, or write it to console, etc. I usually put up a dialog asking the user to email me.

Here's something you can try. Make a button in a test project with a mouseUp handler that has a single line: "if x=y then return". Click the button and note how SC handles the error. Now put the code below in the project script of the test project and click the button again. Click "Email" in the dialog, and you can see what this scriptError handler does. You might want to tailor the way the message is written out before putting it in a real project.

Code: Select all
on scriptError errNum
 
  --if environment() ≠ "Supercard" then
 
  put "APPLICATION NAME" into appName
  put "MY-EMAIL-ADDRESS" into emailAddr
 
  alert merge("Sorry, [[appName]] got an error.") ¬
    explain "Please send an email report to the developer." with "Cancel" or "Email"
 
  put merge("Error #[[errNum]]: [[errorText(errNum)]][[cr]]Location: [[errorOffset()]]; [[errorObject()]]") & cr into msgBody
  put "System Version: Mac OS X" && systemVersion(long) & cr after msgBody
  put "Processor:" && processor() & cr & cr after msgBody
  put "Describe what you were doing when the error occurred: " after msgBody
 
  get shell(merge("open 'mailto:[[emailAddr]]?subject=[[urlEncode(appName)]]&body=[[urlEncode(msgBody)]]'"))
 
  --else pass scriptError
 
end scriptError

When you're done testing the scriptError handler, you want to uncomment the two commented lines. This will allow you the developer to get SC's regular error messages, because presumably you don't want to email yourself every time you make a little typo in a script. ;)
iMac 24" 3.06 GHz Intel Core 2 Duo, 4 GB RAM, Mac OS X 10.6.8, SC 4.7.3
User avatar
Lisa
 
Posts: 303
Joined: Sun Jul 06, 2008 12:33 pm
Location: San Diego, CA

Re: Supertalk Error 15?

Postby drpitcairn » Sat Nov 12, 2011 6:26 am

Thanks so much Lisa. I will work with it as I can see will be very useful.
Your ability to write these scripts is so beyond me. I read what you do (as here) and can sort of follow it but when you get into those sentences with all the brackets I have no idea what it means. :oops: Is this knowledge you are bringing in from other coding experience?
User avatar
drpitcairn
 
Posts: 1023
Joined: Thu Apr 02, 2009 9:39 am
Location: Sedona, Arizona

Re: Supertalk Error 15?

Postby Lisa » Sat Nov 12, 2011 7:52 am

I learned the basics of programming and a few simple languages long before I started with SuperCard. But the brackets are specific to SC's merge function, which is something I've never seen elsewhere. It's just a shorthand way of concatenating strings, it's especially useful when the string needs to include quotation marks but I tend to use it even when it's not any shorter than writing it out the "long" way.

The following two statements are equivalent. If you prefer the latter, then by all means substitute it in the script above; there's nothing inherently superior about the way I wrote it, and I didn't mean to be purposefully esoteric as I just copied and pasted from an existing script of mine without thinking that it might not be the best way to explain something new. :)

Code: Select all
put merge("Error #[[errNum]]: [[errorText(errNum)]][[cr]]Location: [[errorOffset()]]; [[errorObject()]]") & cr into msgBody

put ("Error #" & errNum & ":" && errorText(errNum) & cr & "Location:" && errorOffset() & ";" && errorObject() & cr) into msgBody
iMac 24" 3.06 GHz Intel Core 2 Duo, 4 GB RAM, Mac OS X 10.6.8, SC 4.7.3
User avatar
Lisa
 
Posts: 303
Joined: Sun Jul 06, 2008 12:33 pm
Location: San Diego, CA

Re: Supertalk Error 15?

Postby drpitcairn » Sat Nov 12, 2011 9:01 am

I will have a look at the merge function. Have never used it.
Do you ever have classes, teaching this stuff?
User avatar
drpitcairn
 
Posts: 1023
Joined: Thu Apr 02, 2009 9:39 am
Location: Sedona, Arizona

Re: Supertalk Error 15?

Postby drpitcairn » Sat Nov 12, 2011 5:16 pm

OK, I got some time to try the script. Worked as you explained and here was the message that came up in my email:

Error #15: Expected boolean but found something else.
Location: 2,11,14; card button ID 329 of card ID 101 of window ID 101 of project "MacBook Pro (2):Users:drpitcairn:Documents:Supercard Projects:TESTER.sc45"
Processor: Intel Core 2 Duo

Describe what you were doing when the error occurred:

I can't figure out the location part. What does it refer to?
Also, if I hit the cancel button of the alert window, it still produces an email. I tried to fix that myself but could not. Seems the alert window is different — sheetbutton and strange stuff like that.

If I wanted to test it myself (rather than email) would I change it so as to see a dialog?
User avatar
drpitcairn
 
Posts: 1023
Joined: Thu Apr 02, 2009 9:39 am
Location: Sedona, Arizona

Re: Supertalk Error 15?

Postby drpitcairn » Sat Nov 12, 2011 8:25 pm

I have done more study of this, reading LG and how the errorOffset works. I realize from this information:
The information that is returned is an item list that contains three values:
Item Contents
1 The line offset (number) of the line in the script that produced the error.
2 The character offset (number) of the first character of the line number
returned in item 1.
3 The character offset (number) of the script where the insertion point
would be if the script were edited.

that the numbers are indicating where the error is, right? If that is right, here is the button script:
Code: Select all
on mouseUp
    if x=y then return
end mouseUp

and the error report gives these numbers:
Location: 2,11,14
So I can see the first number refers to line 2, which is correct.
But the second number refers to the first character of the line number? Wouldn't that be the beginning of the line "if x-y, etc."? So wouldn't the number be "1"?
Then the third number, which is 14, refers to what? If I ignore the spaces, then the 14th char is the last character of the line = "n", right?
But don't the numbers basically just tell me that there is something wrong with this line rather than pinpointing what word is the issue?
User avatar
drpitcairn
 
Posts: 1023
Joined: Thu Apr 02, 2009 9:39 am
Location: Sedona, Arizona

Re: Supertalk Error 15?

Postby Lisa » Sun Nov 13, 2011 4:56 am

drpitcairn wrote:Also, if I hit the cancel button of the alert window, it still produces an email.

Oops, sorry, I lost something when cutting and pasting from two different scripts. Just like an "answer" dialog, the name of the button the user pressed in a non-sheet "alert" dialog is placed in the variable "it", so add the following immediately after the line that calls up the alert dialog:
Code: Select all
if it = "Cancel" then exit to supercard

drpitcairn wrote:If I wanted to test it myself (rather than email) would I change it so as to see a dialog?

If you want to see SuperCard's regular error dialog while you're testing the project in the RTE, then uncomment the two commented lines, which wraps the code in a conditional that will only trigger when run in a standalone. You only need to comment out those two lines when you're testing the scriptError handler itself, but keep them uncommented while you're debugging errors elsewhere in the project. If you want to see the result of the errorOffset function as well, then change the last line of the handler to the following, and the offset numbers will be shown in the message box.
Code: Select all
else
  put errorOffset()
  pass scriptError
end if

drpitcairn wrote:But the second number refers to the first character of the line number? Wouldn't that be the beginning of the line "if x-y, etc."? So wouldn't the number be "1"?

The second number refers to the overall position of the first character of the line SuperCard tripped over, which would be the "i" in "if", which is indeed the 11th character (spaces are not ignored) from the beginning of the script. The third number is the overall position of the first character of the word (or function or expression or whatever) that is causing the error, which would be the "x", the 14th character from the beginning of the script.
iMac 24" 3.06 GHz Intel Core 2 Duo, 4 GB RAM, Mac OS X 10.6.8, SC 4.7.3
User avatar
Lisa
 
Posts: 303
Joined: Sun Jul 06, 2008 12:33 pm
Location: San Diego, CA

Re: Supertalk Error 15?

Postby drpitcairn » Sun Nov 13, 2011 7:46 am

Thanks for clarifying. I put this additional code in and works fine. Where I got confused about the "cancel" choice was reading this in the LG for the Alert command. It says that there is no return of a result into "it", so I thought I couldn't use the usual way of using "it".

SPECIAL CONSIDERATIONS
Unlike the regular modal version of alert, the sheet version doesn’t hold up script execution and return a result in it (because modal operation defeats the purpose of using a sheet). Instead, script execution continues, and when the user clicks one of the alert’s buttons a script message called sheetButton is sent to the current card of the window which owns the sheet.
The sheetButton message receives the name of the selected button (in quotes) as a parameter. Interaction with the window over which the sheet is displayed is blocked until the sheet is dismissed, but the rest of the interface continues to respond to user input.
User avatar
drpitcairn
 
Posts: 1023
Joined: Thu Apr 02, 2009 9:39 am
Location: Sedona, Arizona

Re: Supertalk Error 15?

Postby Lisa » Sun Nov 13, 2011 9:19 am

drpitcairn wrote:It says that there is no return of a result into "it"
SPECIAL CONSIDERATIONS
Unlike the regular modal version of alert, the sheet version doesn’t hold up script execution and return a result in it (because modal operation defeats the purpose of using a sheet).

Only if you're using the sheet option -- "alert sheet "some dialog text" explain...". If you omit the "sheet" keyword (as I did above) then the alert will just be the "regular modal version". It's written in a roundabout sort of way, so I can see where the confusion comes from.
iMac 24" 3.06 GHz Intel Core 2 Duo, 4 GB RAM, Mac OS X 10.6.8, SC 4.7.3
User avatar
Lisa
 
Posts: 303
Joined: Sun Jul 06, 2008 12:33 pm
Location: San Diego, CA


Return to Building Standalones

Who is online

Users browsing this forum: No registered users and 1 guest

cron