script local bug or file corruption?

If you find an issue in LiveCode but are having difficulty pinning down a reliable recipe or want to sanity-check your findings with others, this is the place.

Please have one thread per issue, and try to summarize the issue concisely in the thread title so others can find related issues here.

Moderators: Klaus, FourthWorld, heatherlaine, robinmiller, kevinmiller

Post Reply
HansRij
Posts: 8
Joined: Fri Aug 09, 2019 8:10 pm

script local bug or file corruption?

Post by HansRij » Fri Aug 09, 2019 8:25 pm

I'm using script local variables in my stack script which used to keep their values until the stack was closed. But now, the variables are created and their values are shown in the debugger, but on leaving the stack script and returning to it the values are empty. Is this a known problem with a solution, or could it be file corruption?
If it would be file corruption is there a way to prevent it? Is trashing and rebuilding the only solution?
***
Hans Rijnbout
Utrecht, Netherlands

sphere
Posts: 992
Joined: Sat Sep 27, 2014 10:32 am
Location: Earth, Except when i Jump

Re: script local bug or file corruption?

Post by sphere » Tue Oct 08, 2019 2:17 pm

Can you post the stack (as a zip) ?

or show the stack script here?

Groetjes
https://www.jj-s.nl
https://www.multifoodshop.nl
--------------------------------------
1 Check and search the LiveCode User Guide.pdf
2 Check and search the Dictionary
3 Check and search this forum
4 Ask on this forum
5 Ask on the List
6 Help others too

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7295
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: script local bug or file corruption?

Post by FourthWorld » Tue Oct 08, 2019 4:12 pm

If it were file corruption you would not be able to open the file. I have no idea what hellishly unpredictable morass goes on in other development environments to make file corruption such a frequent suspect for scripting issues in LC, but while we pray for the users of such systems I can offer calming assurance that if you can open an LC stack file it's probably not corrupted.

Offhand, what you describe sounds like expected behavior: You have a script that uses script-local vars, the object containing the script (the stack) goes away, and when it goes away those vars go with it.

If you want persistence of a variable throughout a session independent of any script that may be purged, consider using global variables instead.
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

bogs
Posts: 4200
Joined: Sat Feb 25, 2017 10:45 pm

Re: script local bug or file corruption?

Post by bogs » Tue Oct 08, 2019 8:16 pm

FourthWorld wrote:
Tue Oct 08, 2019 4:12 pm
I have no idea what hellishly unpredictable morass goes on in other development environments to make file corruption such a frequent suspect for scripting issues in LC, but while we pray for the users of such systems I can offer calming assurance that if you can open an LC stack file it's probably not corrupted.
Heh, I hope you don't take this the wrong way Richard, and I also hope you don't think what I'm about to type is too harsh, but, that comment seems beneath you, really, like a cheap shot.

Having used a few languages over the years, I never thought about file corruption in any of them.

The first time I ever thought of file corruption was when I was still new to Lc and tried to open a file saved in a later version of the IDE than I was using, which presented me with this cheery message -
fileCorruption.png
Hmmm, is this corrupted?
And the reason I thought (at the time) that it was corrupted was because I *knew* I had created the file in Lc and saved it as a stack.

I think that the reason people jump to 'file corruption' is because they get a result they don't expect, like I did. I've gotten lots of results I didn't expect when learning this languge (far too many to list) for things I regularly did in other IDEs. Maybe it is the same here eh?

Other than that, though, I suspect your dead on with the reason being local vars, instead of a global though, in this case I might suggest going with a custom property.

Just a thought.
Image

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7295
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: script local bug or file corruption?

Post by FourthWorld » Tue Oct 08, 2019 10:23 pm

