Forum > Windows

Measurement converter in Pascal

<< < (4/4)

Zvoni:

--- 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 Project1;Uses SysUtils;Const  SomeText:String='I am running 4.5 miles every day';  mTok:Double=1.609; Var  a:TStringArray;  i:Integer;  d:Double;  s:String;  fs:TFormatSettings; begin  fs:=DefaultFormatSettings;  a:=SomeText.Split(' ');  For i:=Low(a) To High(a) Do    Begin      If a[i].Trim='miles' Then        Begin          If Not TryStrToFloat(a[i-1],d,fs) Then            If fs.DecimalSeparator='.' Then              fs.DecimalSeparator:=','            Else              fs.DecimalSeparator:='.';          a[i-1]:=FloatToStr((StrToFloat(a[i-1],fs)*mTok),fs);          a[i]:='kilometers';        end;    end;  s:=s.Join(' ',a);  Writeln(s);end.    Returns:

--- Quote ---I am running 7.2405 kilometers every day

--- End quote ---

dzoole:
Zvoni your code seems fine in Lazarus Syntax check OK.
When I compile get succes but 1 warning.
I saved your file as .pas
Copy to Pascal Scripts folder in Subtitle Workshop
and when i want to use it i get SystemUtils not identified.
This Subtitle Workshop is very tricky with pascal scripts. Some pascal scripts works fine in 2.51 version but not good in other versions. 6.0a and 6.0b/e

Navigation

[0] Message Index

[*] Previous page

Go to full version