Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Converting BASIC to Delphi 7 Problem

Status
Not open for further replies.

BillKilgore

Programmer
Mar 17, 2002
60
US
Hello All,

I've been engaged in translating some Basic applications into Delphi 7. I got to a triple-nested set of For loops in Basic and the innermost loop had a 'STEP' specification. It took me awhile to recall what that was and, as I recall, one can specify that a loop going through an Array can, instead of taking one at a time can be Stepped to go to every 3rd or 5th or nth place in the Array. An example of the BASIC For loop Line of code is as follows,
"FOR I% = 0 TO 32768 STEP 10".

Obviously a trivial example but I hope it clarifies what I'm trying to explain.
I can't recall and have been unable to find in my Pascal/Delphi texts an example anything similar in Delphi 7. I think I can gin up a 'While' or 'Repeat' loop to work but it'd be much more self-explanatory and self-commenting to have a STEP in Delphi to use.
Is anyone aware of such an option in Delphi For loops?

Bill Kilgore
 

Thank you, imex. I thought that would be the case.

Bill Kilgore
 
Or you could use a for loop such as:
Code:
//"FOR I% = 0 TO 32768 STEP 10".
For I:=0 to 32768 div 10
   X:=Array[I*10]; //access every tenth item
 
Prattaratt,

Thanks for taking the time. I don't think I'd have come up with that one and it looks like it will work.
I learned long ago to always get other eyes to look things over and it's always worked.

Thanks again,

Bill Kilgore
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top