SRL Archive - Help and Support

Something like a foreach statement?


R0b0t1

2007-09-09 12:32:50

Well, I have to use examples on this one…


program New;

Var ColArr: Array [0..4] of Boolean;
Var I: Integer;

begin;
For I:= 0 to 4 do
ColArr[I]:= FindColorSpiralTolerance(......);

Foreach (True in ColArr) do
begin;
......
end;
end.

Anything like that? It would help a bunch…. :p.

Bourdou!

2007-09-09 12:34:22

So like for each color it finds it does something?

R0b0t1

2007-09-09 12:54:54

Yeah, like that… Because Find colors return a boolean, I want a statment that can do something for each of those…

But I don't want to use a For loop, with a if statement inside of it, unless I have to.

n3ss3s

2007-09-09 14:56:57

I quite didnt get your idea? Explain more please.

R0b0t1

2007-09-09 15:01:39

Ugh…

Okay, you have an array of boolean values. For each value in the array you have it search for a color, it then stores whether it found it or not (Find Colors return true if it found it, K?).

What I want to know, is if there is a function to do a block of code for every true value in that array. Like this:


Foreach (True in TheArray) do
.....

I realize this can be done with a for loop and an If statement… But I want to simplify it.

n3ss3s

2007-09-09 15:10:01

I dont know does one exists, but just make

"
procedure YourProc(TrueFalse: Boolean);
begin
case TrueFalse of
True....
"

R0b0t1

2007-09-09 18:58:34

Yeah, I know… But thats so much more typing!

Boreas

2007-09-09 22:07:29

Not compared to the time it took you to make this thread :p

The Claw

2007-09-10 07:30:46

Couldnt you do sometjhing like this:

begin;
For I:= 0 to 4 do
begin
ColArr[i]:= FindColorSpiralTolerance(......);

if ColArr[i] then
begin;
......
end;
end;
end.

n3ss3s

2007-09-10 09:22:47

Lol boreas, but true :D

Why you have to make some kind of functions, why cant you just do

case Bool of
True:…
False:..

Infantry001

2007-09-10 15:14:50

Yeah just do it like claw said.

program New;

Var ColArr: Array [0..4] of Boolean;
Var I: Integer;

begin;
For I:= 0 to 4 do
ColArr[i]:= FindColorSpiralTolerance(......);
for I := 0 to 4 do
begin
if ColArr[i] then
begin
end;
......
end;
end.

Tim0suprem0

2007-09-10 18:15:13

From: Boreas
Not compared to the time it took you to make this thread :p


Foreal, dude it wasn't that much typing… especially compared to :
From: r0b0t1
Ugh…

Okay, you have an array of boolean values. For each value in the array you have it search for a color, it then stores whether it found it or not (Find Colors return true if it found it, K?).

What I want to know, is if there is a function to do a block of code for every true value in that array. Like this:

ScarScript: By Drunkenoldma

Foreach (True in TheArray) do
…..


I realize this can be done with a for loop and an If statement… But I want to simplify it.


lol.. :p