Hi ,
i have a simple code as follow ,
procedure add_to_selection( act_type, doc_type , your_ref , our_ref ,id ,item_desc :string ; qty:integer );
var _no_selected_item ,_qty :integer ;
begin
if (qty <= 0) then
begin
DMConnection.show_toast_message('Warning ,no quantity selected for this item !');
Exit;
end;
if DMConnection.tableSelection.Locate('id', StrToInt( id ) ,[] ) then begin
DMConnection.tableSelection.edit;
_qty := DMConnection.tableSelection.fieldbyname('qty').asInteger ;
_qty := _qty + qty ;
DMConnection.tableSelection.fieldbyname('qty').asstring := inttostr( _qty );
DMConnection.tableSelection.post;
end;
end ;
the qty of the tableSelection is original 1 , then we add qty 2 of the same product ,
but after call the procedure , the table tableSelection field qty become 12 ?
it treated qty as string ? please advice .
regards,
kalmen
no sure this help for you to explain , refer to the image ,
Thanks.
I cannot reproduce this
procedure TForm1.WebButton1Click(Sender: TObject);
var
qty: integer;
_qty: integer;
begin
qty := 2;
_qty := 1;
_qty := _qty + qty;
showmessage(inttostr(_qty));
end;
I'd suggest to step through the code to see where something goes wrong.
thanks , got it , it is pretty confusing , but here is what i found ,
in my ASM block , i passed a string integer that call $mod.myprocedure( _str_integer )
which in my Delphi code , the procedure myprocedure( qty :integer ) ; where the
delphi procedure which has compiled to JS , will not be able to differentiate the integer
from string ! (so in a way , i need to make sure that if it is a integer string by using parseint() in
JS , in order to make it work ?
just a thought , will TMS.Webcore be able to consider do the call of parseint() automatically when it transpile the delphi code into JS , since the delphi has defined that the parameter is integer , if it detect that the param passed is not integer will be able to catch exception and provide a closer feel of delphi code style ?
I believe the goal and preferred approach is to avoid ASM blocks. ASM blocks bring the non-typed JavaScript issues back that Pascal doesn't have, when wanting to use ASM blocks, care for types should be handled there.