I needed some time to understand that in scripter there are no typed variables. all seems handled as variants. The declaration section in a procedure header seems to work as a dummy in which you can type wathever you want. eg var MyDouble: TWhatEverYouWant; is acceptet without any error. Is this concept of undeclared variables in scripter a wanted feature or did I configurated smth. wrong? Can this behaviour changed?
I ask because I falled into a trap by working with the format function.
procedure Button1Click(Sender: TObject);
var myDouble: double;
begin
myDouble := 5;
ShowMessage( Format('%.3f',[myDouble]) ); // in Scripter it raise an convert error - under Delphi no problems
end;
then I found out that every variable in Scripter seems an variant, then I changed procedure into
procedure Button1Click(Sender: TObject);
var myDouble: double;
begin
myDouble := VarAsType(5,varDouble);
ShowMessage( Format('%.3f',[myDouble]) ); // after explicit converted 5 into a double it works
end;
then my consideration was that this handling of untyped vars can let you fall you into a lot more of traps. eg. MyDouble := 'Hello world' in scripter works without problems, but of course as soon you try to MyDouble := MyDouble +1; the next trap. Or asigning a var to another var. you can not go shure that the scripter compiler says anything.
..so this is why I ask where to change this handling. ... Or maybe is there a "scripter internal way" to "really" declare typed variables?