Subversion Repositories jumper

Compare Revisions

Regard whitespace Rev HEAD → Rev 1

/trunk/Functions.pas
6,14 → 6,19
SysUtils, Dialogs, Graphics, Classes, ExtCtrls;
 
function ExtractFileNameWithoutExt(filename: string): string;
function SecondsToTimeString(Seconds: Integer): string;
procedure ClearImage(Image: TImage; BackgroundColor: TColor);
function Ganzzahlig(num: extended): boolean;
function Explode(Separator, Text: String): TStringList;
function Position(FullString, Search: String): Integer;
function DotsAtBeginning(s: string): integer;
function DotsAtEnd(s: string): integer;
function ReadFile(InputFile: string): string;
function RemoveLineBreaks(inp: string): string;
 
implementation
 
resourcestring
LNG_COULD_NOT_OPEN_FILE = 'Could not open file "%s".';
 
function ExtractFileNameWithoutExt(filename: string): string;
begin
result := ExtractFileName(filename);
20,6 → 25,32
result := copy(result, 1, Length(result)-Length(ExtractFileExt(result)));
end;
 
function SecondsToTimeString(Seconds: Integer): string;
var
h, m, s: integer;
tim: TDateTime;
begin
h := 0;
m := 0;
s := Seconds;
 
while s - 60*60 >= 0 do
begin
dec(s, 60*60);
inc(h);
end;
 
while s - 60 >= 0 do
begin
dec(s, 60);
inc(m);
end;
 
tim := EncodeTime(h, m, s, 0);
 
result := TimeToStr(tim);
end;
 
procedure ClearImage(Image: TImage; BackgroundColor: TColor);
var
OldPenColor, OldBrushColor: TColor;
33,6 → 64,11
Image.Canvas.Brush.Color := OldBrushColor;
end;
 
function Ganzzahlig(num: extended): boolean;
begin
result := num = round(num);
end;
 
function Explode(Separator, Text: String): TStringList;
var
pos: integer;
70,33 → 106,35
result := Length(FullString) - x + 1;
end;
 
function DotsAtBeginning(s: string): integer;
function ReadFile(InputFile: string): string;
var
i: integer;
f: textfile;
tmp: string;
begin
result := 0;
for i := 1 to Length(s) do
result := '';
 
if not FileExists(InputFile) then
begin
if s[i] = '.' then
Inc(result)
else
ShowMessage(Format(LNG_COULD_NOT_OPEN_FILE, [InputFile]));
Exit;
end;
end;
 
function DotsAtEnd(s: string): integer;
var
i: integer;
AssignFile(f, InputFile);
Reset(f);
while not Eof(f) do
begin
result := 0;
for i := Length(s) downto 1 do
begin
if s[i] = '.' then
Inc(result)
else
Exit;
ReadLn(f, tmp);
result := result + tmp + #13#10;
end;
CloseFile(f);
end;
 
function RemoveLineBreaks(inp: string): string;
begin
inp := StringReplace(inp, #13, '', [rfReplaceAll]);
inp := StringReplace(inp, #10, '', [rfReplaceAll]);
result := inp;
end;
 
end.