MyChat Scripts Engine: StrToFloat

MyChat Scripts Engine: StrToFloat

"For developers", "Server scripts", "Functions description", "Converting types", "StrToFloat".

 

Converting a string to a floating-point number.

 

Syntax

function StrToFloat(sValue: string): extended;

 

Parameters and return values

Parameter

Type

Value

sValue

string

string that you need to convert to a real number.

 

Function result

Floating-point number that corresponds to the transmitted text string. If the string contains wrong data (for example, "Hello!"), the function returns 0. The decimal separator is the ".".

 

Example

var
  sValue: string;
  x: extended;
begin
  sValue := '123.456E+002';
  x := strtofloat(sValue);
  mLogScript('StrToFloat = ' + inttostr(trunc(x)), '');
end.

Script work result

[08:47:14] (Log "StrToFloat"): StrToFloat = 12345

 

See also

mLogScript

Trunc