Forum > Pas2JS
PAS2JS: VAL() - Incompatible type for arg no. 2: Got "Longint", expected "Boolea
(1/1)
peter.dell:
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 [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---program test; var n: string; v: integer; p: word; begin n:='$123'; val(n,v,p);end.
rca:
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 [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure val(const S: String; out NI : NativeInt; out Code: Integer); overload;procedure val(const S: String; out NI : NativeUInt; out Code: Integer); overload;procedure val(const S: String; out SI : ShortInt; out Code: Integer); overload;procedure val(const S: String; out B : Byte; out Code: Integer); overload;procedure val(const S: String; out SI : smallint; out Code: Integer); overload;procedure val(const S: String; out W : word; out Code : Integer); overload;procedure val(const S: String; out I : integer; out Code : Integer); overload;procedure val(const S: String; out C : Cardinal; out Code: Integer); overload;procedure val(const S: String; out d : double; out Code : Integer); overload;procedure val(const S: String; out b : boolean; out Code: Integer); overload;
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 [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---var n: string; v, p: integer;
peter.dell:
Thanks for the swift and precise reply. Val() issues are solved now. On to the next problem :-)
Navigation
[0] Message Index