Recovering a corrupted script

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

MaxV
Posts: 1580
Joined: Tue May 28, 2013 2:20 pm
Contact:

Recovering a corrupted script

Post by MaxV » Wed Jun 05, 2013 10:06 am

Hello,
I made an error on my scientific calculator script, I wanted to load some values on booting, so I decided to use on openStack message. Bad idea!
I couldn't open the script anymore, it always crashed the C++ runtime enviroment.
So I opened it with a simple text editor and I removed manually the openStack script part.
Now LiveCode says that file is corrupted, probably LiveCode add a signature or byte check in the file, because I didn't change the binary part, so it isn't really corrupted.
How can I recover the file?
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Recovering a corrupted script

Post by Simon » Wed Jun 05, 2013 10:35 am

Hi Max,
In the Development dropdown select Suspend Development Tools before opening your stack.
I think, not sure what "it always crashed the C++ runtime enviroment" means :)

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

MaxV
Posts: 1580
Joined: Tue May 28, 2013 2:20 pm
Contact:

Re: Recovering a corrupted script

Post by MaxV » Wed Jun 05, 2013 10:56 am

Simon, it ask me for a backup file, where are backup files?
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Recovering a corrupted script

Post by Klaus » Wed Jun 05, 2013 11:36 am

Hi Max,
MaxV wrote:So I opened it with a simple text editor and I removed manually the openStack script part.
Now LiveCode says that file is corrupted, probably LiveCode add a signature or byte check in the file, because I didn't change the binary part, so it isn't really corrupted.
well, you opened, modified and saved a BINARY file with a simple TextEditor! 8-)
As a result the stack is now corrupted and useless.

Do you have a backup of that file?

To suppress all messages, "openstack" in your case, and open that namely stack, enter this into the messagebox:
lock messages;go stack "Path/to/your/stack.livecode"

This way all the scripts will NOT trigger and you can fix your error(s).


Best

Klaus

MaxV
Posts: 1580
Joined: Tue May 28, 2013 2:20 pm
Contact:

Re: Recovering a corrupted script

Post by MaxV » Wed Jun 05, 2013 12:17 pm

Klaus,
I couldn't open anymore my script, it crashed all livecode IDE every time. (all IDE collapsed saying runtime c++ error)
So I had to remove the guilty text part.
Is there any recover tool?
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Recovering a corrupted script

Post by Klaus » Wed Jun 05, 2013 12:25 pm

You corrupted the stack by editing it with a TextEditor, no matter why you did this, but you cannot use this stack anymore.
And not, there are no recover tools, I'm afraid.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10052
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Recovering a corrupted script

Post by FourthWorld » Wed Jun 05, 2013 3:08 pm

If this problem occurred with LC 6.0.1, it may be an engine bug that was fixed with LC 6.0.2. That will at least prevent the issue from happening again.

For recovery, if you didn't save the stack while it showed the corrupted script it's probably still in good shape, and likely can be opened in 6.0.2 to resume working as normal.

If you had saved the stack while the script was displaying as corrupted, that script has then been replaced with the corrupted data, and unfortunately I don't believe there's a way to recover it.

I should note here that one of the reasons I've enjoyed LC for so many years is that file corruption is unusually rare. I've only personally experience file corruption myself once since 1997, and have only heard of fewer than half a dozen true cases of file corruption in that span. The way LS writes to disk - as a complete file rather than paging, and with an automatic backup until the write is done and the format verified - generally avoids the sort of corruption issues that have plagued so many other programs over the years, from HyperCard to FileMaker and more.

So while it's disappointing to lose work to corruption, I think you'll find that it's not only a very rare occurrence, but also the sort of thing that the engine team will jump on immediately once they receive a recipe for how the corruption occurred, as was the case with the script corruption I discovered in 6.0.1.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Recovering a corrupted script

Post by Klaus » Wed Jun 05, 2013 3:12 pm

Richard,

sometimes it really helps if you read all posts before you answer 8-)
So I opened it (the STACK) with a simple text editor and I removed manually the openStack script part.
:-)


Best

Klaus

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10052
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Recovering a corrupted script

Post by FourthWorld » Wed Jun 05, 2013 3:36 pm

Thanks, Klaus, but that still leaves us with the mystery of how the corruption occurred, and how to prevent it going forward.

If this happened in 6.0.1, I'd still be interested in learning more about how it happened, since I spent considerable time trying to come up with a concise recipe and couldn't; ultimately the recipe I submitted had far more steps than I would have preferred.

And if it happened with an earlier version, the fix in 6.0.2 may or may not resolve the problem going forward.

So while I'm glad the script was recovered, I'm still not sure why the IDE wouldn't open the stack or how we can prevent this from happening again.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Recovering a corrupted script

Post by Klaus » Wed Jun 05, 2013 4:09 pm

Hi Richard,
FourthWorld wrote:Thanks, Klaus, but that still leaves us with the mystery of how the corruption occurred, and how to prevent it going forward.
hmmmm....

1. Max had a handler in the OPENSTACK script that caused an error!
2. So he opened that stack with a TextEditor and deleted that hanlder of the TEXT IN the TextEditor!?
3. Then he obviously SAVED that stack also IN the TextEditor.

THAT IS how the corruption occurred! Livecode NOT involved!
Get the picture now? 8-)


Best

Klaus

MaxV
Posts: 1580
Joined: Tue May 28, 2013 2:20 pm
Contact:

Re: Recovering a corrupted script

Post by MaxV » Wed Jun 05, 2013 4:52 pm

Wait a minute, however the original livecode file could not be opened anymore:
  • I'm on Windows
  • I doubled click on my script
  • a warning window said me: "C++ runtime error, contact RunRev"
  • I tried to comment comment some lines in file with the original livecode inside the OpenStack message with a text editor, and I succeded to open it with LiveCode 6.0.1
  • however I didn't comment all lines inside the OpeStack and the IDE crashed again when I saved
  • I double click on my script
  • a warning window said me: "C++ runtime error, contact RunRev"
  • I tried to remove the on OpenStack part of my script with a text editor
  • I get corrupted file when I try to open it
It seems the liveCode file format preserve the Script code as is. So I "manually" recovered my script with copy and paste, but if could find livecode file format, I could write a file recover.
My first impression of livecode file format is like a binary array.
Where are livecode file specification?
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Recovering a corrupted script

Post by Klaus » Wed Jun 05, 2013 4:59 pm

Hi Max,
MaxV wrote:Wait a minute, however the original livecode file could not be opened anymore:
  • I'm on Windows
  • I doubled click on my script
Did you try to open the stack NOT by doubleclicking on the desktop but as I described in my earlier post?
That's the way to go with these kind of problems (script error preventing correct opening of stack)
MaxV wrote:My first impression of livecode file format is like a binary array.
No idea, at least it is a BINARY format which you wrecked by modifying and saving it in a TEXT editor 8-)
MaxV wrote:Where are livecode file specification?
Don't know, you better ask RunRev, if they provide this specifications (at all).

Best

Klaus

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10052
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Recovering a corrupted script

Post by FourthWorld » Wed Jun 05, 2013 5:01 pm

What did the folks at RunRev say when you contacted them?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Recovering a corrupted script

Post by Klaus » Wed Jun 05, 2013 5:28 pm

Hi Richard,

LOTS of work in the moment?
Take a break :-)


Best

Klaus

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Recovering a corrupted script

Post by jacque » Wed Jun 05, 2013 6:39 pm

As an aside, if you don't want messages sent when you open the stack, click the Messages icon in the toolbar. If it is bolded, it means no messages will occur. This is a short way to do what Klaus suggested, it's the same as putting "lock messages" into the message box, but you don't need to type anything.

You are correct that a checksum is stored and if you change the stack outside of LiveCode it will be corrupted and can't be opened. The next time, lock the messages and open your stack from inside LiveCode as Klaus said. That usually works.

Also, back up your work. :)
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply