mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-14 07:39:48 +02:00
22 lines
440 B
ObjectPascal
22 lines
440 B
ObjectPascal
{ %opt=-O3 }
|
|
{$mode objfpc}
|
|
{$H+}
|
|
function Bar(const progress: single; divs: uint32): string;
|
|
const
|
|
BarSym: array[boolean] of char = ('.', '#');
|
|
var
|
|
i: int32;
|
|
begin
|
|
SetLength(result, divs);
|
|
for i := 0 to int32(divs) - 1 do
|
|
pChar(result)[i] := BarSym[(progress >= (0.75 + i) / divs) or (i = int32(divs) - 1) and (progress >= 1)];
|
|
end;
|
|
|
|
var
|
|
s: string;
|
|
|
|
begin
|
|
if Bar(0.7, 10)<>'#######...' then
|
|
halt(1);
|
|
end.
|