bogs wrote:
Tue Oct 08, 2019 8:16 pm
FourthWorld wrote:
Tue Oct 08, 2019 4:12 pm
I have no idea what hellishly unpredictable morass goes on in other development environments to make file corruption such a frequent suspect for scripting issues in LC, but while we pray for the users of such systems I can offer calming assurance that if you can open an LC stack file it's probably not corrupted.
Heh, I hope you don't take this the wrong way Richard, and I also hope you don't think what I'm about to type is too harsh, but, that comment seems beneath you, really, like a cheap shot.
It's been a while that I wrote something you felt could stand without correction, so it's not surprising this is another case where you and I are coming at an issue with different perspectives.

In my 30-year career as a published technical writer I don't always get it right. But I find that taking a light-hearted tone helps far more often than it's misunderstood. But humor's funny that way, and everyone's different. The OP I was writing for will be able to tell us, but I don't mind clarifying my intention:

As you know from the years we've spent here, and the conversations we've had like this one before, when I write something that may appear to you as somehow insulting that's never been the goal, and indeed this is like all the other times we go 'round on this.

I can either assume the OP is writing random nonsense, or is writing something reasonable based on direct personal experience. I don't believe it's a mistake to assume the latter.

So if corruption is expressed as a likely cause, where would such an expectation come from?

Those of us who use LC regularly understand that unexpected behavior can be caused by many things. Sometimes it's user error. Sometimes it's a bug in the software. But it's very rarely file corruption.

So when corruption is assumed, and if we assume the OP is a reasonable person, where does the suspicion of such a highly specific cause come from? Since we know that's a rare issue in LC, it's a relatively safe bet the familiarity with corruption comes from experience with something else where that's an actual things that happens often.

A lot of LC users have experience with corruption in HyperCard and Filemaker. Indeed, in Filemaker corruption was so common in earlier versions that they had a "Repair Database" command built into the File menu. With HC, I can't recall the number of AOL and Usenet threads about the infamous "Error 5454", but it was common enough that many of us even remember the specific error code number. :)

All that said, it's possible that my assumptions may be incorrect. It may be that corruption is just a random guess, or that the OP has actually experienced frequent corruption with LC stack files.

If the latter, that would be useful to know, esp. so we can find the recipe and fix it. But I'm disinclined to write off the OP as somehow typing randomly or misrepresenting what they've experienced, so indeed my response, while worded light-heartedly, supportively assumes they're telling the truth about what they've learned from systems where corruption is frequent.
Having used a few languages over the years, I never thought about file corruption in any of them.
Aside from HyperCard and Filemaker, and very few others, my experience is like yours: don't see corruption often in LC.

Maybe the OP is coming from Filemaker? I dunno. We'll learn more when the OP replies.
The first time I ever thought of file corruption was when I was still new to Lc and tried to open a file saved in a later version of the IDE than I was using, which presented me with this cheery message -
fileCorruption.png
And the reason I thought (at the time) that it was corrupted was because I *knew* I had created the file in Lc and saved it as a stack.
Exactly. With corruption the stack can't be opened. For the first several years the engine's generic message was displayed, and for the last decade or so the IDE now presents a more specific notification about formats and possible corruption.
I think that the reason people jump to 'file corruption' is because they get a result they don't expect, like I did. I've gotten lots of results I didn't expect when learning this languge (far too many to list) for things I regularly did in other IDEs. Maybe it is the same here eh?
Might be. We'll know more when the OP returns.

Errors can occur for all sorts of reasons, sometimes a bug and sometimes user error. No worries, that's what we're here for, to help sort them out.

But the assumption that a problem is specifically related to corruption is interesting, esp. given how the assumption appears in this forum so much more frequently than any actual corruption.

As we explore ways to enhance onboarding materials, learning more about where this specific preoccupation with corruption comes from will help us better refine the learning experience.
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

bogs
Posts: 4200
Joined: Sat Feb 25, 2017 10:45 pm

Re: script local bug or file corruption?

Post by bogs » Tue Oct 08, 2019 10:50 pm

Ah, it was a joke! Yoke's on me, heh.

I sincerely apologize, I did say it seemed way below you (I meant that in a good way) :wink:
FourthWorld wrote:
Tue Oct 08, 2019 10:23 pm
It's been a while that I wrote something you felt could stand without correction

