[Pas2js] My 1st type helper

warleyalex warleyalex at yahoo.com.br
Wed Feb 27 14:07:35 CET 2019



-------------------------------------------
type
 TFloatHelper  =  type helper for Float  
   const NPI = 3.141592;
   function ToStr: String;
 end;

function  TFloatHelper.ToStr: String;
begin
  Result:=  FloatToStr(Self);
end;

------------------------
this syntax
//  TFloatHelper  =  helper for Float 

// hum, doesn't work for me, I had to include the keyword type
How to use the float helper function ToStr?

-----------------------
var
  ReturnValue : Float;
begin
  ReturnValue := 2.71;
    console.log(ReturnValue * ReturnValue.NPI);                     
//8.51371432
//  console.log((ReturnValue * ReturnValue.NPI).ToStr);         
//8.51371432  does not work for me
//  console.log((ReturnValue * TFloatHelper.NPI).ToStr);         
//8.51371432 does not work for me
//  console.log(TFloatHelper.ToStr(ReturnValue * Float.NPI));  //8.51371432
does not work for me
//  console.log((ReturnValue * ReturnValue.NPI).ToStr );        //8.51371432
does not work for me




--
Sent from: http://pas2js.38893.n8.nabble.com/


More information about the Pas2js mailing list