ALLPAS.DOC

{Most of these were written by Seth A. Robinson, a few swiped from swag,
and the ones at the end are from Scott Baker's DDPLUS library.

Most are file and string manipulation routines.  Can be used in anything.

Actual string input routines are in SETHPI (for ddpluspi) and SETHLIB (for
standard crt input).

Headers and descriptions.
}

function param_check(s: string): boolean;
{Checks if a certain parm was entered in the commandline, returns yes or
no.}

procedure seth_read_time(var realtime1:longint);
{returns a long number representing the clock time in hundreths of a
second}

procedure strip_danger(var s: string);
{strips out all ` codes that are NOT standard color codes, run this on all
player string input, it allows colors, just nothing else.  It also
reads (if it exists) the BADWORDS.DAT file and replaces badwords
with the replacements specified in the file.

USE THIS ON ALL PLAYER INPUT! - that way if a Sysop wants to allow swearing,
he just has to edit his BADWORDS.DAT file and TEOS *AND* all the IGMS will
automatically change the same.}

procedure strip(var s: string);
{same as above, but doesn't check the badwords dat file.  Used in TEOS for
private mail, which is unsensored.}

function num_of_num(ev: string): integer;
{returns number of numbers in a string}

Function DirExist(st_Dir : string) : Boolean;
{does dir exist?}

procedure unpad(var s:string);

function nice_date : string; {returns a nice todays date}
function nice_time : string; {returns the time in a nice format}
function quick_date : string; {returns both}

{these are easy ways to put the date or time into a string, quick date
is date and time, without year and seconds, with AM or PM}

function match(s1, s2: string) : integer;
{like POS, but only checks from start, not inside of string}

procedure add_text(line, file_name: string);
{appends a text line to a file, if it doesn't exist, it creates it}

function wrap(st: string) : string;

{A very simple word wrap method - send it up a long string, and if it needs
to, it will add "`\  " in a good place and continue the line on the output.
For me, this a carriage return and two spaces, so it matches my games spacing}

function sansi_to_ansi(st: string) : string;
{Give test line with ` color codes (sansi?) and it will return the same
line in regular ansi}

procedure convert_file_to_ansi(f1,f2: string);
{converts a text file of ' sansi to a regular ansi file.  Usefull when
generating score files ect}

procedure convert_file_to_ascii(f1,f2: string);
{Same as above, but strips all sansi out.  Usefull for ascii score files.}


function get_word(s: string; num: integer): string;
{returns one word of a string by number, left to right}

function get_line_starting_at_word(s: string; num: integer): string;
{like above but returns entire string to the RIGHT of a word in a
sentence, by number.  (I know the name is longass, but its a small price
to pay for understandable code!)}

function get_string_part(st,fi: integer;s:string): string;
{lets you get a part of a string.  Like say (6,20) would give back 15
chars in the string, starting at 6 and ending at 20.}

function reverse(st: string):string;
{returns a reversed string}

function tog(tog_c: boolean):boolean;
{toggles a boolean}

Procedure MakeDir(Target : String);
{makes a dir, will make multiple dirs at a time if needed}

function exist(file_name: string): boolean;
{does file exist?}

function safe_file(h,error: longint; file_name: string): boolean;
{A painless way to deal with files.  It isn't file 'locking', it's file
 safety.  If a file is currently being used, it waits and tries again
 and again - until a time limit is up, then it will exit with a error
 and write it in ERROR.LOG.

Remember, you should setfilemode(mode); before opening a file.

Doing setfilemode(readmode); or setfilemode(0); is the same.

  ReadMode      : Byte = 0;
  WriteMode     : Byte = 1;
  NormalMode    : Byte = 2;
  ReadDenyNone  : Byte = 3;
  WriteDenyNone : Byte = 4;


Here is how you use it:

 (1)  file_safety(0,0,''); repeat; {$I-}

{(2)  read(fil, shipd^); here we do the file thing that COULD error } {

 (3)  until file_safety(300,ioresult,'SHIP.DAT'); {$I+}
     {$I-}
{
Lines 1 and 3 are added around every file command that can possibly
error.  Line 1 resets the clock and starts the repeat.

The 300 is how long it should try before assuming something is wrong -
300 is 3 seconds.  ioresult is the error (if any), don't change that.

Instead of SHIP.DAT, replace that with the filename you are currently
working with, this has nothing to do with the procedure, but will make
ERROR.LOG make more sense, as well as the local screen output.

NOTE:  To let the USER see the error, change writeln with your modem out
put line and put the routine in your door, rather than having ALLPAS use
DDPLUS or anything.
}


procedure delete_file(fn: string);
{deletes a file, will not error if it doesn't exist}

function inside(num,low,high: longint): longint;
{a quick way to force NUM to be inside a certain range}

procedure trim(fn:string;n1:longint);
{trims a text file down to number given.  It trims from the top}

function lmon(money: longint): string;
{puts comma's in your longint and returns as a string}

function LZz(w : longint) : String;
{converts ints to string without commas}

function get_dir(s: string): string;
{put the name of the .EXE file with .EXE as the string, and returns the
directory the current program is being run from}

Function get_char_screen (x,y: integer): Char;
{gets a character directly from a screen location}

procedure strip_beginning_spaces(var s: string);


function spad(name:string; num:longint): string;


procedure pad(var name:string; num:longint);
{both add spaces to a string to make it a certain length}

function color_pad(hol: string; num:integer): string;
{Same as above, but takes out color codes while doing the math}

function front_pad(var name:string; num:longint): string;
{Adds spaces to beginning of string to make certain length}

function f_pad(name:string; num:longint): string;
{Same thing but can be passed non-vars}

function lxx(st:string):longint;
{returns a string back as a longint - will be 0 if no #'s are in it}

function seperate_string(str: string; num: integer) : string;
{Returns a section of a string, string must be seperated by |'s}
{used to read IGM data and the badwords.dat file, although you should
never need to}

function say_it(h: boolean): string;
{tiny function to return 'yes or no' depend on true or false of a boolean}

function seth_wait(time_to_wait:longint): longint;
{waiting by clock - 100 is one second, but it's not that precise}

function difference(n1,n2: longint): longint;
{returns the difference between 2 numbers, works with negetives too}

procedure truncate_string(var s: string;len: integer);
{shops a string down to a certain length}

function show_only(h: string;num: shortint) : string;
{like truncate_string, but a function for in the middle on sentences,
does not actually change the string, just the string output.}

function up_string(name: string) : string;
{returns string as all caps}

function write_error(nu: integer) : string;
{give it an error #, and it returns what the problem is}

procedure replace(this,that: string; var inthis: string;all: boolean);
{replaces all instances of 'this' in string with 'that'}

procedure beep;
{beeps a random weird noise, usually to give feedback on checking something
when you don't want to mess with the screen}

function real_length(name: string) : string;
{returns a string with all ` codes stripped out}

