Skip to content

Commit 3c0457d

Browse files
committed
Update - Encapsulate main routines in a class.
- Used new rounding as mentioned by Gus.
1 parent b220409 commit 3c0457d

2 files changed

Lines changed: 259 additions & 145 deletions

File tree

entries/ikelaiah/src/OneBRC.lpr

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
WeatherStation;
3737

3838
const
39-
version = '1.4';
39+
version = '1.5';
4040

4141
type
4242

@@ -57,6 +57,7 @@ TOneBRC = class(TCustomApplication)
5757
var
5858
ErrorMsg: string;
5959
filename: string = '';
60+
weatherStation: TWeatherStation;
6061
begin
6162
// quick check parameters
6263
ErrorMsg := CheckOptions('hvi:', ['help', 'version', 'input:']);
@@ -92,7 +93,7 @@ TOneBRC = class(TCustomApplication)
9293
filename := GetOptionValue('i', 'input');
9394
end;
9495

95-
if (length(filename) < 4) then
96+
if not FileExists(fileName) then
9697
begin
9798
WriteLn('Input file seems invalid.');
9899
WriteHelp;
@@ -102,13 +103,17 @@ TOneBRC = class(TCustomApplication)
102103

103104
// Start the main algorithm ////////////////////////////////////////////////
104105
try
105-
WeatherStation.ProcessTempMeasurementsV4a(filename);
106+
weatherStation := TWeatherStation.Create(filename);
107+
try
108+
weatherStation.ProcessMeasurements;
109+
finally
110+
weatherStation.Free;
111+
end;
106112
except
107113
on E: Exception do
108114
WriteLn('Error: ' + E.Message);
109115
end;
110116

111-
112117
// Stop program loop ///////////////////////////////////////////////////////
113118
Terminate;
114119
end;

0 commit comments

Comments
 (0)