Break-statement in TP 5.5

Hi experts
i'm using TB 5.5 (free pascal)
the problem is;
i need to write a function who compares two arrays of 4 shortint to see if 2 numbers are the same
take for example those 2 arrays
1 2 3 4
2 2 2 8

i wrote this code

FUNCTION Case1:Boolean;
Var Temp, i, j:ShortInt;
Begin
Temp:=0;
FOR i:=1 TO 4 DO
FOR j:=1 TO 4 DO
IF Digit[i]=Guess[j] THEN
Temp:=Temp+1;
IF Temp>=2 THEN Case1:=TRUE;
IF Temp<2 THEN Case1:=FALSE;
End;

the problem is that because there are in the second array more than one '2' the output = TRUE but that shouldn't be
because there is only 1 number in the two arrays who are the same

i thaught i could use the BREAK-statement like this

FUNCTION Case1:Boolean;
Var Temp, i, j:ShortInt;
Begin
Temp:=0;
FOR i:=1 TO 4 DO
FOR j:=1 TO 4 DO
IF Digit[i]=Guess[j] THEN
begin
Temp:=Temp+1;
BREAK;
end;
IF Temp>=2 THEN Case1:=TRUE;
IF Temp<2 THEN Case1:=FALSE;
End;

from an algoritmic point of view that should be good I THINK
but the BREAK statement (which is used to abort the actual loop) doesn't work in TP 5.5
could someone help me out ???

Elvis
Who is Participating?

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Author Commented:
or maybe you can just give me a way to go out or to skip the current loop
an alternative to the BREAK statement

Elvis
Author Commented:
SORRY EVERYONE
i found the answe myself
to "break" a while loop i did

FOR i:=1 TO 10 DO
Begin
WriteLn(i);
IF i=5 THEN i:=10;
End;

The Output is
1
2
3
4
5

sorry
Elvis

Experts Exchange Solution brought to you by

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Self-employed developerCommented:
Doesn't matter. However, personally I consider the use of the Break statement something that you should avoid at all costs. Like the Goto statement and some other statements the Break statement makes the source a bit less readable.
Instead of a for-next loop you could also use a While-Do loop like this:

var
I:Integer;
EndOfLoop: Boolean;
begin
I := 0;
EndOfLoop := False;
while (I < 10) and not EndOfLoop do begin
I := I + 1;
WriteLn(I);
if (I=5) then begin
EndOfLoop := True;
end else begin
// Perhaps do some other code.
end;
end;
end;
Author Commented:
thanks i will remember
but now i got it
thanks
Elvis
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Pascal

From novice to tech pro — start learning today.