HyperNext Studio

HyperNext Studio => Interface Controls => Topic started by: apheline on October 05, 2016, 08:59:22 PM

Title: Code disappearing on restart
Post by: apheline on October 05, 2016, 08: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 :)
Title: Re: Code disappearing on restart
Post by: Malkom on October 06, 2016, 05: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.

Title: Re: Code disappearing on restart
Post by: apheline on October 06, 2016, 05: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.
Title: Re: Code disappearing on restart
Post by: Malkom on October 06, 2016, 06: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.

Title: Re: Code disappearing on restart
Post by: Malkom on October 09, 2016, 09: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 :(
Title: Re: Code disappearing on restart
Post by: apheline on October 20, 2016, 06: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 :)
Title: Re: Code disappearing on restart
Post by: Malkom on October 21, 2016, 05: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.
Title: Re: Code disappearing on restart
Post by: apheline on October 21, 2016, 03:47:12 PM
That's a very good point!
Title: Re: Code disappearing on restart
Post by: apheline 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 :)
Title: Re: Code disappearing on restart
Post by: Malkom 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.
Title: Re: Code disappearing on restart
Post by: apheline 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 :)
Title: Re: Code disappearing on restart
Post by: Malkom 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.


Title: Re: Code disappearing on restart
Post by: apheline 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?
Title: Re: Code disappearing on restart
Post by: apheline 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.
Title: Re: Code disappearing on restart
Post by: Malkom 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.

Title: Re: Code disappearing on restart
Post by: apheline on November 17, 2016, 07:07:15 PM
I have created a new project.  Also, I have tried to do what you say with the @ in front of lines, however, when the error occurs all the code in the entire project is wiped and the project will not save the code anymore.  At this point I must delete that project, copy my blank template project and then paste all the code back into the places where it goes to try again.

It's odd though, because the code will run if I put it in a little at a time, but as soon as all of the code is in it gives me the error.  I've started at the beginning of my code and pasted in a little at a time and it runs fine until the entire code is in.  I've started from the end and gone to the beginning of the code and it runs fine until the beginning is added.  I would think if it were a syntax error of some sort it wouldn't run as soon as that part of the code was put in.

Perhaps I can explain what my code is doing and show you the general format I'm using for it and see if I can get opinions on what might be going on?

I have five groups of 6 buttons that start unpressed but when the user presses them they stay pressed with the following code in the Start Up of the main card:

Code: [Select]
ButtonSetType(X, 0)
ButtonSetValue(X, 0)

where x is 1-30 for each button.

I then have a button which is set to first make the value of some variables 0, then take the values of the buttons and add them to a variable, like so:

Code: [Select]
Put '0' into charX
Put ButtonValueFN(X) into chYdotX

So, the 3rd button in the first group will look like:

Code: [Select]
Put ButtonValueFN(3) into ch1dot3
Then I have code which assigns a value to each button's result (either pushed or unpushed) and adds it to the charx variable.

Code: [Select]
If ch1dot1>0 Then
    add '100000' to char1
EndIf
If ch1dot2>0 Then
    add '20000' to char1
EndIf
If ch1dot3>0 Then
    add '3000' to char1
EndIf
If ch1dot4>0 Then
    add '400' to char1
EndIf
If ch1dot5>0 Then
    add '50' to char1
EndIf
If ch1dot6>0 Then
    add '6' to char1
EndIf

And then that repeats for each group.  After that, the button runs a MainCode Process:

Code: [Select]
Call Search
Search has code which compares the value of charX to a value to determine what text to display in different fields:

Code: [Select]
If char1='000006' Then
    Put 'Something' into field 1
    Put 'Explanation.' into field 2
    Put ' ' into field 3
    Put ' ' into field 4
    Put ' ' into field 5
    Put ' ' into field 6
    Put ' ' into field 7
    Put ' ' into field 8
    Put ' ' into field 9
    Put ' ' into field 10
EndIf

This final part of the code is the part that I believe is causing issues.  I have thousands of these segments for different values of char1 and char2 (I haven't gotten to char 3 yet, since I can't get char2 to work with char1).  Most recently I tried to cut the code up into smaller sections (as mentioned in previous posts) by using:

Code: [Select]
If char2 = 0 AND char3 = 0 AND char4 = 0 AND char5 = 0 then
Call Search
If char1 > 0 AND char1 < 7 AND char2 > 0 AND char3 = 0 AND char4 = 0 AND char5 = 0 then
Call Search2

etc.

This worked fine until all of the code was added into Search1-9.  At this point I got the error I mentioned before.

Not sure if any of this will help, but thought I might as well share and see what I get :)
Title: Re: Code disappearing on restart
Post by: apheline on November 17, 2016, 07:41:45 PM
So, just thought I'd add this little tidbit as well.  When I added all the code and tried to Build Windows rather than Run the project, instead of force closing and giving that error, it said there was an error with my destination for my "char1" variable.  I checked to see if I forgot to put global char1 in my startup and found that startup and all the other Main Processes had disappeared.  So, it may be that what is causing the error when I run is it loads the main processes and then somehow deletes them before opening the program.
Title: Re: Code disappearing on restart
Post by: Malkom on November 17, 2016, 10:07:46 PM

This final part of the code is the part that I believe is causing issues.  I have thousands of these segments for different values of char1 and char2 (I haven't gotten to char 3 yet, since I can't get char2 to work with char1).  Most recently I tried to cut the code up into smaller sections (as mentioned in previous posts) by using:

Code: [Select]
If char2 = 0 AND char3 = 0 AND char4 = 0 AND char5 = 0 then
Call Search
If char1 > 0 AND char1 < 7 AND char2 > 0 AND char3 = 0 AND char4 = 0 AND char5 = 0 then
Call Search2

etc.

This worked fine until all of the code was added into Search1-9.  At this point I got the error I mentioned before.

Not sure if any of this will help, but thought I might as well share and see what I get :)


Thank you so much for this and your very detailed description.

In terms of syntax the only problems I can see are in the block of code above - an IF THEN statement needs an ENDIF to close the block.  Perhaps you already have the ENDIFs but didn't show them.

Code: [Select]
If char2 = 0 AND char3 = 0 AND char4 = 0 AND char5 = 0 then
      Call Search
EndIf
If char1 > 0 AND char1 < 7 AND char2 > 0 AND char3 = 0 AND char4 = 0 AND char5 = 0 then
      Call Search2
EndIf


By the way, your project sounds huge and while I've been converting HN to run on Linux etc using Free Pascal I've noticed some hard limits on the amount of code allowed in a HN project. These are a legacy of when HN had to run on a Mac with 4MB RAM.

I'll have a closer look at this tomorrow but hope this helps.