home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Hacker Chronicles 2
/
HACKER2.BIN
/
134.ADVANCED.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1988-06-30
|
9KB
|
250 lines
UNIT AdvancedOpts;
INTERFACE
USES
{$IFDEF DOSCrt}
DOSCrt,
{$ELSE}
Crt,
{$ENDIF}
Graph,
DrawGraf,
TextOps,
Global;
{----------------------------------------------------------------------------}
{- -}
{- AdvancedOptions allows several options to be changed. -}
{- -}
{----------------------------------------------------------------------------}
PROCEDURE AdvancedOptions;
{----------------------------------------------------------------------------}
{- -}
{- Read_Default_Options reads the default options file that was saved -}
{- previously by the user under the advanced options menu. -}
{- -}
{----------------------------------------------------------------------------}
PROCEDURE Read_DefaultOptions;
(****************************************************************************)
IMPLEMENTATION
PROCEDURE AdvancedOptions;
VAR
int : char;
DONE : BOOLEAN;
NewNum : INTEGER;
temp : string;
Name : text;
error : INTEGER;
ch : CHAR;
Drive : BYTE;
CurrentDir : string;
PROCEDURE AdvancedOptionsMenu;
BEGIN {AdvancedOptionsMenu}
ClrScr;
WriteXY ('Advanced Options',StartColumn+8,3);
WriteXY ('Select Option by typing a number: ',StartColumn,5);
WriteXY ('1. Linear/Spline Interpolation: ',StartColumn+5,8);
WriteXY ('2. Digitizer Port [0/1/2]: ',StartColumn+5,10);
WriteXY ('3. Printer installed (y/n) ? ',StartColumn+5,12);
WriteXY ('4. Colors: ',StartColumn+5,14);
WriteXY ('5. Data Disk/Directory: ',StartColumn+5,16);
WriteXY ('6. Save Options ',StartColumn+5,18);
WriteXY ('9. Exit to Main Menu ',StartColumn+5,20);
WriteXY ('Your Choice? ',StartColumn,24);
GotoXY (StartColumn+39,8);
IF SPLINE
THEN Write ('S')
ELSE Write ('L');
GotoXY (StartColumn+39,10); Write (SerialPort);
GotoXY (StartColumn+39,12);
IF NoPrinter
THEN Write ('N')
ELSE Write ('Y');
GotoXY (StartColumn+35,14);
Write (ForeColor:2,'/',BackColor:2);
GotoXY (StartColumn+29,16); Write (DefaultDataDir:11);
DONE:=FALSE;
END; {AdvancedOptionsMenu}
BEGIN {AdvancedOptions}
AdvancedOptionsMenu;
REPEAT
GotoXY (StartColumn+13,24);
REPEAT
ch:=ReadKey;
UNTIL ch in ['1'..'6','9'];
Write (ch);
CASE ch OF
'1': BEGIN
GotoXY (StartColumn+39,8);
IF SPLINE
THEN BEGIN
SPLINE:=FALSE;
Write ('L');
END {THEN}
ELSE BEGIN
SPLINE:=TRUE;
Write ('S');
END; {ELSE}
ACCEPT:=FALSE;
END;
'2': BEGIN
GotoXY (StartColumn+39,10);
REPEAT
ch:=ReadKey;
UNTIL ch in ['0'..'2'];
SerialPort:=ord(ch)-ord('0');
Write (SerialPort);
END;
'3': BEGIN
GotoXY (StartColumn+39,12);
IF NoPrinter
THEN BEGIN
NoPrinter:=FALSE;
Write ('Y');
END {THEN}
ELSE BEGIN
NoPrinter:=TRUE;
Write ('N');
END; {ELSE}
END;
'4': BEGIN
GotoXY (StartColumn+29,14); ClrEOL;
GotoXY (StartColumn,24);
Write ('Foreground color [',ForeColor,'] ? ');
ClrEol;
ReadLn (temp);
Val (temp,NewNum,error);
IF error = 0 THEN ForeColor:=NewNum mod 16;
GotoXY (StartColumn,24);
Write ('Background color [',BackColor,'] ? ');
ClrEol;
ReadLn (temp);
Val (temp,NewNum,error);
IF error = 0 THEN BackColor:=NewNum mod 16;
IF GraphDriver <> HercMono THEN BEGIN
TextColor (ForeColor);
TextBackground (BackColor);
END; {IF}
AdvancedOptionsMenu;
END;
'5': BEGIN
WriteXY ('New data disk/directory? ',StartColumn,24);
ReadLn (temp);
IF length (temp) > 0 THEN BEGIN
Drive:=0;
GetDir (Drive,CurrentDir);
{$I-} ChDir (temp); {$I+}
IF IOResult = 0
THEN BEGIN
DefaultDataDir:=temp;
ChDir (CurrentDir);
GotoXY (StartColumn+29,16);
Write (DefaultDataDir:11); ClrEOL;
END {THEN}
ELSE BEGIN
PrintErrorMsg ('Invalid disk/directory! ',
StartColumn,21,FALSE,ch);
END; {ELSE}
END; {IF}
WriteXY ('Your Choice? ',StartColumn,24); ClrEOL;
END;
'6': BEGIN
WriteXY ('Saving Options. Please wait ...',
StartColumn,24);
Assign (Name,DefaultOptions);
Rewrite (Name);
IF SPLINE
THEN WriteLn (Name,'SPLINE Interpolation')
ELSE WriteLn (Name,'LINEAR Interpolation');
WriteLn (Name,'Digitizer at COM',SerialPort,':');
IF NoPrinter
THEN WriteLn (Name,'NO Printer installed')
ELSE WriteLn (Name,'Printer is installed');
WriteLn (Name,'Foreground Color is ',ForeColor:2);
WriteLn (Name,'Background Color is ',BackColor:2);
WriteLn (Name,'Drawing Color is ',DrawColor:2);
WriteLn (Name,'Default data directory is ',DefaultDataDir);
Close (Name);
WriteXY ('Your Choice? ',StartColumn,24); ClrEOL;
END;
'9': BEGIN
DONE:=TRUE;
ClrScr;
END;
END; {case}
WriteXY (' ',StartColumn+13,24);
UNTIL DONE;
END; {AdvancedOptions}
PROCEDURE Read_DefaultOptions;
var
Name : text;
temp : string;
i,j : BYTE;
error : INTEGER;
num : string [2];
BEGIN {Read_DefaultOptions}
IF EXIST (DefaultOptions) THEN BEGIN
Assign (Name,DefaultOptions);
Reset (Name);
ReadLn (Name,temp);
i:=Pos ('SPLINE',temp);
IF i >= 1
THEN SPLINE:=TRUE
ELSE SPLINE:=FALSE;
ReadLn (Name,temp);
i:=Pos ('COM',temp);
SerialPort:=ord(temp[i+3])-ord('0');
IF NOT (SerialPort in [0..2]) THEN SerialPort:=0;
ReadLn (Name,temp);
IF temp[1] in ['P','p']
THEN NoPrinter:=FALSE
ELSE NoPrinter:=TRUE;
ReadLn (Name,temp);
i:=Pos ('is ',temp);
num:=Copy (temp,i+3,2);
Val (num,i,error);
IF error = 0 THEN ForeColor:=i;
ReadLn (Name,temp);
i:=Pos ('is ',temp);
num:=Copy (temp,i+3,2);
Val (num,i,error);
IF error = 0 THEN BackColor:=i;
ReadLn (Name,temp);
i:=Pos ('is ',temp);
num:=Copy (temp,i+3,2);
Val (num,i,error);
IF error = 0 THEN DrawColor:=i;
ReadLn (Name,temp);
i:=Pos ('is ',temp);
IF i > 0 THEN BEGIN
FOR j:=i+3 to length(temp) do
DefaultDataDir[j-i-2]:=temp[j];
DefaultDataDir[0]:=char (length(temp)-i-2);
END; {IF}
END; {IF}
END; {Read_DefaultOptions}
(****************************************************************************)
BEGIN {Initialization}
END. {Unit AdvancedOpts}