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

apheline

  • Newbie
  • *
  • Posts: 24
Re: Code disappearing on restart
« Reply #15 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 :)

apheline

  • Newbie
  • *
  • Posts: 24
Re: Code disappearing on restart
« Reply #16 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.

Malkom

  • Administrator
  • Newbie
  • *****
  • Posts: 380
  • Here to help you
Re: Code disappearing on restart
« Reply #17 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.

 
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.