Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   help with large loop (http://www.chiefdelphi.com/forums/showthread.php?t=58902)

SwartMumba 26-09-2007 03:21

help with large loop
 
Can someone please help me to correct my program. I have a variable, LargeNumber. The maximum value that LargeNumber will be is 320000000000, thus I have to declare LargeNumber as Int64. The problem is that the loop does not want to work with my variable, I think because it is declared as Int64. When I try to run the program I get an error message that says, "For Loop control variable must have ordinal type." The following is my Loop:

for Loop := 1 to LargeNumber do
begin

end;

{Since Loop is going to have the same value as LargeNumber, I also declared it as int64}

chris31 26-09-2007 06:54

Re: help with large loop
 
My first questions is, what language are you programming in?

Jack Jones 26-09-2007 07:14

Re: help with large loop
 
Use nested loops, if you have to.

EricS-Team180 26-09-2007 08:22

Re: help with large loop
 
If the compiler accepts LargeNumber as a variable but not as a loop counter, then you could consider using an infinite loop with LargeNumber as a variable that you increment on each pass. Exit the loop when LargeNumber is greater than or equal to the # of passes that you want.

ebarker 26-09-2007 09:21

Re: help with large loop
 
A for loop is a higher level construct of a more primitive algorithm.

You can just implement the base algorithm instead.

The base algorithm has an initializer, a test & branch, the inner block, the incrementer and branch.

One assignment, one test, one arithmetic operator.

Enjoy

Kelly 26-09-2007 20:43

Re: help with large loop
 
With a for loop that large, it sounds like you're trying to create some sort of time delay. Assuming you're writing code for the robot controller, remember that your code is already running in a loop. To create a time delay write code like this:

int counter
.
.
.
while(true)//main loop
{
counter++;
if counter<largeNumber
{
do nothing
}
else
{
do stuff
}
}
If this is for a side project, disregard this comment entirely.

Alan Anderson 26-09-2007 21:23

Re: help with large loop
 
Quote:

Originally Posted by chris31 (Post 643658)
My first questions is, what language are you programming in?

It looks like Pascal, so I'm guessing Delphi.

SwartMumba, this isn't a Delphi programming language forum. Look here for suggestions on better places to look for assistance.

SwartMumba 26-09-2007 23:08

Re: help with large loop
 
Quote:

Originally Posted by chris31 (Post 643658)
My first questions is, what language are you programming in?

Delphi. I thought this was a Delphi forum, www.chiefdelphi.com.


Quote:

Originally Posted by Jack Jones (Post 643659)
Use nested loops, if you have to.

The value of LargeLoop varies, making life hard if you want to nest loops. There should be an easier way.

Quote:

Originally Posted by EricS-Team180 (Post 643660)
If the compiler accepts LargeNumber as a variable but not as a loop counter, then you could consider using an infinite loop with LargeNumber as a variable that you increment on each pass. Exit the loop when LargeNumber is greater than or equal to the # of passes that you want.

I tried that and the Loop crashes at 10000000000 Loops

Quote:

Originally Posted by Alan Anderson (Post 643719)
It looks like Pascal, so I'm guessing Delphi.

SwartMumba, this isn't a Delphi programming language forum. Look here for suggestions on better places to look for assistance.

Oh,okey..


All times are GMT -5. The time now is 00:26.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi