Well, I am always having problems with my code, can anyone tell me whats wrong? I have left out parts of the code for length sake. In this program, you can save your game and your stats are saved to a list. The problem is, when you exit the program, open it back and load, none of the stats are the same. I'm guessing because of the way I am using the lists... Please help.


Code:

:ClrHome
:0→A
:0→B
:0→C
:0→D
:4→dim(∟CHXL)
:Disp "PIC HERE
:Pause
:ClrDraw
:Lbl A
:ClrHome
:Menu("GAME{-}{-}{-}{-}{-}{-}{-}","NEW GAME",B,"LOAD GAME",C,"INSTRUCTIONS",D,"CREDITS",E,"CONTACT",F,"GAME STATS",G,"QUIT",H)
:Lbl C
:ClrHome
:Input "CODE=",Str1
:If Str1="9754"
:Goto I
:If Str1="4826"
:Goto L
:
:
:If Str1≠"9754" or Str1≠"4826"
:Goto A
:Lbl G
:Disp "DEATH:
:Disp A
:Disp "WON:
:Disp B
:Disp "SAVE:
:Disp C
:Disp "LOAD:
:Disp D
:Pause
:Goto A
:
:Lbl D
:Disp "INSTRUCTIONS HERE
:Pause
:ClrHome
:Goto A
:Lbl B
:A→∟CHXL(1)
:B→∟CHXL(2)
:C→∟CHXL(3)
:D→∟CHXL(4)
:ClrHome
:Disp "STORY
:Pause
:Lbl I
:If Str1="9754"
:Then
:" "→Str1
:∟CHXL(1)→A
:∟CHXL(2)→B
:∟CHXL(3)→C
:∟CHXL(4)→D
:D+1→D
:End
:ClrHome
:Menu("SELECT A PATH{-}{-}{-}","SHORT CUT",J,"LONG WAY",K,"SAVE GAME",θA)
:Lbl θA
:ClrHome
:Disp "9754
:C+1→C
:C→∟CHXL(3)
:Pause
:Goto A
:Lbl J
:ClrHome
:Disp "MORE STORY
:Pause
:Lbl L
:If Str1="4826"
:Then
:" "→Str1
:∟CHXL(1)→A
:∟CHXL(2)→B
:∟CHXL(3)→C
:∟CHXL(4)→D
:D+1→D
:End
:ClrHome
:Menu("DO WHAT?","HIDE",M,"APPROACH MAN",N,"SAVE GAME",θB)
:Lbl θB
:ClrHome
:Disp "4826
:C+1→C
:C→∟CHXL(3)
:Pause
:Goto A
:Lbl N
:ClrHome
:Disp "GAME OVER
:Pause
:A+1→A
:Goto A
Hmm, I didn't really notice anything (though I must say, you're overusing Labels)... let me spend a little more time with it.

Can you post up what happens at Label H (quitting)? Also, after your program is run, what are the contents of ∟CHXL?

I also made a few minimal optimizations:
-Use "DelVar" rather than "0-->"
-Change "Disp 'X':"Pause" to "Pause 'X'"
-Remove unnecessary ClrHomes. If it's cleared before the Menu function, you're fine.

You should consider reworking the structure of the program; at the moment, it's broken into fragments by labels, making it a bit hard to manage/follow properly. It is quite possible that the source of the problem is that parts of your code (specifically, those that store data to the list) are not reached due to mistakes in labels/conditionals/whatever.


Code:

