home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
pascal
/
library
/
dos
/
ansi
/
aprompt
/
aprompt.pas
Wrap
Pascal/Delphi Source File
|
1990-12-21
|
7KB
|
179 lines
(********************************************************************
Author: Chuck Dearbeck - THE BAD ATTITUDE BBS! 814-459-2116
With help from the ANSI CRT replacement Unit from Rick Housh ANSICRT.PAS,
and of course I'm still borrowing...stealing... whatever you want to call
it ... from source code Mike Woltz the author of SpitFire BBS has put out.
The Unit (ANSICRT) isn't included in this ZIP file to make it smaller and
also so a person wouldn't already have it and download it twice. It is
needed to compile unless you want to do everything yourself. If you can't
find it you can download it from the above BBS. I read in a computer mag
article Jim Button considers a lot of the shareware available HECKWARE.
Somebody writes something... figures 'WHAT THE HECK' I'll give it a price and
maybe some dummy will send me money even though it doesn't do much. I agree
with him so I figure this could be considered What-The-Heckware too. The
difference though is I figure 'What the Heck, even though it doesn't do much,
it is free and the source code (however amateurish) comes with it. But, it
could have some slight value to someone who has just started programming, so
if thats you I hope it helps a little. I can think of some improvements that
could be made in how it works... you could give the user the option of how
they want their prompts, whether they even want the time in it, more colors,
two-line prompts, prompts with the date... etc... but ... WHAT THE HECK!
********************************************************************)
Program Aprompt;
Uses Dos, Anscrt; (* Turbo Pascal units used *)
Var
Choice : String;
(*------------------------------*)
Procedure Find_Config;
(*------------------------------*)
Var
Config : Text;
Conline : String;
Config_Line : Boolean;
i : byte;
Begin
Config_Line := False;
Assign(Config,'C:\CONFIG.SYS'); (* open To read *)
{$I-}Reset(Config);{$I+}
If IOResult <> 0 Then (* couldn't find it? *)
Begin
Writeln;
Writeln(^G,'CONFIG.SYS File Not Found!');
Halt; (* Config.sys not found so halt program *)
end;
Repeat
ReadLn(Config,Conline); (* config.sys was found so read it *)
For i := 1 To Length(Conline) Do (* make line upper case *)
Conline[i] := UpCase(Conline[i]);
If POS('ANSI.SYS',Conline) <> 0 Then (* does it say ANSI.SYS anywhere? *)
Config_Line := True; (* yes it does *)
Until EOF(Config);
If Config_Line = False Then (* no ANSI.SYS statement so ... *)
Begin;
WriteLn(^g,'You Don''t Have DEVICE=ANSI.SYS In Your CONFIG.SYS File!');
Halt;
end;
Close(config);
end;
(*------------------------------*)
Procedure Auto_Write; (* they chose to change their prompt *)
(*------------------------------*)
Var
Autoprom,
Temp : Text;
Pick : Char;
i : Byte;
Autoline : String;
Found : Boolean;
Begin;
Found := False;
Assign(Autoprom,'c:\AutoExec.BAT'); (* open To read *)
{$I-}Reset(Autoprom);{$I+}
If IOResult <> 0 Then (* no AUTOEXEC.BAT file was found *)
Begin
Writeln;
Writeln(^G,'AUTOEXEC.BAT Not Found!');
Halt;
end;
Assign(Temp,'c:\AutoTemp.BAT'); (* open temporary file to write *)
{$I-}Rewrite(Temp);{$I+}
Append(Temp);
Repeat
ReadLn(Autoprom,AutoLine); (* read a line from the AUTOEXEC.BAT *)
For i := 1 To Length(autoLine) Do
Autoline[i] := UpCase(AutoLine[i]); (* make it upper case *)
If POS('PROMPT',AutoLine) <> 0 Then (* check for the word PROMPT *)
Begin
AutoLine := Choice; (* if its found change line to their choice *)
Found := True;
end;
Writeln(Temp,AutoLine); (* write the line to temporary file *)
Until EOF(Autoprom);
Close(Autoprom);
If Not Found Then (* the word PROMPT wasn't found *)
Writeln(Temp,Choice); (* so put their choice in anyways *)
Close(Temp);
Erase(Autoprom); (* erase old AUTOEXEC.BAT *)
Rename(Temp,'C:\AUTOEXEC.BAT'); (* make temporary file the AUTOEXEC *)
Writeln;
Writeln;
TextColor(10); Writeln('Big deal huh?'); (* WHAT THE HECK! *)
Writeln;
TextColor(15); Write('Do you want to Reboot for your new prompt to take effect! ');
TextColor(14); Write('[y/n] ');
Pick := Upcase(Readkey); (* read the keypress, make upper case *)
if Pick='Y' Then
Begin (* yes, they want to reboot *)
MEMW[$0040:$0072] := $1234;
INLINE($EA/$00/$00/$FF/$FF);
end;
end;
(*-------------------------------
Main Program
(*-------------------------------*)
Var
Which : Char;
Done : Boolean;
Begin;
Done := False;
Repeat
Clrscr;
Find_Config;
Writeln;
TextColor(13); Write(' ANSI ');
TextColor(11); Write('Color ');
TextColor(10); Write('Prompt ');
TextColor(14); Writeln('v1.0 ');
Writeln;
TextColor(15); Write(' What-The-Heckware From - ');
TextColor(14); Writeln(' The Bad Attitude BBS! ');
TextColor(11); Writeln(' 814-459-2116');
Writeln;
Writeln;
TextColor(9); Writeln(' <1>... Like this? - 12:06 C:\DOS>');
TextColor(10); Writeln(' <2>... Like this? - 12:06 C:\DOS>');
TextColor(11); Writeln(' <3>... Like this? - 12:06 C:\DOS>');
TextColor(12); Writeln(' <4>... Like this? - 12:06 C:\DOS>');
TextColor(13); Writeln(' <5>... Like this? - 12:06 C:\DOS>');
TextColor(14); Writeln(' <6>... Like this? - 12:06 C:\DOS>');
TextColor(15); Writeln(' <7>... Quit!');
Writeln;
TextColor(15);Write(' Pick the color of prompt you like ... ');
Repeat
Which := ReadKey;
Until Which In ['1','2','3','4','5','6','7'];
Write(Which);
Case Which Of
'1' : Choice := 'PROMPT $e[0;1;34m$t$H$H$H$H$H$H $P$G $e[37m';
'2' : Choice := 'PROMPT $e[0;1;32m$t$H$H$H$H$H$H $P$G $e[37m';
'3' : Choice := 'PROMPT $e[0;1;36m$t$H$H$H$H$H$H $P$G $e[37m';
'4' : Choice := 'PROMPT $e[0;1;31m$t$H$H$H$H$H$H $P$G $e[37m';
'5' : Choice := 'PROMPT $e[0;1;35m$t$H$H$H$H$H$H $P$G $e[37m';
'6' : Choice := 'PROMPT $e[0;1;33m$t$H$H$H$H$H$H $P$G $e[37m';
'7' : Done := True; (* they want to quit *)
end;
If Not Done Then (* they pick a prompt from the list so... *)
Auto_Write; (* write the file *)
Until Done;
ClrScr;
Writeln;
Writeln;
END.