Author Topic: Code disappearing on restart  (Read 18622 times)

apheline

  • Newbie
  • *
  • Posts: 24
Code disappearing on restart
« on: October 05, 2016, 09:59:22 PM »
So, I have a button on my card which is doing most of the work as far as code is concerned.  I have noticed that every few times I reopen my project the code will be completely gone.  The first time this happened, I lost about 4 days of coding, which was extremely frustrating.  Since then I've begun to write all of my code in a .txt document and copy and paste it into the button to test it out.  The issue I'm now having is the code disappears in between compiling and running, so when I hit run, it compiles okay, but the button does nothing because the code has been deleted.

If I create a new button, the code works fine for a while, and then that button starts to have its code deleted as well.  So I now have 4 buttons that don't work when I run the program no matter what code I put in them (and one that performs a Goto function even though there is no code in it and no Goto selected in its "Main" properties tab.

For now it isn't a big deal, because I can just keep making buttons that work for a few test runs, but I wonder what the end program will end up being like with lots of buttons being created and deleted all the time.

Thanks for any advice on this :)

Malkom

  • Administrator
  • Newbie
  • *****
  • Posts: 461
  • Here to help you
Re: Code disappearing on restart
« Reply #1 on: October 06, 2016, 06:34:24 AM »
This clearly a major bug -  I've never seen or had this reported before.

Which platform and Operating System are you using?
I'm assuming you use HyperNext 4.x

Also, when HN Creator open up - I'm assuming that you created a new project using the File - New menu option?

By the way, when I work with HN projects, I always keep the project folder open, and every so often just duplicate the project file so in the event of a problem occurring or a change of mind then can easily revert.
I do this with some other programming languages to.

I am sorry but I do not have time to answer questions by PM or email.
If you post your questions in this forum then it might help others.

apheline

  • Newbie
  • *
  • Posts: 24
Re: Code disappearing on restart
« Reply #2 on: October 06, 2016, 06:19:46 PM »
I'm using Windows 10 and HyperNext Creator 4.01.  After messing around with it a little more, it seems that it may be an issue of not being able to save and reverting back to the last copy.  As far as I can tell, when you hit Run, the program autosaves after compiling and then runs the project.  I've noticed that sometimes even when I hit the save button my changes are not being saved.  So perhaps that's the root of my problem, although, it wouldn't explain why the code just disappears entirely when the last save had code in it before.

Malkom

  • Administrator
  • Newbie
  • *****
  • Posts: 461
  • Here to help you
Re: Code disappearing on restart
« Reply #3 on: October 06, 2016, 07:25:58 PM »
I'm using Windows 10 and HyperNext Creator 4.01.  After messing around with it a little more, it seems that it may be an issue of not being able to save and reverting back to the last copy.  As far as I can tell, when you hit Run, the program autosaves after compiling and then runs the project.  I've noticed that sometimes even when I hit the save button my changes are not being saved.  So perhaps that's the root of my problem, although, it wouldn't explain why the code just disappears entirely when the last save had code in it before.

Thank you for the details - its given me something to go on. Over the weekend I'll get it tested on Windows 10 with the HN 4.01 source code and debugger - hopefully will show the point when the script code vanishes from the button - then it can be tracked down. You are right about the Run behaviour - it does autosave after the Run button is pressed.

I am sorry but I do not have time to answer questions by PM or email.
If you post your questions in this forum then it might help others.

Malkom

  • Administrator
  • Newbie
  • *****
  • Posts: 461
  • Here to help you
Re: Code disappearing on restart
« Reply #4 on: October 09, 2016, 10:29:10 AM »
I'm sorry but I cannot reproduce the bug - been testing on Windows 10.

I've tried multiple cards, with multiple objects on. Also several saves, and with the Script Editor open tried clicking different objects.

Perhaps this is some random bug or needs a particular event to trigger it.

If you are still having problems, perhaps you could email me a zipped broken project as it might help track the bug down - info@tigabyte.com.

Just noticed a bug in Save As  from the Creator File menu :(
I am sorry but I do not have time to answer questions by PM or email.
If you post your questions in this forum then it might help others.

apheline

  • Newbie
  • *
  • Posts: 24
Re: Code disappearing on restart
« Reply #5 on: October 20, 2016, 07:40:02 PM »
I've just been keeping my code in a text file and copying and pasting it in the blank project to test it.  That seems to be working fine :)

Malkom

  • Administrator
  • Newbie
  • *****
  • Posts: 461
  • Here to help you
Re: Code disappearing on restart
« Reply #6 on: October 21, 2016, 06:10:06 AM »
its clearer now - thank you for the update :)

Just an thought - clearly you already know that the blank project doesn't save any changes - but some others probably don't know this.

For persistant work - just create a new project using the File menu - option New.
« Last Edit: October 21, 2016, 07:42:40 AM by Malkom »
I am sorry but I do not have time to answer questions by PM or email.
If you post your questions in this forum then it might help others.

apheline

  • Newbie
  • *
  • Posts: 24
Re: Code disappearing on restart
« Reply #7 on: October 21, 2016, 04:47:12 PM »
That's a very good point!

apheline

  • Newbie
  • *
  • Posts: 24
Re: Code disappearing on restart
« Reply #8 on: November 01, 2016, 09:28:11 PM »
Okay, so I have pinpointed a possible source of the problem.  Sometimes during the compile process, I get the following string of errors:

"Sorry, an internal error has occured : LoadMemBlockNum"
"Sorry, an internal error has occured : Compiler: Pass2_KWs1to10FN"