function center(f1: string; tot: integer): string;
{returns a centered string (pads spaces on both sides until length meets
integer}
function cen(f1: string; tot: integer): string;
{returns a centered string (pads spaces on left side only}


function ssexist(name,filename: string) : boolean;
{Checks if a @#<name> exists in a file, used in my text database system}

function ssextract(name,filename,new_name: string) : boolean;
{extracts a @#<name> to another text file - on this and above, don't put
the @#, it's added}


{the following are pretty much in everyones library - many were written
by Scott M. Baker and from DDSCOTT.PAS}

Procedure VideoMode(Mode : Byte);
function va(n: integer): string;
function wva(n: word): string;
function lva(n: longint): string;
function tf(d: boolean) : string;
function rva(n: real): string;
function stu(s: string): string;
function locase(c: char): char;
function stl(s: string): string;
function namestr(s: string): string;
function fpad(s:string;h:integer):string;
function date_man: datetype;
function bitcheck(n: word; b: byte): boolean;
procedure setbit(var n: word; b: byte);
procedure resetbit(var n: word; b: byte);
Function CopyFile(SourceFile, TargetFile : String): Byte;

{procedure copyfile(f1,f2: string);
}
function GetHandle(var F : File) : Word;

function DosVer(var Minor : Word) : Word;
function LockFile(Handle : Word; FilePosition,FileLength : LongInt) : Word;
procedure unlock_file(file_name:string);

function dec2hex(w: integer) : string;
function UnLockFile(Handle : Word; FilePosition,FileLength : LongInt) : Word;
procedure get_access_hard(file_name:string);

function RetryFile(Handle,Wait,Retry : Word) : Word;
function hex(i: byte): string;
procedure HexFilt(var s: string);
procedure HexToDec(var s: string);
procedure cursorblock;
procedure cursorw;
function screenaddress: word;
procedure savescreen;
procedure restorescreen;
function hex2dec(what:string) : integer;
Procedure ClrDir ( path : pathStr );
function getvst(s:string;b:byte):string;
procedure setmode(modenumber: byte);
procedure set43lines;
procedure set25lines;
procedure strip_end_spaces(var name: string);
function isega: boolean;
function queryadaptertype: adaptertype;
function determinepoints: integer;
procedure cursoron;
procedure cursoroff;
