Problem locating error in script?

Using SuperCard and the Runtime Editor... working with windows, backgrounds, cards and menus.

Problem locating error in script?

Postby Mike » Mon Aug 14, 2017 7:48 am

I was just running a project for the first time in the SuperCard beta after spending a bit of time living in the SuperEdit script editor window (and watching my scripts bouncing around with odd indents and incorrect colors as I worked - forcing me to have to close and reopen the script editor there numerous times - I do hope that will be fixed soon). Anyway, the project started to run and then informed me of an error where it expected "then". When I clicked the button to check out the script though, the script opened with the cursor blinking at the very top of my script which had absolutely nothing to do with the error (wasn't even a conditional - was a line calling out to another scripted function). In fact, it appears the execution DID get a distance through this long script so the error couldn't possibly have been at the top. I finally did end up doing a trace and did find the offending syntax: line 72:

if not exists(file,tMyFile)) then

which should have been:

if not(exists(file,tMyFile)) then

So why when I opened the script window from the error dialog did it put the cursor up at line 5 of my script (the first line of code after the line establishing my function handler)?

Edit: And shouldn't the error have been about mismatched parenthesis rather than "expected then"?
Mike Yenco
User avatar
Posts: 217
Joined: Sun Jul 06, 2008 8:54 am
Location: Massachusetts, USA

Re: Problem locating error in script?

Postby codegreen » Mon Aug 14, 2017 2:36 pm

FWIW no, you should not have expected a mismatched parentheses error here...

That error is generally encountered when either:

- the parser finds a left paren someplace one shouldn't be, or

- it reaches the end of a line (or other closure, like the end of the script) while an 'opened' parentheses pair is pending

In this case it had just finished unwinding all the stuff that could possibly have legally been part of the conditional expression, and was looking for what syntactically HAD to be a 'then' (which might or might not be on the same line) when it instead ran into a different non-whitespace token (the fact that this was right paren is merely incidental). So perhaps it looks to YOU as a human like this is a mismatched parentheses error, but that's because you already know what the errant expression means.

From the parser's perspective though as it tries to FIGURE OUT what the statement means, the error is much more literal and narrowly-scoped: there's supposed to be a 'then' next and there isn't. You want ten different scriptErrors for that depending on what the errant token actually was and what semantically that might mean in the context of your script? I suppose you'd probably like a pony too, but sorry...

As for the insertion point, theoretically it's set to wherever the parser was chewing at the point things went into the weeds. If you can put together a sample which shows it ending up someplace you think it shouldn't, I'll be happy to investigate further.

Posts: 1556
Joined: Mon Jul 14, 2008 11:03 pm

Return to SuperCard Basics

Who is online

Users browsing this forum: No registered users and 1 guest