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.

Newcomers DBPro Corner / Something wrong with computer? Program hanging.

Author
Message
Somarl
11
Years of Service
User Offline
Joined: 11th Feb 2011
Location: UK
Posted: 25th Oct 2013 11:51
Im not sure if this code is just wrong or if there is something wrong with my computer as this code struggles to be consistant.



Most times it will not get above 1, sometimes it gets to about 4 and only once has it reached 10. Each time i run it i cant predict what number it will hang on. Surely this is a problem with my computer?
Dia
17
Years of Service
User Offline
Joined: 16th Jan 2005
Location:
Posted: 25th Oct 2013 15:18 Edited at: 25th Oct 2013 21:50
First off, your clock() function doesn't actually do anything.
The 'Time' variable inside that function is local, so doesn't get updated by your main loop, and by default = 0. This means that the first logic check inside the function is always

IF Timer() = 0 + 1000

(I think at the moment my Timer() reads in the 868-millions!) So it will never be true

However, given that you are running exactly the same code in the main loop means that the main loop 'Time' variable is being updated properly - it just means you can delete the Clock() call you have after the CLS, along with the whole Clock() function

As far as the actual problem counting up goes: I wasn't able to consistently replicate the issue, but I 'think' the problem is that your logic check is aiming for an 'exact' figure, i.e. IF TIMER() = TIME + 1000 - This makes it extremely sensitive to any hiccups in the looping rate.

i.e. if at the beginning of your code TIMER() may return 868000123, and dutifully assign that value to the 'Time' variable

999 milliseconds later, the TIMER() may = 868001122, and if there is much as a millisecond hiccup in your system, in the next loop the TIMER() value may jump from 868001122 to 868001124 -meaning that TIMER() never = Time + 1000, and hence nothing happens inside your IF ENDIF statement, which basically locks your time variable for, well, all time - this happened to me more frequently when I ran more processes in the background, hard drive kicking over, antivirus starting etc

try running a relative logic check, rather than an absolute (i.e. check if timer() is greater than, rather than directly equal the Time+1000 value)



unless you are worried about millisecond accuracy in your program...

I also chucked in the lines to display TIMER() and TIME + 1000, so you can see when the TIME variable fails to get updated

This is not the Sig you are looking for....
Somarl
11
Years of Service
User Offline
Joined: 11th Feb 2011
Location: UK
Posted: 26th Oct 2013 11:25
Oh this is great. I used to be able to get clocks working all the time but ive been getting rusty and thought id have another dabble but because it wasnt working a part of me thought it might be the crappy computer i was using at work. I am glad to know its the code and how to solve it because i want to use the work computer to test a few things out.

Thank you for your help.

Login to post a reply

Server time is: 2022-06-27 07:13:33
Your offset time is: 2022-06-27 07:13:33