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 Professional Discussion / wayward incrementation

Author
Message
Jedi Padawan
17
Years of Service
User Offline
Joined: 17th Jun 2009
Location: None of your business
Posted: 16th Mar 2010 06:22
whenever I put in this code in my program:



, instead of incrementing by 1, it adds up by 69 or 37, whatever suits its mood.

Does it have something to do with sync rate?

Benjamin
23
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 16th Mar 2010 06:34
Without seeing the rest of your code it's hard to tell. I'm guessing you're running this code every loop, which means after a short amount of time it can be a very high value (half a second at 60fps would increment it by 30).
Jedi Padawan
17
Years of Service
User Offline
Joined: 17th Jun 2009
Location: None of your business
Posted: 16th Mar 2010 06:35
here is the same thing in a shorter form:



Benjamin
23
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 16th Mar 2010 06:38
I'm not sure I understand what you're trying to do regarding the timer code. Could you explain?
Jedi Padawan
17
Years of Service
User Offline
Joined: 17th Jun 2009
Location: None of your business
Posted: 16th Mar 2010 06:42
when I run the program, the output is like this

"
1
2
3
...
19
19
19...
"
At 19, or 18 or even 12, in continues spouting the same number for quite a while.
Then it continues incrmenting normally. However, at 39 or 40 etc it does the repeating thing again.

Kevin Picone
23
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 16th Mar 2010 06:43
I think it's meant to be incrementing every 5 seconds.

Benjamin
23
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 16th Mar 2010 06:44 Edited at: 16th Mar 2010 06:47
Well, explain what you are trying to do. It seems like you're trying to count every 5 seconds, or something along those lines?

[edit] What it's doing is updating the counter every frame on a second that is a multiple of 5. But what's it meant to be doing?
Jedi Padawan
17
Years of Service
User Offline
Joined: 17th Jun 2009
Location: None of your business
Posted: 16th Mar 2010 06:48
yep

in the full program, every 5 seconds, data in an array is stored. But with this problem, it defeats the purpose

Jedi Padawan
17
Years of Service
User Offline
Joined: 17th Jun 2009
Location: None of your business
Posted: 16th Mar 2010 06:49
Benjamin: I am not sure what you mean by your edit

Benjamin
23
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 16th Mar 2010 06:54 Edited at: 16th Mar 2010 06:55
Well, you are getting the number of seconds elapsed and then saying "during every 5th second increment this variable". It'll increment until it counts another second. Try this:



Note that you should avoid using GOTO and instead use structured loops (such as DO/LOOP), and also I noticed you tried assigning 0 to timer which isn't allowed as it's a function.
Jedi Padawan
17
Years of Service
User Offline
Joined: 17th Jun 2009
Location: None of your business
Posted: 16th Mar 2010 07:09 Edited at: 16th Mar 2010 07:09
thanks for that. Now I have a different problem. The program is not putting in data to the array. Here is the code



I have already declared the array at the beginning - dim timeinc$(12)

Benjamin
23
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 16th Mar 2010 07:12
You're jumping to 'printing', meaning any code directly after that won't get executed.
Jedi Padawan
17
Years of Service
User Offline
Joined: 17th Jun 2009
Location: None of your business
Posted: 16th Mar 2010 21:19
i feel dumb

Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 17th Mar 2010 16:09
Quote: "i feel dumb"

You should using goto's IMO

My signature is NOT a moderator plaything! Stop changing it!
Jedi Padawan
17
Years of Service
User Offline
Joined: 17th Jun 2009
Location: None of your business
Posted: 17th Mar 2010 21:17
IMO? what does that mean?

Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 18th Mar 2010 02:44
In My Opinion.



My signature is NOT a moderator plaything! Stop changing it!
Jedi Padawan
17
Years of Service
User Offline
Joined: 17th Jun 2009
Location: None of your business
Posted: 18th Mar 2010 02:51
ah

Login to post a reply

Server time is: 2026-07-27 05:11:05
Your offset time is: 2026-07-27 05:11:05