[Lazarus] Why doesn't this work?

Howard Page-Clark hdpc at talktalk.net
Thu Nov 29 09:39:48 CET 2012


On 28/11/12 10:15, Erwin van den Bosch wrote:
> procedure TForm1.Button1Click(Sender: TObject);
> var
>    iLastError: integer;
> begin
>    iLastError:=10053;
>    if iLastError in [10053, 10054] then Label1.Caption:='Yes, it works!'
>                                    else Label1.Caption:='No, it doesn''t
> work!';
>    // Output : No, it doesn''t work!
> end;

You may be thinking of how "in" is used in a for..in..do loop like this

procedure TForm1.Button1Click(Sender: TObject);
var
    iLastError, j: integer;
    intArray: array[0..1] of integer = (10053,10054);
begin
    iLastError:=10053;
    for j in intArray do
     if j=iLastError
      then begin
            Label1.Caption:='iLastError present';
            Break;
           end
     else label1.Caption:= 'iLastError not found';
end;





More information about the Lazarus mailing list