Gamestudio Links
Zorro Links
Newest Posts
Executing Trades on Next Bar Open
by vicknick. 06/13/24 08:51
Zorro Beta 2.61: PyTorch
by jcl. 06/10/24 14:42
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (Ayumi), 1,170 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19059 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
While loop speed question #314058
03/05/10 13:53
03/05/10 13:53
Joined: Mar 2007
Posts: 112
MikeS Offline OP
Member
MikeS  Offline OP
Member

Joined: Mar 2007
Posts: 112
Hi guys.

I do have an Question about while loops.

if i have an while loop like this:

Code:
while(!anyvar)
{do something }



without an wait(1) in it, does this while loop repeat faster than 1 frame?
If yes, how fast is it repeated? (roundabout)
And such an while loop would not give an possible endless loop error, is that right too?

greetings Mike

Re: While loop speed question [Re: MikeS] #314059
03/05/10 13:59
03/05/10 13:59
Joined: Jan 2004
Posts: 3,023
The Netherlands
Helghast Offline
Expert
Helghast  Offline
Expert

Joined: Jan 2004
Posts: 3,023
The Netherlands
it can give you a possible loop error!
it will run as long as the anyvar is not zero (which can be more then 1000 times in one frame).

hope that helps,
regards


Formerly known as dennis_fantasy
Portfolio - http://www.designorhea.com/
Project - http://randomchance.cherrygames.org/
Re: While loop speed question [Re: Helghast] #314061
03/05/10 14:06
03/05/10 14:06
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
function main() {
var i = 0;
double j;
while(!key_e) { wait(1); }
timer();
while(i < 999999) {
i++;
}
j = timer();
printf("Time: %f",j);
}

This returns a value of 3625 microseconds for me and means
3625 * 1/1000000 sec = 0,003625 sec.
Divide it by 999999 and you have the speed.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: While loop speed question [Re: Superku] #314063
03/05/10 14:15
03/05/10 14:15
Joined: Aug 2007
Posts: 1,922
Schweiz
Widi Offline
Serious User
Widi  Offline
Serious User

Joined: Aug 2007
Posts: 1,922
Schweiz
The variable max_loops is set as default by 5000. You can make it higher for more passes in the whileloop without a wait.

Re: While loop speed question [Re: Widi] #314064
03/05/10 14:30
03/05/10 14:30
Joined: Mar 2007
Posts: 112
MikeS Offline OP
Member
MikeS  Offline OP
Member

Joined: Mar 2007
Posts: 112
@ Helghast: Yep that helped. Thanks

@ Superku: Hei, that really fast :-) Thanks

@Widi: Ah, cool, didint know there is such an var. cool. Thanks.

Thanks to all, that was exactly what i wanted to know :-)

Re: While loop speed question [Re: MikeS] #314067
03/05/10 14:52
03/05/10 14:52
Joined: Oct 2004
Posts: 4,134
Netherlands
Joozey Offline
Expert
Joozey  Offline
Expert

Joined: Oct 2004
Posts: 4,134
Netherlands
Cool widi, never thought of that laugh thanks.


Click and join the 3dgs irc community!
Room: #3dgs
Re: While loop speed question [Re: Joozey] #314070
03/05/10 15:05
03/05/10 15:05
Joined: Dec 2008
Posts: 271
Saturnus Offline
Member
Saturnus  Offline
Member

Joined: Dec 2008
Posts: 271
I'm very sure that max_loops is for C-Script only. It doesn't have any relevance in lite-C anymore.

Re: While loop speed question [Re: Saturnus] #314071
03/05/10 15:13
03/05/10 15:13
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Originally Posted By: Saturnus
I'm very sure that max_loops is for C-Script only. It doesn't have any relevance in lite-C anymore.

Exactly!


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: While loop speed question [Re: Superku] #314127
03/05/10 21:28
03/05/10 21:28
Joined: Aug 2007
Posts: 1,922
Schweiz
Widi Offline
Serious User
Widi  Offline
Serious User

Joined: Aug 2007
Posts: 1,922
Schweiz
Ooops, you`re right. I make a test, it is only for C-Script.

Re: While loop speed question [Re: Widi] #314129
03/05/10 21:34
03/05/10 21:34
Joined: Oct 2004
Posts: 4,134
Netherlands
Joozey Offline
Expert
Joozey  Offline
Expert

Joined: Oct 2004
Posts: 4,134
Netherlands
Oh blimey grin


Click and join the 3dgs irc community!
Room: #3dgs

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1