Recent

Author Topic: PAS2JS: VAL() - Incompatible type for arg no. 2: Got "Longint", expected "Boolea  (Read 307 times)

peter.dell

  • New Member
  • *
  • Posts: 20
The following program compiles with with FPC, but results in
'Incompatible type for arg no. 2: Got "Longint", expected "Boolean'
for the val in PAS2JS:
I don't see were Booleans would come into play here.

Code: Pascal  [Select][+][-]
  1. program test;
  2.  
  3. var
  4.      n: string;
  5.      v: integer;    
  6.      p: word;
  7.  
  8. begin
  9.  
  10.   n:='$123';
  11.   val(n,v,p);
  12. end.
  13.  

rca

  • Jr. Member
  • **
  • Posts: 97
pas2js has its own system.pas and is a little different from fpc.

Reviewing, pas2js has the following options for val: (system.pas)
Code: Pascal  [Select][+][-]
  1. procedure val(const S: String; out NI : NativeInt; out Code: Integer); overload;
  2. procedure val(const S: String; out NI : NativeUInt; out Code: Integer); overload;
  3. procedure val(const S: String; out SI : ShortInt; out Code: Integer); overload;
  4. procedure val(const S: String; out B : Byte; out Code: Integer); overload;
  5. procedure val(const S: String; out SI : smallint; out Code: Integer); overload;
  6. procedure val(const S: String; out W : word; out Code : Integer); overload;
  7. procedure val(const S: String; out I : integer; out Code : Integer); overload;
  8. procedure val(const S: String; out C : Cardinal; out Code: Integer); overload;
  9. procedure val(const S: String; out d : double; out Code : Integer); overload;
  10. procedure val(const S: String; out b : boolean; out Code: Integer); overload;
  11.  

In all options, "out Code" is of type integer.

So your code would work if you change the type of variable from word to integer:
Code: Pascal  [Select][+][-]
  1. var
  2.   n: string;
  3.   v, p: integer;    
  4.  

peter.dell

  • New Member
  • *
  • Posts: 20
Thanks for the swift and precise reply. Val() issues are solved now. On to the next problem :-)

 

TinyPortal © 2005-2018