Nächste Seite: 9.6 Unit TransU
Aufwärts: 9. Programmlisting
Vorherige Seite: 9.4 Unit ASync4U1
  Inhalt
{-------------------------------------------------------------------}
{ Konvertierung einer Plot-Datei in Integer-Werte }
unit ConvertU;
{-------------------------------------------------------------------}
interface
procedure Convert;
procedure ConvertFile;
{-------------------------------------------------------------------}
implementation
uses
Glob, { Globale Deklarationen }
LoadSave, { Laden und Speichern von Dateien }
{ Turbo Pascal Standard Units }
App, Crt, Dialogs, MsgBox, Objects, StdDlg, Views;
{-------------------------------------------------------------------}
{ Ermitteln der Integer-Werte }
procedure Convert;
type
Wert = record
x, y : word;
end;
var
w : array [0..nmax - 1] of Wert;
i, j, ErrorCode : word;
s : string [5];
c : char;
f : Text;
begin
Assign(f, FileName);
Reset(f);
repeat
Read(f, c);
until c = 'D';
repeat
Read(f, c);
until c = 'D';
Read(f, c); { ';' }
Read(f, c); { 'P' }
Read(f, c); { 'A' }
i := 0;
repeat
Read(f, c); { ' ' }
s := '';
c := ' ';
repeat
s := s + c;
Read(f, c);
until c = ',';
Val(s, w[i].x, ErrorCode);
w[i].x := w[i].x div 4;
s := '';
c := ' ';
repeat
s := s + c;
Read(f, c);
until c = ';';
Val(s, w[i].y, ErrorCode);
w[i].y := w[i].y div 16 - 22;
Read(f, c); { 'P' }
Read(f, c); { 'A' bzw. 'U' }
inc(i);
until c = 'U';
Close(f);
i := 0;
Imes^[0] := w[0].y;
for j := 1 to nmax - 1 do
begin
if w[i].x > j then Imes^[j] := Imes^[j - 1]
else
begin
Imes^[j] := w[i].y;
inc(i);
end;
end;
FileName := copy(FileName, 0, length(FileName) - 3) + ExtMess;
SaveFileI(Imes^, FileName);
end; { Convert }
{-------------------------------------------------------------------}
{ Konvertierungs-Dialog }
procedure ConvertFile;
var
D : PFileDialog;
Command : word;
begin
Extens := '*' + ExtPlot;
repeat
D := New(PFileDialog, Init(Extens, 'Datei oeffnen',
'~N~ame (*.PLT)', fdOpenButton, fdReplaceButton));
Command := Desktop^.ExecView(D);
if (Command <> cmCancel) then
begin
D^.GetFileName(FileName);
if Exists(FileName) then Convert
else MessageBox(#3 + 'Datei ' + FileName + ' nicht gefunden'
+ #13 + #13, nil, mfError or mfOKButton);
end;
Dispose(D, Done);
until (Command = cmCancel);
end; { ConvertFile }
{-------------------------------------------------------------------}
end. { ConvertU }
{-------------------------------------------------------------------}
Nächste Seite: 9.6 Unit TransU
Aufwärts: 9. Programmlisting
Vorherige Seite: 9.4 Unit ASync4U1
  Inhalt
Udo Becker
2000-01-02