I really need to work on my interaction and communication skills, if I'm coming off that way that often as that (rarely) is what I intend :(
Image

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7295
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: script local bug or file corruption?

Post by FourthWorld » Tue Oct 08, 2019 11:07 pm

bogs wrote:
Tue Oct 08, 2019 10:50 pm
Ah, it was a joke! Yoke's on me, heh.

I sincerely apologize, I did say it seemed way below you (I meant that in a good way) :wink:
FourthWorld wrote:
Tue Oct 08, 2019 10:23 pm
It's been a while that I wrote something you felt could stand without correction

I really need to work on my interaction and communication skills, if I'm coming off that way that often as that (rarely) is what I intend :(
Maybe me too. Let's go knock back a few whiskeys while we let the OP chime in to get us back on topic... :)
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2234
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: script local bug or file corruption?

Post by [-hh] » Wed Oct 09, 2019 2:34 am

@HansRij
Did you uncheck "Variable Preservation" of tab "Script Editor" of the preferences?
shiftLock happens

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2903
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: script local bug or file corruption?

Post by mwieder » Fri Oct 25, 2019 9:20 pm

I have found that editing and saving a script clears script local variables. I don't know if this is new behavior, but I frequently have a situation where an initialization routine fills in an array and then later handlers make use of the array. If I edit the script I have to run the initialization routine again to fill the array because otherwise it no longer exists. I don't consider this a bug and in general I'm glad that old data doesn't stick around and get me into trouble. I'm quite capable of messing things up on my own, thank you.

HansRij
Posts: 8
Joined: Fri Aug 09, 2019 8:10 pm

Re: script local bug or file corruption?

Post by HansRij » Fri Jan 17, 2020 5:20 pm

Sorry for my late reply. I'm new to this forum. After I posted my message I received an automatic e-mail telling me that someone had responded to it. I expected this to continue, but it didn't. So I plodded on without your help.
As you supposed, my thinking of file corruption dates from my long experience as a Filemaker developer. I'm glad to hear it is very rare in LiveCode.
In my case the stack did not go away but control was passed to a different object in the stack and returned to the stack level. "Variable preservation" was checked.
Somehow the problem disappeared during my further work on the stack, but unfortunately I cannot pinpoint the cause of this change.
Looking forward to fruitful exchanges in the future.
***
Hans Rijnbout
Utrecht, Netherlands

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7295
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: script local bug or file corruption?

Post by FourthWorld » Fri Jan 17, 2020 5:52 pm

Thanks for the follow-up, Hans.

I recently had a moment in which it appeared the values of my script-local variables were being cleared while editing, even with Variable Preservation set. Unfortunately I've not seen it since, do I don't have a recipe.

My hunch is that there may be a circumstance in which that preference is not taken into account by the Script Editor, and the engine's default if clearing those values comes into effect.

If I see it again and an able to pin down a recipe to file a bug report, I'll post the report link here.
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

LCMark
Livecode Staff Member
Livecode Staff Member
Posts: 1048
Joined: Thu Apr 11, 2013 11:27 am

Re: script local bug or file corruption?

Post by LCMark » Fri Jan 17, 2020 6:20 pm

Variable preservation only works if a script compiles and thus applies to an object successfully - if you apply a script to an object which has a syntax error, the previous values of the variables will be lost.

So if you click the Apply button when the S/E is telling you there is a script error, the values of the script locals will be gone (the S/E uses a hidden button to check the script in the editor is correct and give the 'live error' indication so that doesn't affect the actual object).

This has to be the case because LC does not require scripts to be correct when applied to an object (e.g. you might be half-way through something and want to save it - even if unfinished); and scripts with errors don't have any internal structure (no handlers, no variables) so there's nowhere to hold the previous values.

So whenever you find your script locals have lost their values when you didn't expect them to it will almost certainly be because 'Apply' was clicked in the script editor showing that object's script when there was an error present.

Post Reply

Return to “Bug Triage”