program MdTo;
{$APPTYPE CONSOLE}
{$R *.res}
uses
Windows, SysUtils, Classes, uStreamIO;
type
TInfo = packed record
Short,
Full: string;
end;
TInfos = array of TInfo;
function AddRecord(var AInfos: TInfos; const AShort, AFull: string): Boolean;
var
Len: Integer;
i: Integer;
begin
Len := Length(AInfos);
Result := False;
for i := Low(AInfos) to High(AInfos) do
if ((AInfos[i].Short = AShort) and (AInfos[i].Full = AFull)) then
Exit;
SetLength(AInfos, Succ(Len));
AInfos[Len].Short := AShort;
AInfos[Len].Full := AFull;
Result := Len < Length(AInfos);
end;
function ConvertList(const AFilename: string; var AInfos: TInfos): Boolean;
var
stream: TFileStream;
F: Textfile;
s: String;
i: Integer;
cnt: Integer;
GotData: Boolean;
b1: Boolean;
s1, s2: string;
Begin
Result := False;
stream := TFilestream.Create(AFilename, fmOpenRead or fmShareDenyNone );
try
AssignStream(F, stream);
Reset(F);
try
repeat
ReadLn(F, s);
cnt := 0;
b1 := False;
s1 := '';
s2 := '';
GotData := False;
if (Pos('|', s) = 1) then
for i := 1 to Length(s) do
begin
if s[i] = '|' then
inc(cnt);
if ((not b1) and (s[i] <> '|')) then
s1 := s1 + s[i];
if cnt > 1 then
b1 := True;
if (b1 and (s[i] <> '|') and (Length(s2) <= 3)) then
s2 := s2 + s[i];
if cnt >= 3 then
begin
GotData := ((s1 <> '') or (s2 <> ''));
Break;
end;
end;
if GotData then
begin
s1 := Trim(s1);
s2 := Trim(s2);
if ((s2 <> 'Mod') and (s2 <> '----')) then
AddRecord(AInfos, s2, s1);
end;
until EOF(F);
finally
CloseFile(F);
end;
finally
stream.Free;
Result := (Length(AInfos) > 0)
end;
end;
function WriteList(const AFilename: string; const AInfos: TInfos): Boolean;
begin
end;
var
sl: TInfos;
fn: string;
i: Integer;
begin
WriteLn('MonitorInfo extractor by KodeZwerg.');
SetLength(sl, 0);
fn := 'AnalogDisplay.md';
if ConvertList(ExtractFilePath(ParamStr(0)) + fn, sl) then
begin
WriteLn(fn, ' successful read ', Length(sl), ' entries.');
for i := Low(sl) to High(sl) do
WriteLn('[', sl[i].Short, '] - [', sl[i].Full, ']');
WriteLn(fn, ' successful read ', Length(sl), ' entries.');
end;
SetLength(sl, 0);
fn := 'DigitalDisplay.md';
if ConvertList(ExtractFilePath(ParamStr(0)) + fn, sl) then
begin
WriteLn(fn, ' successful read ', Length(sl), ' entries.');
for i := Low(sl) to High(sl) do
WriteLn('[', sl[i].Short, '] - [', sl[i].Full, ']');
WriteLn(fn, ' successful read ', Length(sl), ' entries.');
end;
ReadLn;
end.