SRL Archive - Help

Having If.. Then... Else... Problems


Ancient8989

2012-02-10 23:52:28

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

2012-02-10 23:54:18

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

2012-02-10 23:57:26

Thanks that worked.