:ClrHome
:DelVar A DelVar B DelVar C DelVar D
:4→dim(∟CHXL)
:Pause "PIC HERE
:ClrDraw
:Lbl A
:ClrHome
:Menu("GAME{-}{-}{-}{-}{-}{-}{-}","NEW GAME",B,"LOAD GAME",C,"INSTRUCTIONS",D,"CREDITS",E,"CONTACT",F,"GAME STATS",G,"QUIT",H)
:Lbl C
:ClrHome
:Input "CODE=",Str1
:If Str1="9754"
:Goto I
:If Str1="4826"
:Goto L
:
:Goto A
:Lbl G
:Disp "DEATH:",A,"WON:",B,"SAVE:",C,"LOAD"
:Pause D
:Goto A
:
:Lbl D
:Pause "INSTRUCTIONS HERE
:Goto A
:Lbl B
:A→∟CHXL(1)
:B→∟CHXL(2)
:C→∟CHXL(3)
:D→∟CHXL(4)
:ClrHome
:Pause "STORY
:Lbl I
:If Str1="9754"
:Then
:" "→Str1
:∟CHXL(1)→A
:∟CHXL(2)→B
:∟CHXL(3)→C
:∟CHXL(4)→D
:D+1→D
:End
:ClrHome
:Menu("SELECT A PATH{-}{-}{-}","SHORT CUT",J,"LONG WAY",K,"SAVE GAME",θA)
:Lbl θA
:C+1→C
:C→∟CHXL(3)
:Pause "9754
:Goto A
:Lbl J
:Pause "MORE STORY
:Lbl L
:If Str1="4826"
:Then
:" "→Str1
:∟CHXL(1)→A
:∟CHXL(2)→B
:∟CHXL(3)→C
:∟CHXL(4)→D
:D+1→D
:End
:ClrHome
:Menu("DO WHAT?","HIDE",M,"APPROACH MAN",N,"SAVE GAME",θB)
:Lbl θB
:C+1→C
:C→∟CHXL(3)
:Pause "4826
:Goto A
:Lbl N
:ClrHome
:Pause "GAME OVER
:A+1→A
:Goto A
While looking at your code I realized that you use Strings to store a numerical value. Why not use a fifth list element? If String1 is archived you're SOL. Just use a list like ∟CHXLC(1) or ∟CHXL(5)... Smile

I'll keep looking at your program.
rthprog wrote:
Hmm, I didn't really notice anything (though I must say, you're overusing Labels)... let me spend a little more time with it.


Yeah, that's how I am, lol. Very Happy

rthprog wrote:

Can you post up what happens at Label H (quitting)? Also, after your program is run, what are the contents of ∟CHXL?


Nothing, it just clears screen and quits. As for the list, when you start a new game, the values are all 0. When you load, it restores the values saved previously to that list.

When the program starts back and I load, it is almost like it "resets" the values.

rthprog wrote:

I also made a few minimal optimizations:
-Use "DelVar" rather than "0-->"
-Change "Disp 'X':"Pause" to "Pause 'X'"
-Remove unnecessary ClrHomes. If it's cleared before the Menu function, you're fine.


Thanks

rthprog wrote:

You should consider reworking the structure of the program; at the moment, it's broken into fragments by labels, making it a bit hard to manage/follow properly. It is quite possible that the source of the problem is that parts of your code (specifically, those that store data to the list) are not reached due to mistakes in labels/conditionals/whatever.


Man... that sounds daunting, my whole program is over 12KB, I only posted this sample fragment.

I believe the problem is where I am putting the list equals stuff, does that make sense?
comicIDIOT wrote:
While looking at your code I realized that you use Strings to store a numerical value. Why not use a fifth list element? If String1 is archived you're SOL. Just use a list like ∟CHXLC(1) or ∟CHXL(5)... Smile

I'll keep looking at your program.


Yeah that would get rid of excess memory, thanks.
xXEpicxXXxFailXx wrote:
Nothing, it just clears screen and quits. As for the list, when you start a new game, the values are all 0. I can't get the values to save onto the list because when the program starts back and I load, it is almost like it "resets" the values.


Likely the culprit.

Code:
4→dim(∟CHXL)
comicIDIOT wrote:
xXEpicxXXxFailXx wrote:
Nothing, it just clears screen and quits. As for the list, when you start a new game, the values are all 0. I can't get the values to save onto the list because when the program starts back and I load, it is almost like it "resets" the values.


Likely the culprit.

Code:
4→dim(∟CHXL)


Your saying that it is probably resetting itself because it keeps reformatting the list at the beginning, right? This could be fixed with a sub-routine easily.
xXEpicxXXxFailXx wrote:
Your saying that it is probably resetting itself because it keeps reformatting the list at the beginning, right?
Correct. Since you have the list made, remove that line and if your list isn't cleared when you run the program, You've found your problem Smile
Thanks you guys, that fixed it all!
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement