Log in

View Full Version : Having If.. Then... Else... Problems



Ancient8989
02-11-2012, 04:52 AM
procedure findBMP;
var
BMP: Integer;
begin
BMP := BitmapFromString(4, 6, 'meJxjYmBwT63zL+hmYmDorI5RsQ3U' +
'dI3R9UmJCrTZOL98+9LqfasaEsIcU6Kc85O9KnMC/Txtgn0dwgOdn' +
'WyNrcx03Z3MfdysgXoBTxQWZQ==');

If FindBitmapSpiralTolerance(BMP, x, y, MIX1, MIY1, MIX2, MIY2, 1) then
Mouse(x, y, 4, 4, true);
FreeBitmap(BMP);
Else
FreeBitmap(BMP);
end;

When I run this code I get:


[Error] (24:1): Identifier expected at line 23
Compiling failed.

Saying that the else needs a identifier? I've looked at tutorials that involve this and don't seem to see what's wrong. Can you help me out?

Ancient8989

NickMystre
02-11-2012, 04:54 AM
When you have more than one statement after the 'then' or 'else', you need to use 'begin' and 'end'.

Like this ...

procedure findBMP;
var
BMP: Integer;
begin
BMP := BitmapFromString(4, 6, 'meJxjYmBwT63zL+hmYmDorI5RsQ3U' +
'dI3R9UmJCrTZOL98+9LqfasaEsIcU6Kc85O9KnMC/Txtgn0dwgOdn' +
'WyNrcx03Z3MfdysgXoBTxQWZQ==');

If FindBitmapSpiralTolerance(BMP, x, y, MIX1, MIY1, MIX2, MIY2, 1) then
begin
Mouse(x, y, 4, 4, true);
FreeBitmap(BMP);
end
Else
FreeBitmap(BMP);
end;

Ancient8989
02-11-2012, 04:57 AM
Thanks that worked.