Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / Array problems

Author
Message
Flamertor
8
Years of Service
User Offline
Joined: 12th Oct 2011
Location:
Posted: 11th Dec 2011 10:04
I've been trying to get this peice of code working but it won't becuase the save array is in the wrong place snf i don't know where to put it, so can someone please find the right place. Thank you.



It's the PScore array which have the problem.
Thanks again for looking.
Latch
14
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 11th Dec 2011 17:52
Hello,

You have to be careful when saving or loading arrays. The first thing to keep in mind, before you SAVE or LOAD and array, you must make sure you have DIMensioned the array in your program.

For example, if I wanted to save an array named myarray, I'd have to create it (DIM it) first:



The same thing applies when I load the array. The array must exist in my code before I load it:



Also notice that when I load the array, I have to include the first dimensioned index : (10) .

This is important for both loading and saving an array. Even if I have a multidimensioned array, I have to include the first dimension:



I haven't gone through all of your code (it needs a bit of organization and has a lot of jumping with GOTOs that is hard to follow), but I did notice right off the bat that your Check_Stats array seems to attempt to load the PScore array without it being dimensioned previously, and also without adding the first dimension.

Your Code:



An apparent fix for this could be



But if there are other errors in the body of your code, your program may still not behave as you expect.

Enjoy your day.
Flamertor
8
Years of Service
User Offline
Joined: 12th Oct 2011
Location:
Posted: 11th Dec 2011 18:55
I've being trying to attempt to make a save game kind of thing and this is what i ended making and thanks for your time. Do you know how to make it save your score for next time you load it up.
Latch
14
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 12th Dec 2011 23:14
Quote: "Do you know how to make it save your score for next time you load it up"

Sure.

Here's a generic save score routine. The comments in it should help you understand what it is doing. Basically, it allows for 10 saved scores. You can clear them, save them, and load them. If the score table is full, it allows you to choose a slot replace one of the saved scores with a new one.

This code is general enough that one could expand it to save whatever they want, as long as they manage the arrays and variables.

So look it over, try it out, and see if it makes sense to you. The real work horse is the _load_save_scores subroutine.

The layout of this code should also give you an idea of how you can get rid of most, if not all, of those gotos in your code and use subroutines that gosub and return from blocks of code - making it a little easier to follow the path and logic flow.



Enjoy your day.
Flamertor
8
Years of Service
User Offline
Joined: 12th Oct 2011
Location:
Posted: 13th Dec 2011 17:33
Im a bit confused by this, but im still looking at it. Could you show it with my code in it please. It may help me. Thxs again for your time and reponce.
Latch
14
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 16th Dec 2011 00:42
Quote: "Could you show it with my code in it please"

Sorry, I can't quite spend the time to go through all of your code.

Here's some pointers when trying to implement your save routine:

1. Are you keeping score? If so it's likely stored in a variable. You'll use the value in this variable to save.

2. Have some kind of key press control that jumps to your save routine:



That's basically the bare bones of how to do it. The code I posted before is a save and load routine that stores up to 10 previously saved scores. You don't need anything as complicated as that. The code right above is basically psuedo code but works if you can understand how to place it in your game.

Enjoy your day.
Flamertor
8
Years of Service
User Offline
Joined: 12th Oct 2011
Location:
Posted: 17th Dec 2011 09:34
thanx you very much. I'll let you know if I need anymore help, if thats ok for you.
Latch
14
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 28th Dec 2011 00:52
No problem

Enjoy your day.
Flamertor
8
Years of Service
User Offline
Joined: 12th Oct 2011
Location:
Posted: 31st Dec 2011 10:52
I thought I knew howto fix it but i was wrong. Again . Also I just want it so it always show the score because it's your money so I just want one that keep being saved over again and again.

Login to post a reply

Server time is: 2020-08-15 12:51:57
Your offset time is: 2020-08-15 12:51:57