After this, the program forcibly closes.

When I reopen, all code is gone and when I re-paste the code from my notes, buttons don't seem to function properly.

Still not sure why this error occurs sometimes and not other times, but I figured I'd let you know :)

Malkom

  • Administrator
  • Newbie
  • *****
  • Posts: 461
  • Here to help you
Re: Code disappearing on restart
« Reply #9 on: November 02, 2016, 12:35:28 PM »
Okay, so I have pinpointed a possible source of the problem.  Sometimes during the compile process, I get the following string of errors:

"Sorry, an internal error has occured : LoadMemBlockNum"
"Sorry, an internal error has occured : Compiler: Pass2_KWs1to10FN"

After this, the program forcibly closes.

When I reopen, all code is gone and when I re-paste the code from my notes, buttons don't seem to function properly.

Still not sure why this error occurs sometimes and not other times, but I figured I'd let you know :)

Thank you do much for this - it gives us something to go on. Although sorry I don't have a definite fix for it yet.

It looks like the compiler crashes after failing to compile one of your script commands - the LoadMemBlockNum expects to find an integer for the command but finds something else and fails, and then causes the compiler keyword handler to fail, so crashing HN.

In the past I've tried to put better error handling around these Compiler: Pass2_KWsXXXXX but they cause HN to freeze solid and not quit.

I'll try to identify which command it might be and have a further look into the compiler.
I am sorry but I do not have time to answer questions by PM or email.
If you post your questions in this forum then it might help others.

apheline

  • Newbie
  • *
  • Posts: 24
Re: Code disappearing on restart
« Reply #10 on: November 07, 2016, 04:21:09 PM »
Could it be because I am using ASCII text for some text I'm putting into fields?  I've been playing around with it, trying to find out what causes the error and it seems to compile okay outside of the ASCII.  Or it may just be a string of bad code in the same block of code as the ASCII.  I'll keep looking :)

Malkom

  • Administrator
  • Newbie
  • *****
  • Posts: 461
  • Here to help you
Re: Code disappearing on restart
« Reply #11 on: November 07, 2016, 09:10:50 PM »
Could it be because I am using ASCII text for some text I'm putting into fields?  I've been playing around with it, trying to find out what causes the error and it seems to compile okay outside of the ASCII.  Or it may just be a string of bad code in the same block of code as the ASCII.  I'll keep looking :)

Thank you for this :)

You might be right, it should accept ASCII but perhaps a bad character was in the block - or a bug in my coding.

HN uses UTF-8 encoding so should accept non english characters, eg Russian, Japanese etc - I've tested these along with a few others and it worked fine but there still might be a problem.

Such a pity the crash doesn't allow the project to save otherwise I could have loaded it into  the debugger.


I am sorry but I do not have time to answer questions by PM or email.
If you post your questions in this forum then it might help others.

apheline

  • Newbie
  • *
  • Posts: 24
Re: Code disappearing on restart
« Reply #12 on: November 14, 2016, 07:37:21 PM »
Okay, I have even more information :)  So, I ran the offending code in blocks.  Each block of code compiled without problem, however, as soon as I put them all together again I got a LoadMemBlockNum internal error again and a crash.  This pretty much rules out non-english/ASCII characters causing the issue.   I've tried both putting the code directly into the button's script and into main code processes and calling them from button press with the same results.

My idea of what is causing the problem now is this: is there a character/length limit for Main Code Processes/Scripts for buttons?  I have a substantial amount of code in this script (201,706 characters/6,445 lines).  Could this be causing the issue?

apheline

  • Newbie
  • *
  • Posts: 24
Re: Code disappearing on restart
« Reply #13 on: November 14, 2016, 08:01:52 PM »
Okay, so, I just tried putting all the code into different processes and making a code to determine which one to run (depending on the value of the variable).  I made each section no longer than the section I know works by itself.  I got the same error I was getting before (LoadMemBlockNum).  So, looks like there's maybe too much code altogether?  I'm not sure.  Kind of running out of ideas at this point.

Malkom

  • Administrator
  • Newbie
  • *****
  • Posts: 461
  • Here to help you
Re: Code disappearing on restart
« Reply #14 on: November 14, 2016, 09:08:20 PM »
Okay, so, I just tried putting all the code into different processes and making a code to determine which one to run (depending on the value of the variable).  I made each section no longer than the section I know works by itself.  I got the same error I was getting before (LoadMemBlockNum).  So, looks like there's maybe too much code altogether?  I'm not sure.  Kind of running out of ideas at this point.
Thank you for your feedback on this - such a bug could actually drive one crazy.

To me it seems most likely that there is a syntax error in your code somewhere and due to a bug in the compiler its not being caught properly.

There shouldn't be problems with too much code together as there are some limit checks that would give you a warning when an attempt was made to the extra line.


My advice, somehow try to find where the syntax error is. Two ways:

1/ Your current method for splitting things up - perhaps you could gradually remove blocks of code until the error stops or increase the amount of code until the error appears.

2/ In front of every line of code place a comment symbol @ and then gradually remove them until the error appears.

Looking at the error you have - the syntax error could be in any one of a hundred or so keywords - so it doesn't really narrow it down enough to help you.

The Language Reference and built in Help often don't fully describe acceptable syntax for some keywords so if you are not sure about something perhaps you could just post it here.

By the way. I forget but have you now created a new project and are saving your code in that because as mentioned earlier the card that appears when HyperNext Creator starts up isn't meant to be used for a permanent project.

I am sorry but I do not have time to answer questions by PM or email.
If you post your questions in this forum then it might help others.