Stack stopped working
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Stack stopped working
My stack was working fine, then it stopped. The stack is simple: A single card, with all handlers in that card's script. Calling any handler from a menu button or the Message Box fails. In the Message Box calling the handler setStaff, for example, results in "put setStaff" appearing in the command field, with "setStaff" showing up in the results, and the commands in the handler NOT executing.
All is not well in the card script. Twenty or thirty handlers look fine, then seemingly randomly there is this: The error message is: There's nothing wrong with the contents of the line indicated as an error. Commenting out the line just shifts the error to the next, perfectly good, line of code. Commenting out the entire handler relocates the error to a perfectly good line in a later handler.
Some sort of stack corruption? I'm hoping the cause is simple, and easily rectified, but I am a relative newbie, and have no idea what's going on. Thanks.
All is not well in the card script. Twenty or thirty handlers look fine, then seemingly randomly there is this: The error message is: There's nothing wrong with the contents of the line indicated as an error. Commenting out the line just shifts the error to the next, perfectly good, line of code. Commenting out the entire handler relocates the error to a perfectly good line in a later handler.
Some sort of stack corruption? I'm hoping the cause is simple, and easily rectified, but I am a relative newbie, and have no idea what's going on. Thanks.
-
- VIP Livecode Opensource Backer
- Posts: 7237
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: Stack stopped working
Do you have explicitVariables turned on? That's what the error message implies. If so, turn it off.
Unrelated, the parentheses around the quoted image name aren't necessary.
Unrelated, the parentheses around the quoted image name aren't necessary.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: Stack stopped working
Difficult to tell from your screenshot... you're only showing us a fragment of code, albeit one that contains the error...
Is variable checking switched on by chance? (with the script editor showing, ensure text in the SE is selected then click he 'Edit' menu -> options -> variable checking.
It doesn't look like you're declaring your local variables (although difficult to say for sure from your screenshot) and if variable checking is switched on it will throw errors if you haven't declared the variables first...
First of all i would recommend putting the global declarations at the top of the script, outside any handlers (that way the globals will be available for all handlers).
Then you could changing and see if the error goes away. If this is the source of problems then either declare all your local variables within the handler or switch off the variable checking... I prefer to always have variable checking switched on because it prevents errors from typos, but each to his own...
Hope that helps,
Stam
Is variable checking switched on by chance? (with the script editor showing, ensure text in the SE is selected then click he 'Edit' menu -> options -> variable checking.
It doesn't look like you're declaring your local variables (although difficult to say for sure from your screenshot) and if variable checking is switched on it will throw errors if you haven't declared the variables first...
First of all i would recommend putting the global declarations at the top of the script, outside any handlers (that way the globals will be available for all handlers).
Then you could changing
Code: Select all
on SetStaff
local currentLocH, divLocks, beatLocks // and whatever other local variables you use in handler
set the fileName of...
Hope that helps,
Stam
Re: Stack stopped working
The problem was indeed variable checking. Turning it off returned things to normal. I'll follow Stam's suggestions about variable declarations and their placement. FYI, I am a Director refugee, and declaring local variables there wasn't necessary (or recommended, I don't think), so that didn't occur to me as a problem. And I don't THINK declaring globals outside handlers was an option (no, not certain about that).
Thanks commenters! This is a REALLY great forum. I have posted a number of problems, and all have received timely and helpful responses.
Thanks commenters! This is a REALLY great forum. I have posted a number of problems, and all have received timely and helpful responses.
Re: Stack stopped working
Yeh i remember being confused about that as well when starting out... globals need to be declared in each script (not handler) where they may be used and putting the declaration at the top means they'll be available to all subsequent handlers.
Many times a 'local' declaration outside a handler (ie a script local variable) does a similar job for all handlers in that script and may be a better choice depending on what scope you need...
Re: Stack stopped working
Another good option would be a custom property, which if you need it to retain it's value even after the program closes can be accomplished, unlike any other variable.