home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Turbo Toolbox
/
Turbo_Toolbox.iso
/
1990
/
09
/
tricks
/
isamdemo.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
1990-06-15
|
5KB
|
184 lines
(* ------------------------------------------------------ *)
(* ISAMDEMO.PAS *)
(* Demoprogramm zur ISAM-Unit *)
(* (c) 1990 Karlheinz Büker & TOOLBOX *)
(* ------------------------------------------------------ *)
PROGRAM IsamTree_Demo;
USES Crt, IsamTree;
CONST Ende : BOOLEAN = FALSE;
VAR D : DataType;
{-----------------------------------------}
PROCEDURE Maske(Name : STRING);
BEGIN
ClrScr; GotoXY(20, 1); WriteLn(Name);
WriteLn;
WriteLn(' Name : ');
WriteLn(' Vorname : ');
WriteLn(' Postleitzahl : ');
WriteLn(' Ort : ');
WriteLn(' Strasse : ');
END;
{-----------------------------------------}
PROCEDURE GetOB;
BEGIN
REPEAT
GotoXY(20, 3); ReadLn(D.OB);
UNTIL D.OB <> '';
END;
{-----------------------------------------}
PROCEDURE anlegen;
BEGIN
Maske('Satz erfassen');
GetOB;
REPEAT
GotoXY(20, 4); ReadLn(D.Vorname);
UNTIL D.Vorname <> '';
REPEAT
GotoXY(20, 5); ReadLn(D.Plz);
UNTIL (D.Plz>=1000) AND (D.Plz<9000);
REPEAT
GotoXY(20, 6); ReadLn(D.Ort);
UNTIL D.Ort <> '';
REPEAT
GotoXY(20, 7); ReadLn(D.Str);
UNTIL D.Str <> '';
AddRecord(D);
END;
{-----------------------------------------}
PROCEDURE aendern;
VAR YN : CHAR;
Ref : WORD;
BEGIN
Maske('Satz aendern');
GetOB; GetRecord(D.OB, D, Ref);
IF IsamError <> 0 THEN
BEGIN
GotoXY(10, 25);
Write('Satz nicht gefunden'#7);
Delay(1000); Exit;
END;
GotoXY(20, 4); Write(D.Vorname); ClrEol;
GotoXY(20, 5); Write(D.Plz); ClrEol;
GotoXY(20, 6); Write(D.Ort); ClrEol;
GotoXY(20, 7); Write(D.Str); ClrEol;
REPEAT
GotoXY(20, 20);
Write('Diesen Satz ändern? (J/N) ');
ReadLn(YN);
UNTIL (UpCase(YN)='J')OR(UpCase(YN)='N');
IF UpCase(YN) = 'N' THEN Exit;
DelRecord(D.OB, Ref);
GetOB;
REPEAT
GotoXY(20, 4); ReadLn(D.Vorname);
UNTIL D.Vorname <> '';
REPEAT
GotoXY(20, 5); ReadLn(D.Plz);
UNTIL (D.PLZ>=1000) AND (D.PLZ<9000);
REPEAT
GotoXY(20, 6); ReadLn(D.ort);
UNTIL D.Ort <> '';
REPEAT
GotoXY(20, 7); ReadLn(D.Str);
UNTIL D.Str <> '';
AddRecord(D);
END;
{-----------------------------------------}
PROCEDURE Loeschen;
VAR YN : CHAR;
Ref : WORD;
BEGIN
Maske ('Satz löschen');
GetOB; GetRecord(D.OB, D, Ref);
IF IsamError <> 0 THEN
BEGIN
GotoXY(10, 25);
Write('Satz nicht gefunden'#7#7#7);
Delay(1000); Exit;
END;
GotoXY(20, 4); Write(D.Vorname); ClrEol;
GotoXY(20, 5); Write(D.Plz); ClrEol;
GotoXY(20, 6); Write(D.ort); ClrEol;
GotoXY(20, 7); Write(D.Str); ClrEol;
REPEAT
GotoXY(20, 20);
Write('Diesen Satz löschen ? (J/N) ');
ReadLn(YN);
UNTIL(UpCase(YN)='J')OR(UpCase(YN)='N');
IF UpCase(YN) = 'N' THEN Exit;
DelRecord(D.OB, Ref);
END;
{-----------------------------------------}
PROCEDURE anzeigen;
LABEL Weiter;
VAR ch : CHAR;
Ref : WORD;
BEGIN
Maske ('Satz anzeigen');
GetOB; GetRecord (D.OB, D, Ref);
Weiter:
IF IsamError <> 0 THEN
BEGIN
GotoXY(10, 25);
Write(' Satz nicht gefunden'#7#7#7);
Delay(1000); Exit;
END;
GotoXY(20, 3); Write(D.OB); ClrEol;
GotoXY(20, 4); Write(D.Vorname); ClrEol;
GotoXY(20, 5); Write(D.Plz); ClrEol;
GotoXY(20, 6); Write(D.Ort); ClrEol;
GotoXY(20, 7); Write(D.Str); ClrEol;
GotoXY(20, 10);
Write('B = Blättern / andere Taste = Anzeigen Ende');
ReadLn(ch);
IF (CH='B') OR (CH = 'b') THEN
BEGIN
GetNextRecord(D, Ref); GOTO Weiter;
END;
END;
{-----------------------------------------}
PROCEDURE Menue;
VAR Wahl : BYTE;
BEGIN
ClrScr;
WriteLn(' ISAM-Demonstration - Menü');
WriteLn(' ===========================');
WriteLn;
WriteLn(' 1 .... Datensatz anlegen');
WriteLn(' 2 .... Datensatz ändern');
WriteLn(' 3 .... Datensatz löschen');
WriteLn(' 4 .... Datensatz anzeigen');
WriteLn(' 5 .... Datendatei reorganisieren');
WriteLn(' 6 .... Schlüsseldatei rekonstruieren');
WriteLn;
WriteLn(' 9 .... Programmende');
WriteLn; WriteLn;
REPEAT
GotoXY(14, 16); Write('Bitte wählen : ');
{$I-} ReadLn (Wahl); {$I+}
UNTIL ((Wahl > 0) AND (Wahl < 7)) OR (Wahl = 9);
CASE Wahl OF
1 : anlegen;
2 : aendern;
3 : loeschen;
4 : anzeigen;
5 : ReorgDataFile;
6 : Reko (FALSE);
9 : Ende := TRUE;
ELSE Write (#7);
END;
END;
{-----------------------------------------}
BEGIN
IF NOT ExistFile(Data) THEN CreateFile(Data);
IF NOT ExistFile(Index) THEN CreateFile(Index);
OpenDataBase;
REPEAT Menue UNTIL Ende;
CloseDataBase;
END.