home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The World of Computer Software
/
World_Of_Computer_Software-02-385-Vol-1of3.iso
/
t
/
tcsel003.zip
/
GLOBALS.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1992-11-07
|
19KB
|
352 lines
unit globals;
{ Use this unit for procedures, functions and variables that every program you
write will share.
}
interface
uses
dos;
type
str1 = string[1]; str2 = string[2]; str3 = string[3];
str4 = string[4]; str5 = string[5]; str6 = string[6];
str7 = string[7]; str8 = string[8]; str9 = string[9];
str10 = string[10]; str11 = string[11]; str12 = string[12];
str13 = string[13]; str14 = string[14]; str15 = string[15];
str16 = string[16]; str17 = string[17]; str18 = string[18];
str19 = string[19]; str20 = string[20]; str21 = string[21];
str22 = string[22]; str23 = string[23]; str24 = string[24];
str25 = string[25]; str26 = string[26]; str27 = string[27];
str28 = string[28]; str29 = string[29]; str30 = string[30];
str31 = string[31]; str32 = string[32]; str33 = string[33];
str34 = string[34]; str35 = string[35]; str36 = string[36];
str37 = string[37]; str38 = string[38]; str39 = string[39];
str40 = string[40]; str41 = string[41]; str42 = string[42];
str43 = string[43]; str44 = string[44]; str45 = string[45];
str46 = string[46]; str47 = string[47]; str48 = string[48];
str49 = string[49]; str50 = string[50]; str51 = string[51];
str52 = string[52]; str53 = string[53]; str54 = string[54];
str55 = string[55]; str56 = string[56]; str57 = string[57];
str58 = string[58]; str59 = string[59]; str60 = string[60];
str61 = string[61]; str62 = string[62]; str63 = string[63];
str64 = string[64]; str65 = string[65]; str66 = string[66];
str67 = string[67]; str68 = string[68]; str69 = string[69];
str70 = string[70]; str71 = string[71]; str72 = string[72];
str73 = string[73]; str74 = string[74]; str75 = string[75];
str76 = string[76]; str77 = string[77]; str78 = string[78];
str79 = string[79]; str80 = string[80]; str81 = string[81];
str82 = string[82]; str83 = string[83]; str84 = string[84];
str85 = string[85]; str86 = string[86]; str87 = string[87];
str88 = string[88]; str89 = string[89]; str90 = string[90];
str91 = string[91]; str92 = string[92]; str93 = string[93];
str94 = string[94]; str95 = string[95]; str96 = string[96];
str97 = string[97]; str98 = string[98]; str99 = string[99];
str100 = string[100]; str101 = string[101]; str102 = string[102];
str103 = string[103]; str104 = string[104]; str105 = string[105];
str106 = string[106]; str107 = string[107]; str108 = string[108];
str109 = string[109]; str110 = string[110]; str111 = string[111];
str112 = string[112]; str113 = string[113]; str114 = string[114];
str115 = string[115]; str116 = string[116]; str117 = string[117];
str118 = string[118]; str119 = string[119]; str120 = string[120];
str121 = string[121]; str122 = string[122]; str123 = string[123];
str124 = string[124]; str125 = string[125]; str126 = string[126];
str127 = string[127]; str128 = string[128]; str129 = string[129];
str130 = string[130]; str131 = string[131]; str132 = string[132];
str133 = string[133]; str134 = string[134]; str135 = string[135];
str136 = string[136]; str137 = string[137]; str138 = string[138];
str139 = string[139]; str140 = string[140]; str141 = string[141];
str142 = string[142]; str143 = string[143]; str144 = string[144];
str145 = string[145]; str146 = string[146]; str147 = string[147];
str148 = string[148]; str149 = string[149]; str150 = string[150];
str151 = string[151]; str152 = string[152]; str153 = string[153];
str154 = string[154]; str155 = string[155]; str156 = string[156];
str157 = string[157]; str158 = string[158]; str159 = string[159];
str160 = string[160]; str161 = string[161]; str162 = string[162];
str163 = string[163]; str164 = string[164]; str165 = string[165];
str166 = string[166]; str167 = string[167]; str168 = string[168];
str169 = string[169]; str170 = string[170]; str171 = string[171];
str172 = string[172]; str173 = string[173]; str174 = string[174];
str175 = string[175]; str176 = string[176]; str177 = string[177];
str178 = string[178]; str179 = string[179]; str180 = string[180];
str181 = string[181]; str182 = string[182]; str183 = string[183];
str184 = string[184]; str185 = string[185]; str186 = string[186];
str187 = string[187]; str188 = string[188]; str189 = string[189];
str190 = string[190]; str191 = string[191]; str192 = string[192];
str193 = string[193]; str194 = string[194]; str195 = string[195];
str196 = string[196]; str197 = string[197]; str198 = string[198];
str199 = string[199]; str200 = string[200]; str201 = string[201];
str202 = string[202]; str203 = string[203]; str204 = string[204];
str205 = string[205]; str206 = string[206]; str207 = string[207];
str208 = string[208]; str209 = string[209]; str210 = string[210];
str211 = string[211]; str212 = string[212]; str213 = string[213];
str214 = string[214]; str215 = string[215]; str216 = string[216];
str217 = string[217]; str218 = string[218]; str219 = string[219];
str220 = string[220]; str221 = string[221]; str222 = string[222];
str223 = string[223]; str224 = string[224]; str225 = string[225];
str226 = string[226]; str227 = string[227]; str228 = string[228];
str229 = string[229]; str230 = string[230]; str231 = string[231];
str232 = string[232]; str233 = string[233]; str234 = string[234];
str235 = string[235]; str236 = string[236]; str237 = string[237];
str238 = string[238]; str239 = string[239]; str240 = string[240];
str241 = string[241]; str242 = string[242]; str243 = string[243];
str244 = string[244]; str245 = string[245]; str246 = string[246];
str247 = string[247]; str248 = string[248]; str249 = string[249];
str250 = string[250]; str251 = string[251]; str252 = string[252];
str253 = string[253]; str254 = string[254]; str255 = string[255];
const
MaxWord = $ffff;
MinWord = 0;
MinInt = integer($8000);
MinLongint = $80000000;
UseCfg = true;
{Color constants:
Black = 0; Blue = 1; Green = 2; Cyan = 3; Red = 4;
Magenta = 5; Brown = 6; LtGray = 7;
DkGray = 8; LtBlue = 9; LtGreen = A; LtCyan = B; LtRed = C;
LtMagenta = D; Yellow = E; White = F
}
const Blink = $80;
{Screen color constants}
const BlackOnBlack = $00; BlueOnBlack = $01;
const BlackOnBlue = $10; BlueOnBlue = $11;
const BlackOnGreen = $20; BlueOnGreen = $21;
const BlackOnCyan = $30; BlueOnCyan = $31;
const BlackOnRed = $40; BlueOnRed = $41;
const BlackOnMagenta = $50; BlueOnMagenta = $51;
const BlackOnBrown = $60; BlueOnBrown = $61;
const BlackOnLtGray = $70; BlueOnLtGray = $71;
const GreenOnBlack = $02; CyanOnBlack = $03;
const GreenOnBlue = $12; CyanOnBlue = $13;
const GreenOnGreen = $22; CyanOnGreen = $23;
const GreenOnCyan = $32; CyanOnCyan = $33;
const GreenOnRed = $42; CyanOnRed = $43;
const GreenOnMagenta = $52; CyanOnMagenta = $53;
const GreenOnBrown = $62; CyanOnBrown = $63;
const GreenOnLtGray = $72; CyanOnLtGray = $73;
const RedOnBlue = $14; MagentaOnBlue = $15;
const RedOnGreen = $24; MagentaOnGreen = $25;
const RedOnCyan = $34; MagentaOnCyan = $35;
const RedOnRed = $44; MagentaOnRed = $45;
const RedOnMagenta = $54; MagentaOnMagenta = $55;
const RedOnBrown = $64; MagentaOnBrown = $65;
const RedOnLtGray = $74; MagentaOnLtGray = $75;
const BrownOnBlack = $06; LtGrayOnBlack = $07;
const BrownOnBlue = $16; LtGrayOnBlue = $17;
const BrownOnGreen = $26; LtGrayOnGreen = $27;
const BrownOnCyan = $36; LtGrayOnCyan = $37;
const BrownOnRed = $46; LtGrayOnRed = $47;
const BrownOnMagenta = $56; LtGrayOnMagenta = $57;
const BrownOnBrown = $66; LtGrayOnBrown = $67;
const BrownOnLtGray = $76; LtGrayOnLtGray = $77;
const DkGrayOnBlack = $08; LtBlueOnBlack = $09;
const DkGrayOnBlue = $18; LtBlueOnBlue = $19;
const DkGrayOnGreen = $28; LtBlueOnGreen = $29;
const DkGrayOnCyan = $38; LtBlueOnCyan = $39;
const DkGrayOnRed = $48; LtBlueOnRed = $49;
const DkGrayOnMagenta = $58; LtBlueOnMagenta = $59;
const DkGrayOnBrown = $68; LtBlueOnBrown = $69;
const DkGrayOnLtGray = $78; LtBlueOnLtGray = $79;
const LtGreenOnBlack = $0A; LtCyanOnBlack = $0B;
const LtGreenOnBlue = $1A; LtCyanOnBlue = $1B;
const LtGreenOnGreen = $2A; LtCyanOnGreen = $2B;
const LtGreenOnCyan = $3A; LtCyanOnCyan = $3B;
const LtGreenOnRed = $4A; LtCyanOnRed = $4B;
const LtGreenOnMagenta = $5A; LtCyanOnMagenta = $5B;
const LtGreenOnBrown = $6A; LtCyanOnBrown = $6B;
const LtGreenOnLtGray = $7A; LtCyanOnLtGray = $7B;
const LtRedOnBlue = $1C; LtMagentaOnBlue = $1D;
const LtRedOnGreen = $2C; LtMagentaOnGreen = $2D;
const LtRedOnCyan = $3C; LtMagentaOnCyan = $3D;
const LtRedOnRed = $4C; LtMagentaOnRed = $4D;
const LtRedOnMagenta = $5C; LtMagentaOnMagenta = $5D;
const LtRedOnBrown = $6C; LtMagentaOnBrown = $6D;
const LtRedOnLtGray = $7C; LtMagentaOnLtGray = $7D;
const YellowOnBlack = $0E; WhiteOnBlack = $0F;
const YellowOnBlue = $1E; WhiteOnBlue = $1F;
const YellowOnGreen = $2E; WhiteOnGreen = $2F;
const YellowOnCyan = $3E; WhiteOnCyan = $3F;
const YellowOnRed = $4E; WhiteOnRed = $4F;
const YellowOnMagenta = $5E; WhiteOnMagenta = $5F;
const YellowOnBrown = $6E; WhiteOnBrown = $6F;
const YellowOnLtGray = $7E; WhiteOnLtGray = $7F;
const BlackOnDkGray = Blink + $00; BlueOnDkGray = Blink + $01;
const BlackOnLtBlue = Blink + $10; BlueOnLtBlue = Blink + $11;
const BlackOnLtGreen = Blink + $20; BlueOnLtGreen = Blink + $21;
const BlackOnLtCyan = Blink + $30; BlueOnLtCyan = Blink + $31;
const BlackOnLtRed = Blink + $40; BlueOnLtRed = Blink + $41;
const BlackOnLtMagenta = Blink + $50; BlueOnLtMagenta = Blink + $51;
const BlackOnYellow = Blink + $60; BlueOnYellow = Blink + $61;
const BlackOnWhite = Blink + $70; BlueOnWhite = Blink + $71;
const GreenOnDkGray = Blink + $02; CyanOnDkGray = Blink + $03;
const GreenOnLtBlue = Blink + $12; CyanOnLtBlue = Blink + $13;
const GreenOnLtGreen = Blink + $22; CyanOnLtGreen = Blink + $23;
const GreenOnLtCyan = Blink + $32; CyanOnLtCyan = Blink + $33;
const GreenOnLtRed = Blink + $42; CyanOnLtRed = Blink + $43;
const GreenOnLtMagenta = Blink + $52; CyanOnLtMagenta = Blink + $53;
const GreenOnYellow = Blink + $62; CyanOnYellow = Blink + $63;
const GreenOnWhite = Blink + $72; CyanOnWhite = Blink + $73;
const RedOnDkGray = Blink + $04; MagentaOnDkGray = Blink + $05;
const RedOnLtBlue = Blink + $14; MagentaOnLtBlue = Blink + $15;
const RedOnLtGreen = Blink + $24; MagentaOnLtGreen = Blink + $25;
const RedOnLtCyan = Blink + $34; MagentaOnLtCyan = Blink + $35;
const RedOnLtRed = Blink + $44; MagentaOnLtRed = Blink + $45;
const RedOnLtMagenta = Blink + $54; MagentaOnLtMagenta= Blink + $55;
const RedOnYellow = Blink + $64; MagentaOnYellow = Blink + $65;
const RedOnWhite = Blink + $74; MagentaOnWhite = Blink + $75;
const BrownOnDkGray = Blink + $06; LtGrayOnDkGray = Blink + $07;
const BrownOnLtBlue = Blink + $16; LtGrayOnLtBlue = Blink + $17;
const BrownOnLtGreen = Blink + $26; LtGrayOnLtGreen = Blink + $27;
const BrownOnLtCyan = Blink + $36; LtGrayOnLtCyan = Blink + $37;
const BrownOnLtRed = Blink + $46; LtGrayOnLtRed = Blink + $47;
const BrownOnLtMagenta = Blink + $56; LtGrayOnLtMagenta = Blink + $57;
const BrownOnYellow = Blink + $66; LtGrayOnYellow = Blink + $67;
const BrownOnWhite = Blink + $76; LtGrayOnWhite = Blink + $77;
const DkGrayOnDkGray = Blink + $08; LtBlueOnDkGray = Blink + $09;
const DkGrayOnLtBlue = Blink + $18; LtBlueOnLtBlue = Blink + $19;
const DkGrayOnLtGreen = Blink + $28; LtBlueOnLtGreen = Blink + $29;
const DkGrayOnLtCyan = Blink + $38; LtBlueOnLtCyan = Blink + $39;
const DkGrayOnLtRed = Blink + $48; LtBlueOnLtRed = Blink + $49;
const DkGrayOnLtMagenta = Blink + $58; LtBlueOnLtMagenta = Blink + $59;
const DkGrayOnYellow = Blink + $68; LtBlueOnYellow = Blink + $69;
const DkGrayOnWhite = Blink + $78; LtBlueOnWhite = Blink + $79;
const LtGreenOnDkGray = Blink + $0A; LtCyanOnDkGray = Blink + $0B;
const LtGreenOnLtBlue = Blink + $1A; LtCyanOnLtBlue = Blink + $1B;
const LtGreenOnLtGreen = Blink + $2A; LtCyanOnLtGreen = Blink + $2B;
const LtGreenOnLtCyan = Blink + $3A; LtCyanOnLtCyan = Blink + $3B;
const LtGreenOnLtRed = Blink + $4A; LtCyanOnLtRed = Blink + $4B;
const LtGreenOnLtMagenta= Blink + $5A; LtCyanOnLtMagenta = Blink + $5B;
const LtGreenOnYellow = Blink + $6A; LtCyanOnYellow = Blink + $6B;
const LtGreenOnWhite = Blink + $7A; LtCyanOnWhite = Blink + $7B;
const LtRedOnDkGray = Blink + $0C; LtMagentaOnDkGray = Blink + $0D;
const LtRedOnLtBlue = Blink + $1C; LtMagentaOnLtBlue = Blink + $1D;
const LtRedOnLtGreen = Blink + $2C; LtMagentaOnLtGreen= Blink + $2D;
const LtRedOnLtCyan = Blink + $3C; LtMagentaOnLtCyan = Blink + $3D;
const LtRedOnLtRed = Blink + $4C; LtMagentaOnLtRed = Blink + $4D;
const LtRedOnLtMagenta = Blink + $5C; LtMagentaOnLtMagenta= Blink + $5D;
const LtRedOnYellow = Blink + $6C; LtMagentaOnYellow = Blink + $6D;
const LtRedOnWhite = Blink + $7C; LtMagentaOnWhite = Blink + $7D;
const YellowOnDkGray = Blink + $0E; WhiteOnDkGray = Blink + $0F;
const YellowOnLtBlue = Blink + $1E; WhiteOnLtBlue = Blink + $1F;
const YellowOnLtGreen = Blink + $2E; WhiteOnLtGreen = Blink + $2F;
const YellowOnLtCyan = Blink + $3E; WhiteOnLtCyan = Blink + $3F;
const YellowOnLtRed = Blink + $4E; WhiteOnLtRed = Blink + $4F;
const YellowOnLtMagenta = Blink + $5E; WhiteOnLtMagenta = Blink + $5F;
const YellowOnYellow = Blink + $6E; WhiteOnYellow = Blink + $6F;
const YellowOnWhite = Blink + $7E; WhiteOnWhite = Blink + $7F;
var
TempStr : string;
TempStrLen : byte absolute TempStr;
function Exist(fn: str80): boolean;
{ Returns true if file fn exists in the current directory }
function ExistsOnPath(var fn: str80): boolean;
{ Returns true if file fn exists in any directory specified in the current }
{ path and changes fn to a fully qualified path/file. }
function StrUpCase(s : string): string;
{ Returns an upper case string from s. Applicable to the English language. }
function StrLowCase(s : string): string;
{ Returns a string = to s with all upper case characters converted to lower }
function Asc2Str(var s; max: byte): string;
{ Converts an ASCIIZ string to a Turbo Pascal string with a maximum length }
{ of max characters. }
procedure Str2Asc(s: string; var ascStr; max: word);
{ Converts a TP string to an ASCIIZ string of no more than max length. }
{ WARNING: No checks are made that there is sufficient room in destination }
{ variable. }
function LastPos(ch: char; s: string): byte;
{ Returns the last position of ch in s }
procedure CheckIO(a: byte);
implementation
function Exist(fn: str80): boolean;
begin
TempStrLen := 0;
TempStr := FSearch(fn,'');
Exist := TempStrLen <> 0;
end; { Exist }
function ExistsOnPath(var fn: str80): boolean;
begin
TempStrLen := 0;
TempStr := FSearch(fn,GetEnv('PATH'));
ExistsOnPath := TempStrLen <> 0;
fn := FExpand(TempStr);
end; { ExistsOnPath }
function StrUpCase(s : string): string;
var x : byte;
begin
StrUpCase[0] := s[0];
for x := 1 to length(s) do
StrUpCase[x] := Upcase(s[x]);
end; { StrUpCase }
function StrLowCase(s : string): string;
var x : byte;
begin
StrLowCase[0] := s[0];
for x := 1 to length(s) do
case s[x] of
'a'..'z': StrLowCase[x] := chr(ord(s[x]) and $df);
else StrLowCase[x] := s[x];
end; { case }
end; { StrLowCase }
function Asc2Str(var s; max: byte): string;
var starray : array[1..255] of char absolute s;
len : integer;
begin
len := pos(#0,starray)-1; { Get the length }
if (len > max) or (len < 0) then { length exceeds maximum }
len := max; { so set to maximum }
Asc2Str := starray;
Asc2Str[0] := chr(len); { Set length }
end; { Asc2Str }
procedure Str2Asc(s: string; var ascStr; max: word);
begin
FillChar(AscStr,max,0);
if length(s) < max then
move(s[1],AscStr,length(s))
else
move(s[1],AscStr,max);
end; { Str2Asc }
function LastPos(ch: char; s: string): byte;
var x : word;
begin
x := succ(length(s));
repeat
dec(x);
until (s[x] = ch) or (x = 0);
end; { LastPos }
procedure CheckIO(a: byte);
var e : integer;
begin
e := IOResult;
if e <> 0 then begin
writeln('I/O error ',e,' section ',a);
halt(e);
end;
end; { CheckIO }
end. { Globals }