[fpc-pascal] Can variables be declared within a block?

Benedikt Schindler BeniSchindler at gmx.de
Mon Oct 18 16:21:01 CEST 2010


> 
>     I just want to create shorter variables like
>     si :=  StringList.NameOfIndex(TableName.FieldByName('xxxx').AsString);
>     ae := xxx;
>     so:= yyy
> 
>     to express complicated logic with them.
> 
>     When I put them all at the top of the procedure, they are extra
>     noise, which is not necessary for the understanding the purpose at
>     the top level of the procedure.

I don't see the great extra noise of a

procedure SomeProc([someVars : Type]);
var
  [somevars : type;]
  si,ae,so : double; // temp vars for easy math;
begin
  [...]
end;

and i think the easy answer is:

No you could't, because in pascal you have to declare the vars in the
beginning of a procedure.

or:

No because this is pascal and not C

or:

why couldn't i use spanish in my english? :) *just kidding*


have all a nice day.



More information about the fpc-pascal mailing list