home *** CD-ROM | disk | FTP | other *** search
- {$A-,B-,D-,E-,F+,I-,L-,N-,O-,R-,S-,V-}
- {$M 65520, 0, 655360}
-
- {$DEFINE USETURBODOS}
- {$DEFINE USETURBOCRT}
-
- unit eco_libp;
- interface
- uses
- crt
-
- {$IFDEF USETURBODOS}
- , dos
- {$ENDIF}
-
- ;
-
-
-
-
- {$IFNDEF VER40}
- {$IFNDEF VER50}
- {$IFNDEF VER55}
- {$IFNDEF VER70}
- {$IFNDEF VER10}
- {$DEFINE VER3HEAP}
- {$ENDIF}
- {$ENDIF}
- {$ENDIF}
- {$ENDIF}
- {$ENDIF}
-
-
-
-
-
-
- const
- _dosminorver = 0; _dosmajorver = 5;
- none = $00; only = $40; notnone = $80;
-
- _period = $342E; _colon = $273A; _c_2= $0300;
- _slash = $352F; _padslash = $E02F; _c_6= $071E;
- _c_minus = $0C1F;
- _left = $4BE0; _padleft = $4B00;
- _cleft = $73E0; _cpadleft = $7300;
- _right = $4DE0; _padright = $4D00;
- _cright = $74E0; _cpadright = $7400;
- _up = $48E0; _padup = $4800;
- _down = $50E0; _paddown = $5000;
- _pgup = $49E0; _padpgup = $4900;
- _pgdn = $51E0; _padpgdn = $5100;
- _home = $47E0; _padhome = $4700;
- _chome = $7700; _end = $4FE0;
- _padend = $4F00; _cend = $7500;
- _ins = $52E0; _padins = $5200;
- _del = $53E0; _paddel = $5300;
- _spaddel = $532E; _backspace = $0E08;
- _minus = $0C2D; _padminus = $4A2D;
- _plus = $0D2B; _padplus = $4E2B;
- _star = $092A; _padstar = $372A;
- _enter = $1C0D; _newline = $1C0A;
- _padenter = $E00D;
-
- _tab = $0F09; _s_tab = $0F00;
- _esc = $011B; _space = $3920;
-
- _a = $1E61; _b = $3062; _s_a = $1E41; _s_b = $3042;
- _c = $2E63; _d = $2064; _s_c = $2E43; _s_d = $2044;
- _e = $1265; _f = $2166; _s_e = $1245; _s_f = $2146;
- _g = $2267; _h = $2368; _s_g = $2247; _s_h = $2348;
- _i = $1769; _j = $246A; _s_i = $1749; _s_j = $244A;
- _k = $256B; _l = $266C; _s_k = $254B; _s_l = $264C;
- _m = $326D; _n = $316E; _s_m = $324D; _s_n = $314E;
- _o = $186F; _p = $1970; _s_o = $184F; _s_p = $1950;
- _q = $1071; _r = $1372; _s_q = $1051; _s_r = $1352;
- _s = $1F73; _t = $1474; _s_s = $1F53; _s_t = $1454;
- _u = $1675; _v = $2F76; _s_u = $1655; _s_v = $2F56;
- _w = $1177; _x = $2D78; _s_w = $1157; _s_x = $2D58;
- _y = $1579; _z = $2C7A; _s_y = $1559; _s_z = $2C5A;
-
- _c_a = $1E01; _c_b = $3002; _a_a = $1E00; _a_b = $3000;
- _c_c = $2E03; _c_d = $2004; _a_c = $2E00; _a_d = $2000;
- _c_e = $1205; _c_f = $2106; _a_e = $1200; _a_f = $2100;
- _c_g = $2207; _c_h = $2308; _a_g = $2200; _a_h = $2300;
- _c_i = $1709; _c_j = $240A; _a_i = $1700; _a_j = $2400;
- _c_k = $250B; _c_l = $260C; _a_k = $2500; _a_l = $2600;
- _c_m = $320D; _c_n = $310E; _a_m = $3200; _a_n = $3100;
- _c_o = $180F; _c_p = $1910; _a_o = $1800; _a_p = $1900;
- _c_q = $1011; _c_r = $1312; _a_q = $1000; _a_r = $1300;
- _c_s = $1F13; _c_t = $1414; _a_s = $1F00; _a_t = $1400;
- _c_u = $1615; _c_v = $2F16; _a_u = $1600; _a_v = $2F00;
- _c_w = $1117; _c_x = $2D18; _a_w = $1100; _a_x = $2D00;
- _c_y = $1519; _c_z = $2C1A; _a_y = $1500; _a_z = $2C00;
-
- _f1 = $3B00; _f2 = $3C00; _f3 = $3D00; _f4 = $3E00;
- _f5 = $3F00; _f6 = $4000; _f7 = $4100; _f8 = $4200;
- _f9 = $4300; _f10 = $4400;
-
- _s_f1 = $5400; _s_f2 = $5500; _s_f3 = $5600; _s_f4 = $5700;
- _s_f5 = $5800; _s_f6 = $5900; _s_f7 = $5A00; _s_f8 = $5B00;
- _s_f9 = $5C00; _s_f10 = $5D00;
-
- _c_f1 = $5E00; _c_f2 = $5F00; _c_f3 = $6000; _c_f4 = $6100;
- _c_f5 = $6200; _c_f6 = $6300; _c_f7 = $6400; _c_f8 = $6500;
- _c_f9 = $6600; _c_f10 = $6700;
-
- _a_f1 = $6800; _a_f2 = $6900; _a_f3 = $6A00; _a_f4 = $6B00;
- _a_f5 = $6C00; _a_f6 = $6D00; _a_f7 = $6E00; _a_f8 = $6F00;
- _a_f9 = $7000; _a_f10 = $7100;
-
- _left_just_str = 0;
- _right_just_str = 1;
- _center_str = 2;
-
- _rem_white_str = $0001;
- _rem_lead_white_str = $0002;
- _rem_trail_white_str = $0004;
- _reduce_white_str = $0008;
- _save_quoted_str = $0010;
- _to_upcase_str = $0020;
- _to_lowcase_str = $0040;
- _discard_str = $0080;
-
- _usa_dt_str = 0;
- _euro_dt_str = 1;
- _year_dt_str = 2;
- _mont_dt_str = 3;
- _form_dt_str = 4;
-
- _12hour_str = $0001;
- _inc_sec_str = $0002;
- _inc_tic_str = $0004;
- _inc_ampm_str = $0008;
- _standard_str = $0009;
- _complete_str = $0006;
- _dos_dir_str = $0011;
-
- _ampm_str : array[0..1] of string[3] = (' AM',' PM');
- _ap_str : string[2] = 'ap';
-
- _fmt_buflen_str = 256;
-
- _strmonths : array[1..12] of string[9] = (
- 'January', 'February', 'March', 'April', 'May', 'June', 'July',
- 'August', 'September', 'October', 'November', 'December'
- );
-
- _strdays : array[0..6] of string[9] = (
- 'Sunday', 'Monday', 'Tuesday', 'Wednesday',
- 'Thursday', 'Friday', 'Saturday'
- );
- _colours : array[0..15] of string[12] = (
- 'Black', 'Blue', 'Green', 'Cyan', 'Red', 'Magenta', 'Brown',
- 'LightGray', 'Darkgray', 'LightBlue', 'LightGreen', 'LightCyan',
- 'LightRed', 'LightMagenta', 'Yellow', 'White'
- );
-
- _strusach : char = '/';
- _streuroch : char = '-';
- _strmoneych : char = 'f';
-
- _dirslash : char = '/';
- _dircase : word = _to_lowcase_str;
-
- fk_ctrl_mark: char = '^';
- nonblock : char = '-';
- block : char = 'X';
- maxstr_ = 255;
-
- {$IFNDEF USETURBODOS}
-
- (* flags bit masks *)
-
- fcarry = $0001;
- fparity = $0004;
- fauxiliary = $0010;
- fzero = $0040;
- fsign = $0080;
- foverflow = $0800;
-
- (* file mode magic numbers *)
-
- fmclosed = $d7b0;
- fminput = $d7b1;
- fmoutput = $d7b2;
- fminout = $d7b3;
-
-
- (* file attribute constants *)
- readonly = $01;
- hidden = $02;
- sysfile = $04;
- volumeid = $08;
- directory = $10;
- archive = $20;
- anyfile = $3f;
- {$ENDIF}
-
-
- type
- stream = file;
- {$IFNDEF USETURBOCRT}
- textbuf = array [0..127] of char;
- textrec = record
- handle : word;
- mode : word;
- bufsize : word;
- private : word;
- bufpos : word;
- bufend : word;
- bufptr : ^textbuf;
- openfunc : pointer;
- inoutfunc : pointer;
- flushfunc : pointer;
- closefunc : pointer;
- userdata : array [1..16] of byte;
- name : array [0..79] of char;
- buffer : textbuf;
- end;
- {$ENDIF}
-
- comstr = string[127]; { command line string }
- pathstr = string[79]; { full file path string }
- dirstr = string[67]; { drive and directory string }
- namestr = string[8]; { file name string }
- extstr = string[4]; { file extension string }
- filestr = string[12]; { file name + extension string }
-
- {$IFNDEF USETURBODOS}
- registers = record case integer of
- 0 : (ax,bx,cx,dx,bp,si,di,ds,es,flags : word);
- 1 : (al,ah,bl,bh,cl,ch,dl,dh : byte);
- end;
- searchrec = record
- fill : array [1..21] of byte;
- attr : byte;
- time : longint;
- size : longint;
- name : string[12];
- end;
- datetime = record
- year,month,day,hour,min,sec : word;
- end;
- {$ENDIF}
-
- _memorychar = array[1..65534] of char;
- _vectoraddr = record _ofs : word; _seg : word end;
- str3 = string[3];
- str8 = string[8];
- str9 = string[9];
- str32 = string[32];
- anystr = string;
- asciiz = array[0..255] of char;
- asciizptr = ^asciiz;
- ar1024 = array[1..1024] of char;
-
-
-
- const
- nullchar = $00;
- colon = ':';
- period = '.';
- separ = 'ยท';
- space = ' ';
- zero = '0';
- maxtimer = 10;
-
- type
- daterecord = record
- year : word;
- month : word;
- date : word;
- dayofweek : word
- end;
-
- timerecord = record
- hour : word;
- minute : word;
- second : word;
- hundredth : word
- end;
-
- clockrecord = record
- clockstartdate : daterecord;
- clockstarttime : timerecord;
- elapsedtime : timerecord;
- clockisrunning : boolean;
- end;
-
- var
- clockarray : array[0..maxtimer] of clockrecord;
- exitcode : word;
- {$IFNDEF USETURBODOS}
- doserror : integer;
- {$ENDIF}
- _dosdrv : integer;
- _dosdrvchar : char;
- _doscurpath : pathstr;
- _dospath : string;
- _dosdiscfree,
- _dosdiscsize : longint;
-
-
-
-
-
-
-
-
- { BASE STRING FUNCTIONS XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX }
- function __leftstr(source : string; num : word): string;
- function __rightstr(source : string; chpos : word): string;
- function __substr(source : string; chpos, num: word): string;
- function __midstr(source,target : string; chpos: word): string;
- function __fillstr(
- fillch : char; target : string;
- chpos,num : word
- ): string;
- function __xlatestr(source,table,trans : string) : string;
- function __juststr(
- source : string; fillch : char;
- fieldsize : word;
- justcode : word
- ): string;
- function __cvtstr(source : string; cvtcode : word) : string;
- function __entabstr(source : string; incr : byte) : string;
- function __detabstr(
- source : string; incr : byte;
- var remstr : string
- ): string;
- function __toradstr(
- intvalue : longint;
- size,radix,width: word
- ): string;
- function __todecstr(intvalue: longint; size: word) : string;
- function __tohexstr(intvalue: longint; size: word) : string;
- function __ptr2str(thisptr: pointer): string;
- function __formstr(mask : string; x : real) : string;
- procedure __initfstr(var fmtfil : text);
- function __retbfstr(var fmtfil : text) : string;
- function locase(ch: char): char;
- function __part(s: string; a, b: byte): string;
-
-
-
-
-
-
-
- { SECONDARY STRING FUNCTIONS XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX }
- procedure __app(var st: string; aps: string);
- function __backapp(s: string) : string;
- function __backrem(s: string) : string;
- function __lastchr(s: string) : char;
-
- function __comp(s1, s2: string): boolean;
- function __overtype(n:byte;strs,strt:string):string;
- function __rep(n: byte; character: char): string;
- function __nw(s: string): string;
-
- function __pntstr(n: longint): string;
- function __up(s: string): string;
- function __lo(s: string): string;
- function __uprem(s: string): string;
-
- function __hexdecstr(hexstr: string): longint;
- function __str(st: string): integer;
- function __num(nr: longint): string;
- function __val(st: string): longint;
- function __real(st: string): real;
- function __streal(nr: real; decs: byte): string;
-
- function __byte2str(b: byte): str8;
- function __str2byte(s: str8): byte;
- function __longint2str(l: longint): str32;
- function __str2longint(s: str32): longint;
-
- procedure __str2obj(s: anystr; var a; length_a: integer);
- procedure __str2arr(s: anystr; var a; length_a: integer);
- function __readctrls(s: anystr): anystr;
- function __writectrls(s: anystr): anystr;
- function __az2str(a: asciiz): string;
- procedure __str2az(s: string; var a : asciiz);
-
- procedure __clr1024(var a: ar1024);
- procedure __app1024(var app: ar1024; s: string);
- function __len1024(var a: ar1024) : word;
- procedure __del1024(var a: ar1024; b, l: word);
- procedure __ins1024(var a: ar1024; b : word; s: string);
- procedure __write1024(var a: ar1024);
-
- function __nonascii(s: string): boolean;
- function __killnonascii(s: string): string;
-
-
-
-
-
- { PRIMARY DATA CONVERSION FUNCTIONS XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX }
- function __main(b: longint; w: word): longint;
- function __max(v1, v2: longint): longint;
- function __min(v1, v2: longint): longint;
- function __power(x,y: integer): longint;
-
-
-
- function __2longsup(hiword,loword : word): longint;
- inline($58 { pop ax } /$5A); { pop dx }
-
- function __hiwrdsup(intvalue : longint) : word;
- inline($58 { pop ax } /$58); { pop ax }
-
- function __lowrdsup(intvalue : longint) : word;
- inline($58 { pop ax } /$5A); { pop dx }
-
- function __2wordsup(hibyte,lobyte : byte) : word;
- inline($58 { pop ax } /$5A { pop dx } /$8A/$E2); { mov ah,dl }
-
- function __2bytesup(hinybble,lonybble : byte) : byte;
- inline(
- $5B/ { pop bx } $58/ { pop ax }
- $32/$E4/ { xor ah,ah } $b1/$04/ { mov cl,4 }
- $d3/$E0/ { shl ax,cl } $80/$e3/$0f/ { and bl,0fh }
- $0A/$C3 { or al,bl }
- );
-
- function __hinybsup(bytevalue : byte) : byte;
- inline(
- $58 { pop ax } /$32/$E4 { xor ah,ah }
- /$B1/$04 { mov cl,4 } /$D3/$E8 { shr ax,cl }
- );
-
- function __lonybsup(bytevalue : byte) : byte;
- inline($58 { pop ax } /$25/$0F/$00); { and ax,000fh }
-
- procedure __fcallsup(procptr : pointer; var reg : registers);
- inline(
- $8B/$DC/ { mov bx,sp } $83/$C3/$04/ { add bx,4 }
- $36/$FF/$1F/ { call dword ptr ss:[bx] } $83/$C4/$04 { add sp,4 }
- );
-
- procedure __ncallsup(procptr : pointer; var reg : registers);
- inline(
- $8B/$DC { mov bx,sp } /$83/$C3/$04 { add bx,4 }
- /$36/$FF/$17 { call word ptr ss:[bx] } /$83/$C4/$04 { add sp,4 }
- );
-
- function __caddrsup : pointer;
- inline(
- $8B/$46/$02 { mov ax,[bp + 2] } /$2D/$03/$00 { sub ax,3 }
- /$8B/$56/$04 { mov dx,[bp + 4] }
- );
-
- procedure __iptrsup (var p : pointer; n : longint);
- procedure __dptrsup (var p : pointer; n : longint);
- function __nptrsup (thisptr : pointer) : pointer;
- function __ptr2lsup(thisptr : pointer) : longint;
- procedure __fillwsup(var target; count : longint; fillword : word);
- procedure __fillbsup(var target; count : longint; fillbyte : byte);
- procedure __repmsup (var target,source; count : longint; sourcesize : word);
- function __alphasup(ch : char) : boolean;
-
-
-
-
-
-
- { IMPORTANT DOS FUNCTIONS XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX }
- const
- _keep_mode = -1; { do not change file mode in fopen }
- _readonly = $00; { share mode dos 3++ and above }
- _denyall = $10;
- _writeonly = $01;
- _denywrite = $20;
- _readwrite = $02;
- _denyread = $30;
- _denynone = $40;
-
- lockregion = 00;
- unlockregion = 01;
-
-
- {typed}const
- casesensitive_env: boolean = false;
-
- var
- lastkey : char;
- lastscan : byte;
- _envseg : word;
- envsize_ : word;
- envmemptr_,
- _envptr,
- envptr : pointer; { pointer to environment table }
- registeredprogname : string;
-
-
- {$IFNDEF USETURBODOS}
- procedure getdate(var year,month,day,dayofweek : word);
- procedure setdate(year,month,day : word);
- procedure gettime(var hour,minute,second,sec100 : word);
- procedure settime(hour,minute,second,sec100 : word);
-
- function diskfree(drive : byte) : longint;
- function disksize(drive : byte) : longint;
-
- procedure getfattr(var f;var attr : word);
- procedure setfattr(var f;attr : word);
- procedure getftime(var f;var time : longint);
- procedure setftime(var f;time : longint);
-
- procedure findfirst(path : pathstr;attr : word;var f : searchrec);
- procedure findnext(var f : searchrec);
-
- function fexpand(path : pathstr) : pathstr;
- procedure fsplit(
- path : pathstr;var dir : dirstr;
- var name : namestr;var ext : extstr
- );
- procedure intr(intno: byte; var regs: registers);
- procedure getintvec(intno: byte;var vector: pointer);
- procedure swapvectors;
- {$ENDIF}
-
- function __existfil(pathname : string) : boolean;
- procedure __erasefil(filename : pathstr; var errorcode : word);
- function __progname: string;
-
-
- type
- _keystatus = record { keyboard shift status record }
- _rightctrlshift: boolean; { right ctrl depressed }
- _rightaltshift : boolean; { right alt depressed }
- _insstate : boolean; { insert state is active }
- _capsstate : boolean; { caps lock key toggled }
- _numstate : boolean; { num lock key toggled }
- _scrollstate : boolean; { scroll lock key toggled }
- _altshift : boolean; { alt shift key depressed }
- _ctrlshift : boolean; { ctrl shift depressed }
- _leftshift : boolean; { left shift key depressed}
- _rightshift : boolean; { right shift depressed }
- _insshift : boolean; { ins key depressed }
- _capsshift : boolean; { caps lock key depressed }
- _numshift : boolean; { num lock key depressed }
- _scrollshift : boolean; { scroll lock depressed }
- _holdstate : boolean; { suspend state toggled }
- _sysshift : boolean; { sysreq depressed & held }
- _leftctrlshift : boolean; { left ctrl depressed }
- _leftaltshift : boolean; { left alt depressed }
- end;
-
-
- function __dosinkey(var extendedcode : byte) : char;
- function __retkey: word;
- function __retdelaykey(delaytim: byte; default: word): word; { delay < 60 }
- function __exinkey(useextended: boolean; var scancode: byte): char;
- function __exrdykey(
- useextended : boolean;
- var nextch : char;
- var scancode : byte
- ) : boolean;
- function keypressed : boolean;
- procedure __flushkey;
- function __queuekey : word;
- procedure __delay(w: word);
- procedure __delaykey(w:word);
- function __spaceutl(
- drive : byte;
- var availclus, totalclus,
- bytespersec, secsperclus: word
- ): longint;
- function __paridutl(var cmdprocid : word) : word;
- function cmdenvseg(var cmdprocid: word): word;
- function __putenutl(envstr: string): string;
- function __retenutl(var envpos : word) : string;
- function __chgenutl(progseg: word; envstr: string; var error: word): string;
- function __envpath(st: string): string; { ends on \ }
- function __getpath(var fname : string) : boolean;
-
- function __address(zone, net, node, point: integer): string;
- procedure __expandnum(
- node : string; var tozone, tonet, tonode, topoint: word
- );
- function __expandchr(st: string; c: char; chh: string): string;
- function __statkey(var status : _keystatus) : longint;
- function __ctrlkey(status : _keystatus) : longint;
- function __stuffkey(charstr : string) : string;
- procedure __resetsup(testmem : boolean);
- procedure __resetfil;
-
-
-
-
-
-
-
-
-
- { LOCK FUNCTIONS }
- function fopen(var fv : stream; fn : pathstr; mode : integer) : integer;
- function fclose(var fv : stream) : integer;
- function shareloaded : boolean;
- function filelock(
- handle : word;
- action : byte;
- start,
- bytes : longint;
- var ax : integer
- ): boolean;
-
-
-
-
-
- { DATE FUNCTIONS XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX }
- function __dt2ststr(year, month, day, datefmt : word): string;
- function __datestr(var year,month,day: word): string;
- function __timestr(var hours,minutes,seconds,tics: word): string;
- procedure __st2dtstr(st: string; var year, month, day: word; datefmt: word);
- function __time2str(hours, mins, secs, tics, format: word): string;
- function __2timestr(timestr: string; var hours,mins,secs,tics:word): boolean;
-
- function __retdowstr(dayofweek: word; ful: boolean): string;
- function __todaystr(ful: boolean): string;
- procedure __jl2dtutl(julian: longint; var year, month, day, weekday: word);
- function __dt2jlutl(year, month, day : word) : longint;
- function __daysutl(yr1, mn1, day1 : word; yr2, mn2, day2 : word) : longint;
- function __retdow(y, m, d: word): word;
- function __today: byte;
-
- function __curdate: string;
- function __curdate2longint: longint;
- function __longint2date(l: longint): string;
- function __date2longint(d: string): longint; { 'xx NNN yy HH:MM.ss' }
- { eg. '22 Aug 69 14:50.11' }
- procedure __longint2datetime(d : longint; var dt : datetime);
- function format_date(dt : datetime; format : byte): string;
- function __formatdate(d : longint; format : byte): string;
-
- function __dbdate: string;
- function __radate: string;
-
- {$IFNDEF USETURBODOS}
- procedure unpacktime(p : longint;var t : datetime);
- procedure packtime(var t : datetime;var p : longint);
- {$ENDIF}
-
-
-
-
-
- { IMPORTANT TIMER FUNCTIONS XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX }
- procedure starttimer(whichclock : byte);
- function getlaptime(whichclock : byte) : string;
- procedure restarttimer(whichclock : byte);
- function stoptimer(whichclock : byte) : string;
-
-
-
-
-
-
- { IMPORTANT FILE FUNCTIONS XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX }
- const
- info : array[0..6] of string[27] = (
- 'Successful.',
- 'Source and target the same!',
- 'Cannot open source!',
- 'Unable to create target!',
- 'Error during copy!',
- 'Cannot allocate buffer!',
- 'Not enough free discspace!'
- );
- function __retdrfil : char;
- function __attrfilter(fileattr, filter: byte): boolean;
- function __bak(s: string): string;
- function __comexebatcmdfilter(s: string): boolean;
- function __curdir: string;
- function __deverr: string;
- procedure __drvparm(drv: char);
- procedure __erasefiles(s: string);
- function __existpath(s: string): boolean;
- function __extractext(name: string): str3;
- function __extractname(s : string): string;
- function __extractnamext(s : string): string;
- function __extractpath(s : string): string;
- function __findfil(f: string; var s: string): boolean;
- function __inparams(s: string; var i: word): boolean;
- function __checkstr(pa, en: string; var j, k : word): boolean;
- function __packfil(str: string; size: byte): string;
- procedure __parsefil(name: filestr; var nam: namestr; var ext: extstr);
- function __slashfil(s: string): string;
- function __normfil(filename : pathstr) : pathstr;
- procedure __splitfil(
- pathname : pathstr;
- var subdir : dirstr;
- var filename : namestr;
- var fileext : extstr
- );
- function __searchrec(
- src : searchrec;
- nm, woord, mainsize : word;
- takemainsize, extended,
- ampm, show_attr,
- wide : boolean
- ): string;
- function __sizefil(pt: string): longint;
- function __strattr(attr: byte; full: boolean): string;
- procedure __uniquefil( { i.s.o. __tempfil, an unique textfile }
- var pathname: string; var tmpfile: text; var errorcode: word
- );
- function __copyfil(show: boolean; x1,x2,y,f,b: byte; fs: longint; src, targ: string): byte;
- procedure __renamfil(prevname,newname : pathstr; var errorcode : word);
- function __slicefil(x1, x2, y, f, b: byte; haksize:longint; src:string): byte;
- function __isdrvfil(drive : char; var errorcode : word) : boolean;
- function __retvlfil(drive : char; var volstamp : longint) : string;
- function __handlfil(var filevar) : word;
- function __isconfil(handle : word) : boolean;
-
-
-
-
-
-
-
-
-
-
-
-
- const
- maxfiles = 4096;
-
- type
- filarraytype = array[1..maxfiles] of ^searchrec;
- filarraytypeptr = ^filarraytype;
- sortmethods = (on_name, on_extension, on_datetime, on_size);
- condition_attrstype = record
- show_r_o : boolean;
- show_hid : boolean;
- show_sys : boolean;
- show_arc : boolean;
- show_vol : boolean;
- show_dir : boolean;
- show_non : boolean;
- sort_method : sortmethods;
- end;
-
- const
- std_condition_attrs : condition_attrstype = (
- show_r_o : true;
- show_hid : true;
- show_sys : true;
- show_arc : true;
- show_vol : true;
- show_dir : true;
- show_non : true;
- sort_method : on_name
- );
-
-
- var
- conditionfuncptr_ : pointer;
- filitems : word;
-
- {$F+}
-
- const
- renew_space : boolean = true;
-
- procedure set_std_condition_attrs(attrs: condition_attrstype);
- procedure __dirutl(
- comexebatcmdfilter : boolean;
- searchpath : pathstr;
- var filar : filarraytypeptr;
- searchattr : byte;
- manipulate : byte;
- var error,
- counted_dirs : word;
- vol_counted : boolean;
- condit,
- sorter : pointer;
- var totnum : longint
- );
- procedure dispose_filarray(var fil: filarraytypeptr);
- procedure new_filarray(var fil: filarraytypeptr);
- function std_sort(var data1, data2): boolean;
- function std_condition(var srec): boolean;
- function no_condition(var srec): boolean;
-
-
-
-
-
- { XXXXXXXXXX LOG FUNCTIONS XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX }
- const
- logfilename : pathstr = 'ECOPURGE.LOG'; { 22 Aug 69 14:50.11 }
- programname : string[40] = 'ECOPURGE';
- purge : byte = 7;
- lines : word = 512;
-
- var
- logheader : array[1..11] of string[62];
- error,
- yr, mo, da : word;
- i : byte;
-
-
-
- procedure __loginit;
- procedure __logapp(s: string);
- procedure __filapp(fil, s : string);
-
- procedure __setpurge(b: byte);
- procedure __logpurge;
-
- function __recent(s: string): boolean;
-
-
-
-
-
- { XXXXXXXXXXXX FAST SCREEN FUNCTIONS XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX }
-
- type
- _scnpos = record _ch : char; _attr : byte end;
- _scnimage = array[1..4000] of _scnpos;
- _scnimageptr = ^_scnimage;
- str80 = string[80];
- _monitortype = (
- _nomonitor,
- _monomonitor, { monochrome monitor }
- _colormonitor, { color monitor (composite also) }
- _enhancedmonitor, { ega rnhanced color monitor }
- _anmonomonitor, { ps/2 analog monochrome monitor }
- _ancolormonitor { ps/2 analog color monitor }
- );
-
-
- const
- fcol: byte = 7;
- bcol: byte = 0;
- bt_double = 15; bt_single = 1;
- sh_default = 255; sh_high = 254; sh_low = 253;
- black = 00; blue = 01;
- green = 02; cyan = 03;
- red = 04; magenta = 05;
- brown = 06; lightgray = 07;
- darkgray = 08; lightblue = 09;
- lightgreen = 10; lightcyan = 11;
- lightred = 12; lightmagenta = 13;
- yellow = 14; white = 15;
- blink = 128;
-
- _unknown = $7f;
- _absent = 0; { no adapter installed }
- _mono = 1; { monochrome type adapter }
- _color = 2; { color type adapter }
-
- _biosseg = $0040; { segment of bios/dos communica- }
-
-
- var
- _hidemouse : byte;
- baseofscreen,
- vseg, vofs,
- rows, cols,
- _curcolumns, { number of screen columns }
- _currows : word; { number of screen rows }
-
- _scnloc : _scnimageptr; { screen adapter memory location }
- _curmonitor : _monitortype; { monitor attached to _curdevice }
- _curmode : byte; { current video display mode }
- _curdevice : byte; { _mono or _color device }
- _maxdisplaypage : byte; { maximum display page number }
- _curdisplaypage : byte; { current video display page }
- _curactivepage : byte; { current video active page }
- _monoadapter : byte; { monochrome adapter }
- _coloradapter : byte; { color/graphics adapter }
- _egaadapter : byte; { ega adapter }
- _hercadapter : byte; { hercules mono graphics card }
- _vgaadapter : byte; { ps/2 video graphics array }
- _mcgaadapter : byte; { ps/2 model 30 adapter }
- _scrolltab : word; { spaces to skip for tab scroll }
- _tabincr : word; { tab increment for _txbufscn }
- _bufindent : word; { left margin for _txbufscn }
-
- {scnstate_ : scnstat_; } { bios video save information }
- {availcolormodes_ : videomodes_; } { modes available on color device}
- {availmonomodes_ : videomodes_; } { modes available on mono device }
- {availcolorrows_ : legalrows_; } { rows available on color device }
- {availmonorows_ : legalrows_; } { rows available on mono device }
- {dualdisplay_ : boolean; } { two adapters present }
- egamonitor_ : _monitortype; { monitor attached: ega }
- analogmonitor_ : _monitortype; { monitor attached: vga/mcga }
- egamemory_ : word; { 64, 128, 192, or 256 (k) }
- maxscanline_ : byte; { current character set size }
-
- var
- scn1, scn2,
- scn3, scn4 : _scnimageptr;
-
- function at(f, b: byte): byte;
- function __loc(x, y : byte; var fore, back : byte): char;
- procedure __scn(col, row, attr: byte; st: str80);
- procedure __vid(col, row: byte; st: str80);
- procedure changeattr(col,row,attr: byte; number: word);
- function get_video_mode: byte;
-
- { extended functions, just like in eco_vid, but for small use }
- procedure __attrib(x1, y1, x2, y2, f, b: byte);
- procedure __bandwin(del: boolean; x1,y1,x2,y2,f,b,shadow,bt: byte);
- procedure __betwscn(x1, x2, y, f, b: byte; st: string);
- procedure __boxscn(x1,y1,x2,y2,boxtype,fore,back : byte);
- procedure __clrscn(x1, y1, x2, y2, f, b: byte; c: char);
- procedure __cls;
- procedure __copyscn(x1, y1, x2, y2, x, y: byte);
-
- procedure __equipscn;
- function __retdvscn(
- var dvmode : byte;
- var dvcols : word;
- var dvrows : word;
- var dbactpage : byte;
- var dvdispage : byte
- ): byte;
-
- procedure __vert(x, y, f, b: byte; s: string);
- procedure __write(col, row, f, b: byte; st: str80);
- procedure __hwrite(x, y, f, b, h: byte; st: string);
-
- procedure __resscn(sc: _scnimageptr);
- procedure __savscn(sc: _scnimageptr);
- procedure __speedscn(
- sourceptr,targetptr : pointer;
- count,option,attribute : word;
- wait : boolean
- );
- function __barchoice(x,x1,y,f,b,h : byte; st: string; timeout: byte): byte;
- { error = 255: debugging mode; else no debuginfo display }
- function __barcheck(s: string; var error: byte): boolean;
- procedure __setblwin(blinkon : boolean);
-
-
-
-
-
-
- { XXXXXXXXXXXX CRT FUNCTIONS XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX }
- procedure __stdio;
-
-
-
-
-
-
-
- { XXXXXXXXXXXX TEXT FUNCTIONS XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX }
-
- type
- strptr = ^string;
- textnodeptr = ^textnode;
- textnode = record
- next,prev :textnodeptr; {line may not be made longer}
- line :strptr; {allocation is length+1}
- end;
- textbuffer = record
- first,last :textnodeptr;
- end;
-
- {-
- Note: Don't mess around inside the data structures defined above.
- Use the procedures to access them instead. This unit should be
- written object orientated. Some procedures don't use all their
- parameters at the moment. This is intentional and will be useful
- if the structures are enhanced.
- -}
-
- {- initialise an empty buffer -}
- procedure newbuffer(var t :textbuffer);
-
- {- return true if the buffer is empty -}
- function emptybuffer(var t :textbuffer) :boolean;
-
- {- return a pointer to the first line of a buffer -}
- function firstline(var t :textbuffer) :textnodeptr;
-
- {- return a pointer to the last line of a buffer -}
- function lastline(var t :textbuffer) :textnodeptr;
-
- {- return the next line in a buffer -}
- function nextline(var t :textbuffer; pos :textnodeptr) :textnodeptr;
-
- {- return the previous line in a buffer -}
- function prevline(var t :textbuffer; pos :textnodeptr) :textnodeptr;
-
- {- add a line to the end of a buffer -}
- procedure addtoend(var t :textbuffer; line :string);
-
- {- insert a line before another line -}
- procedure addinsert(var t :textbuffer; pos :textnodeptr; line :string);
-
- {- delete a line and return the next line or nil if it was the last line -}
- function deleteline(var t :textbuffer; var pos :textnodeptr) :textnodeptr;
-
- {- delete a buffer -}
- procedure deletebuffer(var t :textbuffer);
-
- {- retrieve the text value from a line -}
- function gettextline(var t: textbuffer; pos :textnodeptr) :string;
-
- {- assign a new string to a line of text -}
- procedure modifytextline(var t: textbuffer; pos :textnodeptr; line :string);
-
- {- word wrap the buffer -}
- procedure wrapbuffer(var t :textbuffer; margin :byte);
-
- {- create a new buffer with maximum length (255) lines -}
- procedure unwrapbuffer(var t,w :textbuffer);
-
- {- count the number of lines in a buffer -}
- function bufferlength(var t :textbuffer) :word;
-
-
-
-
-
-
- { XXXXXXXXXXXX CRC FUNCTIONS XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX }
- function __crc32(value: byte; crc: longint) : longint;
- function __crc16(value: byte; crc: word) : word;
-
-
-
-
-
-
-
-
-
- { XXXXXXXXXXXX SELECTION FUNCTIONS XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX }
-
- const
- _fore : byte = 7;
- _back : byte = 0;
- _x1 : byte = 10;
- _y1 : byte = 5;
- _x2 : byte = 30;
- _y2 : byte = 15;
-
- _noerror_sel = 0;
- _nopickrec_sel = 1;
- _invwindow_sel = 2;
- _invpath_sel = 3;
- _dispwin_sel = 4;
- _titlewin_sel = 5;
- _remwin_sel = 6;
- _zapwin_sel = 7;
- _memalloc_sel = 8;
- _selerror : word = _noerror_sel;
- _nofilesmsg : string[10] = ' No Files';
- _name_fmt_sel = 0;
- _dos_fmt_sel = 1;
-
-
- type
- _pickptr = ^_pick;
- _pick = record
- _barfore : byte;
- _barback : byte;
- _keyproc : pointer;
- _itemlen : word;
- _numitems : word;
- _itemsize : word;
- _numcols : word;
- _spacing : word;
- _itemaddr : pointer;
- _pointers : boolean;
- _firstpage : word;
- _lastpage : word;
- _curitemnum : word;
- _curitemptr : pointer;
- end;
-
-
- var
- _initpickkey : word;
-
-
- function __makesel(
- x1, y1,
- x2, y2,
- fore, back,
- barfore,
- barback : byte;
- keyproc : pointer;
- itemlen : word;
- numitems : word;
- itemsize : word;
- numcols : word;
- spacing : word;
- itemaddr : pointer;
- ispointers : boolean
- ) : _pickptr;
-
- function __picksel(
- listpickptr : _pickptr;
- var retitem : string;
- var retkey : word
- ) : word;
-
- procedure __itemsel(pickptr: _pickptr; fore, back: byte; itemno: word);
- function __zapsel(var pickptr : _pickptr) : boolean;
-
-
-
-
-
-
-
- { XXXXXXXXXXXX SELECTION FUNCTIONS XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX }
- type
- _editctrl = record
- _viewx1,
- _viewx2,
- _viewy1,
- _vscnfore,
- _vscnback,
- _vscncols : word;
- _showflags : boolean;
- _mask : string; { ( * ) }
- end;
-
- { masks are currently not supported }
- {-------------------------------------------------------------}
- { }
- { ( * ) masking }
- { }
- { Format Char Input Allowed }
- { ----------------------------------------------------- }
- { & (Any character) }
- { # 0-9,+,-,. }
- { 9 0-9 }
- { X 0-9,+,-,.,A-Z,a-z,#32 (space) }
- { Y (Same as X, convert to upper case) }
- { y (Same as X, convert to lower case) }
- { A A-Z,a-z,#32 (space) }
- { B (Same as A, convert to upper case) }
- { b (Same as A, convert to lower case) }
- { ^ (Escape--treat next character as literal) }
- { * same as &, but report * as user input (pwd)}
- { }
- { Literal characters are displayed at the corresponding }
- { position within the data input field and are unaffected }
- { by operator input (the cursor skips over them). A }
- { format character is treated as a literal character if it }
- { is preceded by a single escape character ('^'). }
- { }
- { If a mask is specified, InitStr is validated against }
- { the mask, and if found invalid __editline exits with }
- { ErrorCode = 2. Thereafter, the entire edit buffer }
- { is validated against the mask with each keypress. }
- { Invalid keystrokes cause the system speaker to sound and }
- { leave the edit buffer unchanged. Inserting or }
- { deleting a character will be disallowed if it 'pushes' }
- { or 'pulls' a character into an invalid position relative }
- { to the mask. }
- { }
- { Examples of masks: }
- { }
- { '(999) 999-9999' (telephone number) }
- { '99/99/99' (date) }
- { '999-99-9999' (social security number) }
- { 'B-99999' (part number, initial alpha char) }
- { '#########' (real number) }
- { 'AAAAAAAAAAAAAAAAA' (name field, alpha only) }
- { }
- { Case conversion specified by a mask takes precedence }
- { over case conversion specified with _EditMode. }
- { }
- { The editing viewport: If the length of the field }
- { defined in _editctrl (_ViewX2 - _ViewX1 + 1) is less }
- { than the number of columns in the edit buffer }
- { (_VScnCols), editing may take place in a viewport which }
- { is shorter than the length of the edit buffer. In such }
- { a case, moving the cursor to a position within the }
- { buffer which is not currently visible causes the }
- { buffer to scroll within the viewport. }
- {_____________________________________________________________}
-
-
- function __editline(var st: string; control: _editctrl): boolean;
-
-
-
-
-
-
- { memory management }
- const
- _max_getmem = 65520;
- _alloconfail : word = 0;
-
- type
- _xads = record
- _loword : word;
- _hibyte : byte
- end;
-
- _progsize = record
- _codesize : word;
- _datasize : word;
- _stacksize : word;
- _overlaysize : word;
- _heapsize : word
- end;
-
- _memctrl = record
- _header : char;
- _ownerpsp : word;
- _size : word;
- _reserved : array[1..11] of byte
- end;
-
- _freerec = record
- _freeblockptr : pointer;
- _nextblockptr : pointer
- end;
-
- _freelist = array[0..8190] of _freerec;
-
-
-
- procedure __totalmem(var dosmemory, extmemory : word);
- procedure __availmem(
- var dosmemory, extmemory: word; var memptr: pointer; var extads: _xads
- );
- procedure __allocmem(
- blockreq: word; var memptr: pointer; var allocsize, errorcode: word
- );
- procedure __freemem (memptr: pointer; var errorcode: word);
- procedure __altermem(
- blockreq: word; memptr : pointer; var altersize, errorcode: word
- );
- function __firstmem : pointer;
- function __ctrlmem(memptr: pointer; var memblock: _memctrl): pointer;
- procedure __hookmem(progseg: word; var hookvecno: integer);
- procedure __xtmovmem(
- memptr: pointer; extads: _xads; nowords: word;
- toext: boolean; var errorcode: word
- );
- function __fetchmem(p: pointer; itemsize: word; itemnum: longint): pointer;
-
-
- type
- _3freerecptr = ^_3freerec;
- _3freerec = record
- _nextfree : _3freerecptr;
- _blocksize : pointer
- end;
-
-
- (*
- the following variables are used in conjunction with errorexit
- to provide an exit procedure for __hfreemem and __hgetmem. this is
- needed so that a runtime error can be generated for invalid heap
- operations. the turbo pascal 5.0 procedure runerror is not used as
- it is not avaiable for 4.0 and does not report the address of the
- statement that invokes __hfreemem or __hgetmem.
- *)
-
- var
- prevexitproc_ : pointer;
- calleraddr_ : pointer;
-
-
-
-
-
-
- { sort management }
- const
- _default_srt = $0000;
- _insert_srt = $0001;
- _sortdata_srt = $0002;
- _variable_srt = $0004;
- _inmemory_srt = $0008;
- _leavemem_srt = $0010;
-
- _useinsertsrt : word = 10;
-
- _numsortedsrt : word = 0;
- _datasrt : pointer = nil;
- _datasizesrt : longint = 0;
- _ptrsrt : pointer = nil;
- _ptrsizesrt : longint = 0;
-
-
- procedure __isortsrt(
- dataptr : pointer;
- numrecords : word;
- recordsize : word;
- lessfunction : pointer
- );
- procedure __qsortsrt(
- dataptr : pointer;
- numrecords : word;
- recordsize : word;
- lessfunction : pointer
- );
-
- procedure __addsrt(
- dataptr : pointer;
- var errorcode : word
- );
-
- procedure __retsrt(
- var dataptr : pointer;
- var errorcode : word
- );
-
- procedure __sortsrt(
- maxrecords : word;
- recordsize : word;
- lessfunction : pointer;
- inputproc : pointer;
- outputproc : pointer;
- sortcontrol : word;
- var errorcode : word
- );
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- implementation
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- { BASE STRING FUNCTIONS XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX }
- function locase(ch: char): char;
- var j : word;
- begin
- if ch in ['A'..'Z'] then locase := chr(ord(ch) + 32) else locase := ch;
- end;
-
-
-
- function __part(s: string; a, b: byte): string;
- begin
- if b > length(s) then b := length(s);
- if b < a then a := b;
- __part := copy(s, a, b-a+1)
- end;
-
-
-
- function __leftstr(source : string; num : word) : string;
- begin
- __leftstr := copy(source,1,num)
- end;
-
-
- function __rightstr(source : string; chpos : word) : string;
- begin
- __rightstr := copy(source,chpos,maxstr_)
- end;
-
-
- function __substr(source : string; chpos,num : word) : string;
- var startpos : word;
- begin
- if (chpos <= 0) then startpos := 1 else startpos := chpos;
- if (chpos <= length(source)) then
- __substr := copy(source,startpos,num) else __substr := ''
- end;
-
-
-
- function __midstr(source, target : string; chpos : word) : string;
- var
- newtarget : string;
- newtarlen : byte;
- newlen : word;
- newstrptr : ^_memorychar;
- lensource : word;
- lentarget : word;
-
- begin
- lensource := length(source);
- lentarget := length(target);
- newlen := lensource + lentarget;
- getmem(newstrptr,newlen);
- if (newstrptr = nil) then begin __midstr := ''; exit end;
- if (chpos < 1) then chpos := 1 else if (chpos > lentarget) then
- chpos := lentarget + 1;
- move(target[1],newstrptr^[1],chpos - 1);
- move(source[1],newstrptr^[chpos],lensource);
- move(target[chpos],newstrptr^[chpos + lensource],
- lentarget - chpos + 1);
- if (newlen > maxstr_) then newtarget[0] := chr(maxstr_) else
- newtarget[0] := chr(newlen);
- move(newstrptr^,newtarget[1],length(newtarget));
- __midstr := newtarget;
- freemem(newstrptr,newlen)
- end;
-
-
-
- function __fillstr(
- fillch : char; target : string;
- chpos,num : word
- ) : string;
- var
- lentarget : word;
- startpos : word;
-
- begin
- if (num <= 0) then exit;
- lentarget := length(target);
- if (chpos < 1) then startpos := 1 else if (chpos > lentarget) then
- startpos := lentarget + 1 else startpos := chpos;
- if (num > (maxstr_ - startpos + 1)) then num := maxstr_ - startpos + 1;
- fillchar(target[startpos],num,fillch);
- if (lentarget < (startpos + num)) then
- target[0] := chr(startpos + num - 1);
- __fillstr := target
- end;
-
-
-
- function __xlatestr(source, table, trans : string) : string;
- const blank = #32;
- var
- i,j : word;
- lensource : word;
- lentrans : word;
- target : string;
-
- begin
- lentrans := length(trans);
- lensource := length(source);
- for i := 1 to lensource do begin
- j := pos(source[i],table);
- if (j > 0) then if (j > lentrans) then target[i] := blank else
- target[i] := trans[j] else target[i] := source[i]
- end;
- target[0] := chr(lensource);
- __xlatestr := target
- end;
-
-
-
- function __juststr(
- source : string;
- fillch : char;
- fieldsize : word;
- justcode : word
- ) : string;
-
- var
- juststring : string;
- len : word;
-
- begin
- if (fieldsize > maxstr_) then fieldsize := maxstr_;
- fillchar(juststring[1],fieldsize,fillch);
- juststring[0] := chr(fieldsize);
- len := length(source);
- case justcode of
- _right_just_str:
- if (len <= fieldsize) then
- move(source[1],juststring[fieldsize - len + 1],len) else
- move(source[len - fieldsize + 1],juststring[1],fieldsize);
- _center_str:
- if (len <= fieldsize) then
- move(source[1],juststring[((fieldsize - len) div 2) + 1],len) else
- move(
- source[((len - fieldsize) div 2) + 1],
- juststring[1],fieldsize
- );
- else begin
- if (len <= fieldsize) then move(source[1],juststring[1],len) else
- move(source[1],juststring[1],fieldsize)
- end;
- end;
- __juststr := juststring
- end;
-
-
-
- function __cvtstr(source : string; cvtcode : word) : string;
- const
- blank = #32;
- tab = #9;
- quote = #39;
- dquote = #34;
- nul = #0;
- linefeed = #10;
- vtab = #11;
- formfeed = #12;
- creturn = #13;
-
-
- function quotecheck(var lastquote : char; ch : char) : boolean;
- begin
- if ((ch = quote) or (ch = dquote)) then begin
- if (ch = lastquote) then begin
- quotecheck := false;
- lastquote := blank
- end else if ((lastquote <> quote) and (lastquote <> dquote)) then begin
- quotecheck := true;
- lastquote := ch
- end
- end else if ((lastquote = quote) or (lastquote = dquote)) then
- quotecheck := true else quotecheck := false
- end;
-
- var
- target : string;
- isquote : boolean;
- quoteon : boolean;
- lastquote : char;
- deleteon : boolean;
- i,j,len : word;
- ch : char;
-
- begin
- target := source;
- isquote := (cvtcode and 16) <> 0;
- quoteon := false;
- lastquote := ' ';
- if ((cvtcode and _rem_white_str) <> 0) then begin
- len := length(source);
- i := 1;
- j := 0;
- while (i <= len) do begin
- ch := source[i];
- if (isquote) then quoteon := quotecheck(lastquote,ch);
- if (((ch <> blank) and (ch <> tab)) or quoteon) then begin
- inc(j);
- target[j] := ch
- end;
- inc(i);
- end;
- target[0] := chr(j)
- end;
-
- if ((cvtcode and _rem_lead_white_str) <> 0) then begin
- len := length(target);
- i := 1;
- while (
- (i <= len) and ((target[i] = blank) or (target[i] = tab))
- ) do inc(i);
- delete(target,1,i - 1)
- end;
-
- if ((cvtcode and _rem_trail_white_str) <> 0) then begin
- len := length(target);
- i := len;
- while (
- (i >= 1) and ((target[i] = blank) or (target[i] = tab))
- ) do dec(i);
- target := copy(target,1,i)
- end;
-
- if ((cvtcode and _reduce_white_str) <> 0) then begin
- deleteon := false;
- lastquote := blank;
- len := length(target);
- i := 1;
- j := 0;
- while (i <= len) do begin
- ch := target[i];
- if (isquote) then quoteon := quotecheck(lastquote,ch);
- if (((ch <> blank) and (ch <> tab)) or quoteon) then begin
- inc(j);
- target[j] := ch;
- deleteon := false
- end else if (not deleteon) then begin
- inc(j);
- target[j] := blank;
- deleteon := true
- end;
- inc(i)
- end;
- target[0] := chr(j)
- end;
-
- if ((cvtcode and _to_upcase_str) <> 0) then begin
- lastquote := blank;
- for i := 1 to length(target) do begin
- ch := target[i];
- if (isquote) then quoteon := quotecheck(lastquote,ch);
- if (not quoteon) then target[i] := upcase(ch)
- end
- end;
-
- if ((cvtcode and _to_lowcase_str) <> 0) then begin
- lastquote := blank;
- for i := 1 to length(target) do begin
- ch := target[i];
- if (isquote) then quoteon := quotecheck(lastquote,ch);
- if (not quoteon) then target[i] := locase(ch)
- end
- end;
-
- if ((cvtcode and _discard_str) <> 0) then begin
- lastquote := blank;
- len := length(target);
- i := 1;
- j := 0;
- while (i <= len) do begin
- ch := target[i];
- if (isquote) then quoteon := quotecheck(lastquote,ch);
- if (quoteon or
- (
- (ch <> nul) and
- (
- (ch < linefeed) or (ch > creturn))
- )
- ) then begin
- inc(j);
- target[j] := ch
- end;
- inc(i)
- end;
- target[0] := chr(j)
- end;
- __cvtstr := target
- end;
-
-
-
-
- function __entabstr(source : string; incr : byte) : string;
- const
- blank = #32;
- tab = #9;
-
- var
- column, numblanks : word;
- sourceidx : word;
- targetidx : word;
- thisch : char;
-
- begin
- if ((length(source) = 0) or (incr <= 0)) then begin
- __entabstr := source;
- exit
- end;
-
- column := 0;
- numblanks := 0;
- sourceidx := 0;
- targetidx := 0;
-
- repeat
- inc(sourceidx);
- thisch := source[sourceidx];
- case thisch of
- blank: begin
- inc(numblanks);
- inc(column);
- if ((incr <= 0) or (column mod incr = 0)) then begin
- inc(targetidx);
- if (numblanks > 1) then __entabstr[targetidx] := tab else
- __entabstr[targetidx] := blank;
- numblanks := 0
- end;
- end;
- tab: begin
- inc(targetidx);
- column := 0;
- numblanks := 0;
- __entabstr[targetidx] := tab
- end;
-
- else begin
- inc(column);
- inc(targetidx);
- while numblanks > 0 do begin
- __entabstr[targetidx] := blank;
- dec(numblanks);
- inc(targetidx)
- end;
- __entabstr[targetidx] := thisch
- end;
- end;
- until (sourceidx = length(source));
- __entabstr[0] := chr(targetidx)
- end;
-
-
-
-
- function __detabstr(
- source : string; incr : byte;
- var remstr : string
- ) : string;
-
- const
- tab = #9;
- blank = #32;
-
- var
- numspaces : word;
- sourceidx : word;
- targetidx : word;
- len : word;
- thisch : char;
-
- begin
- if ((length(source) = 0) or (incr <= 0)) then begin
- __detabstr := source;
- remstr := '';
- exit
- end;
-
- len := 0;
- sourceidx := 0;
- targetidx := 0;
-
- repeat
- inc(sourceidx);
- thisch := source[sourceidx];
- if (thisch = tab) then begin
- numspaces := incr - (targetidx mod incr);
- if (numspaces > 0) then
- repeat
- inc(targetidx);
- dec(numspaces);
- if (targetidx <= maxstr_) then
- begin
- len := targetidx;
- __detabstr[targetidx] := blank
- end
- else
- numspaces := 0
- until (numspaces = 0);
- end else begin
- inc(targetidx);
- len := targetidx;
- __detabstr[targetidx] := thisch
- end;
- until ((sourceidx = length(source)) or (targetidx >= maxstr_));
- if (sourceidx < length(source)) then
- remstr := copy(source,sourceidx,maxstr_) else remstr := '';
- __detabstr[0] := chr(len)
- end;
-
-
-
-
-
-
- function __toradstr(
- intvalue : longint;
- size,radix,width : word
- ) : string;
-
- const
- max32bit = 4294967296.0;
-
- const
- radcheck : array[1..36] of char =
- '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
-
- var
- quotient : word;
- i, j, ival : word;
- rval, rquotient : real;
- remainder : real;
- tempstr, returnedstr : string;
-
- begin
- if (
- (radix < 2) or (radix > 36) or
- (
- (size <> 1) and (size <> 2) and (size <> 4)
- )
- ) then begin
- __toradstr := '';
- exit
- end;
-
- i := 0;
- case size of
- 1,2: begin
- if (size = 1) then ival := (intvalue shl 24) shr 24 else
- ival := (intvalue shl 16) shr 16;
- if (ival = 0) then returnedstr := '0' else repeat
- inc(i);
- quotient := ival div radix;
- tempstr[i] := radcheck[(ival mod radix) + 1];
- ival := quotient;
- until (ival = 0);
- end;
- 4 : if (intvalue = 0) then returnedstr := '0' else begin
- if (intvalue < 0) then rval := intvalue + max32bit else
- rval := intvalue;
- repeat
- inc(i);
- rquotient := trunc(rval / radix);
- remainder := trunc(rval - radix * 1.0 * trunc(rval / radix));
- tempstr[i] := radcheck[round(remainder) + 1];
- rval := rquotient;
- until (rval = 0);
- end;
- end;
-
- returnedstr[0] := chr(i);
- for j := i downto 1 do returnedstr[j] := tempstr[i - j + 1];
-
- if ((width < length(returnedstr)) or (width > maxstr_)) then
- __toradstr := returnedstr else
- __toradstr := __juststr(returnedstr,'0',width,_right_just_str)
- end;
-
-
-
- function __todecstr(intvalue : longint; size : word) : string;
- var width : word;
- begin
- case size of
- 1 : width := 3;
- 2 : width := 5;
- 4 : width := 10;
- else exit;
- end;
- __todecstr := __toradstr(intvalue,size,10,width)
- end;
-
-
-
- function __tohexstr(intvalue : longint; size : word) : string;
- const hexcheck : array[0..15] of char = '0123456789ABCDEF';
- var
- i : integer;
- tempstr : string[8];
-
- begin
- if ((size <> 1) and (size <> 2) and (size <> 4)) then begin
- __tohexstr := '';
- exit
- end;
- tempstr[0] := chr(8);
- for i := 0 to 7 do begin
- tempstr[8 - i] := hexcheck[intvalue and $000f];
- intvalue := intvalue shr 4
- end;
- i := 2 * size;
- __tohexstr := copy(tempstr,8 - i + 1,i)
- end;
-
-
-
-
- function __ptr2str(thisptr : pointer) : string;
- const colon = ':';
- begin
- __ptr2str :=
- __tohexstr(_vectoraddr(thisptr)._seg,sizeof(word)) + colon +
- __tohexstr(_vectoraddr(thisptr)._ofs,sizeof(word))
- end;
-
-
-
- function __formstr(mask : string; x : real) : string;
- const
- space = ' ';
- zero = '0';
- right = 1;
- left = 2;
- inputchars : string[6] = '+-#@*';
-
- type
- signlogic = (default,plus,minus);
-
- var
- retstr : string;
- fillch : char;
- decch : char;
- sepch : char;
- signch : char;
- i : byte;
- j : byte;
- intlen : byte;
- decpos : byte;
- start : byte;
- endit : byte;
- nfldsize : byte;
- dplaces : byte;
- signpos : byte;
- signflg : signlogic;
- done : boolean;
- money : boolean;
- innum : boolean;
- negative : boolean;
-
- begin
- if (mask = '') then begin
- __formstr := '';
- exit
- end;
-
- done := false;
- innum := false;
- money := false;
- signflg := default;
- negative := x < 0;
- decpos := 0;
- i := 0;
- start := 0;
- fillch := space;
- sepch := #0;
- decch := #0;
- x := abs(x);
- inputchars := inputchars + _strmoneych;
-
- repeat
- inc(i);
- if (
- ((innum) and ((mask[i] = '.') or (mask[i] = ',') or
- (mask[i] = space))) or (pos(mask[i],inputchars) > 0)
- ) then begin
- innum := true;
- if (start = 0) then start := i;
- if (mask[i] = '-') then begin
- signpos := i;
- signflg := minus
- end;
- if (mask[i] = '+') then begin
- signpos := i;
- signflg := plus
- end;
- if (mask[i] = _strmoneych) then money := true;
- if (mask[i] = '@') then if (fillch = space) then fillch := zero;
- if (mask[i] = '*') then fillch := '*';
- if ((mask[i] = '.') or (mask[i] = ',') or (mask[i] = space)) then
- if ((i = length(mask)) or (pos(mask[succ(i)],inputchars) < 3)) then
- done := true else if (mask[i] = space) then
- sepch := space else begin
- if (decch <> #0) then sepch := decch;
- decch := mask[i];
- decpos := i
- end;
- end else if (innum) then done := true;
- until (i = length(mask)) or done;
-
- if (decch = sepch) then begin decpos := 0; decch := #0 end;
- if (start = 0) then begin __formstr := mask; exit end;
- endit := i - ord(done);
- if (signflg <> default) then if (signpos = endit) then begin
- inc(decpos, ord(decpos > 0));
- signpos := right
- end else signpos := left;
-
- if (money) then if (fillch = zero) then fillch := space;
- nfldsize := succ(endit - start);
- if (decpos > 0) then begin
- decpos := decpos - pred(start);
- dplaces := nfldsize - decpos
- end else dplaces := 0;
-
- str(x : 0 : dplaces, retstr);
- if (dplaces > 0) then begin
- dplaces := length(retstr) - pos('.',retstr);
- retstr[length(retstr) - dplaces] := decch
- end;
-
- j := 0;
- if (dplaces > 0) then intlen := length(retstr) - succ(dplaces) else
- intlen := length(retstr);
- if (sepch <> #0) then for i := intlen downto 2 do begin
- inc(j);
- if (j mod 3 = 0) then insert(sepch,retstr,i);
- end;
-
- if (negative) then signch := '-' else if (signflg = plus) then
- signch := '+' else signch := space;
-
- j := length(retstr) + ord(money) +
- ord((negative) or (signflg <> default));
-
- if (j > nfldsize) then begin
- for i := start to endit do
- if ((mask[i] = '+') or (mask[i] = '-')) then mask[i] := signch else
- if (not ((mask[i] = ',') or (mask[i] = '.') or
- (mask[i] = space))) then mask[i] := '*';
- __formstr := mask;
- exit
- end;
-
- if (money) then retstr := _strmoneych + retstr;
- if (signflg = default) then begin
- if ((negative) and (fillch = space)) then retstr := '-' + retstr;
- while length(retstr) < nfldsize do insert(fillch,retstr,1)
- end else begin
- case signpos of
- right : retstr := retstr + signch;
- left : retstr := signch + retstr;
- end;
- while length(retstr) < nfldsize do insert(fillch,retstr,signpos)
- end;
-
- if (start > 1) then retstr := copy(mask,1,pred(start)) + retstr;
- if (endit < length(mask)) then
- retstr := retstr + copy(mask,succ(endit),length(mask));
- __formstr := retstr
- end;
-
-
-
- function openfmt__(var fmtfil : textrec) : integer;
- begin
- with textrec(fmtfil) do begin
- if (mode <> fmoutput) then begin
- openfmt__ := 105;
- exit;
- end;
- getmem(bufptr,_fmt_buflen_str);
- if (bufptr = nil) then begin
- openfmt__ := 203;
- exit;
- end;
- bufsize := _fmt_buflen_str;
- bufpos := 0;
- bufend := 0;
- end;
- openfmt__ := 0
- end;
-
-
-
-
- function closefmt__(var fmtfil : textrec) : integer;
- begin
- with textrec(fmtfil) do begin
- freemem(bufptr,_fmt_buflen_str);
- mode := fmclosed;
- end;
- closefmt__ := 0;
- end;
-
-
-
-
- function inoutfmt__(var fmtfil : textrec) : integer;
- begin
- with textrec(fmtfil) do begin
- if (bufpos >= _fmt_buflen_str) then inoutfmt__ := 101 else
- inoutfmt__ := 0;
- end;
- end;
-
-
-
- procedure __initfstr(var fmtfil : text);
- begin
- with textrec(fmtfil) do begin
- handle := $ffff;
- mode := fmclosed;
- bufsize := 0;
- bufptr := nil;
- openfunc := @openfmt__;
- inoutfunc := @inoutfmt__;
- flushfunc := @inoutfmt__;
- closefunc := @closefmt__;
- name[0] := #0;
- rewrite(fmtfil)
- end;
- end;
-
-
-
-
- function __retbfstr(var fmtfil : text) : string;
- var
- s : string;
- i : word;
-
- begin
- with textrec(fmtfil) do begin
- if (mode = fmoutput) then begin
- i := bufpos; if (i > 255) then i := 255;
- move(bufptr^,s[1],i);
- s[0] := char(i);
- bufpos := 0;
- bufend := 0;
- end else s[0] := #0;
- end;
- __retbfstr := s;
- end;
-
-
-
-
-
-
-
-
-
-
-
- { SECONDARY STRING FUNCTIONS XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX }
- procedure __app(var st: string; aps: string);
- begin
- st := st + aps;
- end;
-
-
- function __backapp(s: string) : string;
- begin
- if s[length(s)] <> _dirslash then __backapp := s + _dirslash else
- __backapp := s;
- end;
-
-
- function __backrem(s: string) : string;
- begin
- if s[length(s)] in ['\', _dirslash] then __backrem := copy(s, 1, length(s)-1) else
- __backrem := s;
- end;
-
-
- function __lastchr(s: string): char;
- begin
- __lastchr := s[length(s)];
- end;
-
-
- function __comp(s1, s2: string): boolean;
- begin
- __comp := (
- __cvtstr(s1, _rem_white_str + _to_upcase_str) =
- __cvtstr(s2, _rem_white_str + _to_upcase_str)
- )
- end;
-
-
-
-
- function __hexdecstr;
- var
- v : longint;
- i : shortint;
-
- {
- converts a hexadecimal string into an integer, ready to
- be processed by __toradstr into the diverse formats
- }
-
- function __power(x,y: integer): longint;
- begin
- if x>0 then
- __power := round(exp(y*ln(x))) else if x<0 then
- __power := -1 * (y mod 2) * round(exp(y*ln(x)));
- end;
-
-
- function hexvalue(inchar: char): shortint;
- begin
- if ord(inchar) in [65..70] then hexvalue := ord(inchar) - 55
- else hexvalue := ord(inchar) - 48
- end;
-
- begin
- v := 0; for i := length(hexstr) downto 1 do
- v := v + trunc(__power(16,length(hexstr)-i)*hexvalue(upcase(hexstr[i])));
- __hexdecstr := v
- end;
-
-
-
- function __lo(s: string): string;
- begin
- __lo := __cvtstr(s, _to_lowcase_str);
- end;
-
-
- function __min(v1, v2: longint): longint;
- begin
- if v1 <= v2 then __min := v1 else __min := v2;
- end;
-
-
- function __num(nr: longint):string;
- var temp: string;
- begin
- str(nr,temp); __num := temp;
- end;
-
-
-
- function __real(st: string): real;
- var
- code : integer;
- temp : real;
- begin
- if length(st)=0 then __real := 0 else begin
- val(st, temp, code);
- if code = 0 then __real := temp else __real := 0;
- end;
- end;
-
-
-
- function __streal(nr: real; decs: byte): string;
- var
- tm1, tm2 : string;
-
- begin
- tm1 := __num(trunc(nr));
- tm2 := __num(
- round(
- (
- nr - trunc(nr)
- )
- *
- __power(10, decs)
- )
- );
- __streal := tm1 + '.' + tm2;
- end;
-
-
- function __nw(s: string): string;
- begin
- __nw := __cvtstr(s, _rem_white_str);
- end;
-
-
- function __overtype(n:byte;strs,strt:string):string;
-
- var
- l : byte;
- strn : string;
-
- begin
- l := n + pred(length(strs));
- if l < length(strt) then l := length(strt);
- if l > 255 then __overtype := copy(strt,1,pred(n)) +
- copy(strs,1,255-n) else begin
- fillchar(strn[1],l,' ');
- strn[0] := chr(l);
- move(strt[1],strn[1],length(strt));
- move(strs[1],strn[n],length(strs));
- __overtype := strn;
- end;
- end;
-
-
-
-
- function __pntstr(n: longint): string;
- var
- tmpnrstr,
- tmpcvtstr : string;
- tab, i,
- len_numstr,
- len_pnts : longint;
-
- begin
- str(n, tmpnrstr); tab := 0;
- len_numstr := length(tmpnrstr);
- len_pnts := (len_numstr -1) div 3;
- tmpcvtstr[0] := chr(len_numstr + len_pnts);
-
- tmpcvtstr[len_pnts +len_numstr -tab] := tmpnrstr[len_numstr];
- for i := len_numstr-1 downto 1 do begin
- if ((len_numstr -i) mod 3 =0) then begin
- tmpcvtstr[len_pnts +i -tab] := '.'; inc(tab)
- end;
- tmpcvtstr[len_pnts +i -tab] := tmpnrstr[i];
- end;
- __pntstr := copy(tmpcvtstr, 1, len_numstr +len_pnts);
- end;
-
-
-
-
- function __str(st: string): integer;
- var
- code, temp: integer;
- begin
- if length(st)=0 then __str := 0 else begin
- val(st, temp, code);
- if code=0 then __str := temp else __str := 0;
- end;
- end;
-
-
-
-
- function __up(s: string): string;
- begin
- __up := __cvtstr(s, _to_upcase_str);
- end;
-
-
- function __uprem(s: string): string;
- begin
- __uprem := __cvtstr(s, _to_upcase_str + _rem_white_str);
- end;
-
-
- function __val(st: string): longint;
- var
- code: integer;
- temp: longint;
-
- begin
- if length(st)=0 then __val := 0 else begin
- val(st, temp, code);
- if code=0 then __val := temp else __val := 0;
- end;
- end;
-
-
-
-
-
- function __nonascii(s: string): boolean;
- var
- i : byte;
- __b__ : boolean;
-
- begin
- __b__ := false;
- for i := 1 to length(s) do
- __b__ := __b__ or (ord(s[i]) in [0..31,128..255]);
- __nonascii := __b__
- end;
-
-
-
- function __killnonascii(s: string): string;
- var
- __st__ : string;
- i : byte;
-
- begin
- __st__ := '';
- for i := 1 to length(s) do
- if (ord(s[i]) in [32, 127]) then
- __st__ := __st__ + s[i];
- __killnonascii := __st__;
- end;
-
-
-
-
-
- { PRIMARY BYTE CONVERSION FUNCTIONS XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX }
- function __byte2str(b: byte): str8;
- var
- s: str8;
- i: byte;
-
- begin
- s := __rep(8, nonblock); i := b;
- if (i and $01) > 0 then s[1] := block;
- if (i and $02) > 0 then s[2] := block;
- if (i and $04) > 0 then s[3] := block;
- if (i and $08) > 0 then s[4] := block;
- if (i and $10) > 0 then s[5] := block;
- if (i and $20) > 0 then s[6] := block;
- if (i and $40) > 0 then s[7] := block;
- if (i and $80) > 0 then s[8] := block;
- __byte2str := s
- end;
-
-
-
- function __str2byte(s: str8): byte;
- var l, b: byte;
- begin
- l := 0;
- for b := 1 to 8 do begin
- l := l shl 1; if not(s[b] in [nonblock, ' ', '-']) then inc(l)
- end;
- __str2byte := l;
- end;
-
-
-
-
- {
- representation 4 user flags, array[1..4] of byte
- by a string[32], or a longint
-
-
- ยทยทยทยทยทโ ยทโ โ ยทโ โ ยทโ ยทโ ยทโ ยทโ โ โ ยทยทยทยทโ โ ยทโ ยทโ = longint
- โโโfDโโโโโโfCโโโโโโfBโโโโโโfAโโโ
- str8 str8 str8 str8
- byte byte byte byte
-
- โ โ
- 2^31 1
-
- bit 31 (32nd bit) is complementory represented.
- ( -maxlongint-1 )
- }
-
-
-
- function __longint2str(l: longint): str32;
- const con: array[1..31] of longint = (
- $00000001, $00000002, $00000004, $00000008,
- $00000010, $00000020, $00000040, $00000080,
- $00000100, $00000200, $00000400, $00000800,
- $00001000, $00002000, $00004000, $00008000,
- $00010000, $00020000, $00040000, $00080000,
- $00100000, $00200000, $00400000, $00800000,
- $01000000, $02000000, $04000000, $08000000,
- $10000000, $20000000, $40000000
- );
- var
- s : str32;
- b : byte;
-
- begin
- s := __rep(32, nonblock); if l < 0 then s[32-31] := block;
- if l < 0 then l := l + maxlongint + 1;
- for b := 1 to 31 do if (l and con[b]) >0 then s[32-b+1] := block;
- __longint2str := s
- end;
-
-
-
- function __str2longint(s: str32): longint;
- var
- l : longint;
- b : byte;
-
- begin
- l := 0;
- for b := 2 to 32 do begin
- l := l shl 1; if not(s[b] in [nonblock, ' ', '-']) then inc(l)
- end;
- if not(s[1] in [nonblock, ' ', '-']) then l := l - maxlongint - 1;
- __str2longint := l;
- end;
-
-
-
-
-
-
-
-
- { ASCIIZ AND OTHER FUNCTIONS XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX }
- procedure __str2obj(s: anystr; var a; length_a: integer );
- var
- i : integer;
- aa : packed array[ 1 .. 1 ] of char absolute a;
-
- begin
- fillchar(aa[1], length_a, ' ');
- move(s[1], aa[1], __min(length_a, length(s)));
- end;
-
-
- procedure __str2arr(s: anystr; var a; length_a: integer );
- var
- i : integer;
- len_s : integer;
- len_a : integer;
- l : integer;
- aa : packed array[ 1 .. 1 ] of char absolute a;
-
- begin
- len_s := length( s ); len_a := length_a; l := __min(len_a, len_s);
- for i := 1 to l do begin
- aa[len_a] := s[len_s]; dec(len_a); dec(len_s)
- end;
- for i := len_a downto 1 do aa[i] := ' ';
- end;
-
-
- function __readctrls(s: anystr): anystr;
- var
- t : anystr;
- i : integer;
- j : integer;
- l : integer;
-
- begin
- t:=''; i:=1; j:=0; l:=length(s);
- while( i <= l ) do begin
- if ( s[i] = fk_ctrl_mark ) then if ( s[i+1] <> '''' ) then begin
- inc(i); inc(j); t[j]:=chr( ord(s[i])-64); inc(i)
- end else begin
- inc(j); t[j]:=s[i]; t[j+1]:=s[i+1]; t[j+2]:=s[i+2]; inc(i,3); inc(j,2);
- end else begin
- inc( j ); t[j]:=s[i]; inc(i)
- end;
- end; t[0]:=chr( j ); __readctrls:=t;
- end;
-
-
-
- function __writectrls(s: anystr): anystr;
- var
- t: anystr;
- i: integer;
- j: integer;
-
- begin
- t:=''; j := 0;
- for i:=1 to length( s ) do begin
- if ( s[i] in [^@..^_] ) then begin
- inc(j); t[j] := fk_ctrl_mark; inc(j); t[j] := chr(ord(s[i])+64);
- end else begin
- inc(j); t[j]:=s[i]
- end;
- end; t[0]:=chr( j ); __writectrls := t;
- end;
-
-
- function __az2str(a: asciiz): string;
- var s : string; slen: byte absolute s;
- begin
- slen:=0; while a[slen] <> #0 do slen:=succ(slen); move(a, s[1], slen);
- __az2str:=s;
- end;
-
-
- procedure __str2az(s : string; var a : asciiz);
- var slen: byte absolute s;
- begin
- move(s[1], a, slen); a[slen]:=#0;
- end;
-
-
-
-
-
-
-
- { STRING1024 FUNCTIONS XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX }
- procedure __app1024(var app: ar1024; s: string);
- var i, j : word;
- begin
- i := 1; while (app[i] <> #0) and (i < 1024) do inc(i);
- for j := 1 to length(s) do begin app[i + j - 1] := s[j] end;
- end;
-
-
-
- function __len1024(var a: ar1024) : word;
- var l : word;
- begin
- l := 1;
- while (l < 1024) and (a[l] <> #0) do inc(l); dec(l);
- __len1024 := l;
- end;
-
-
-
- procedure __clr1024(var a: ar1024);
- begin
- fillchar(a, sizeof(ar1024), #0);
- end;
-
-
- procedure __del1024(var a: ar1024; b, l: word);
- begin
- move(a[b+l], a[b], 1024 - b)
- end;
-
-
- procedure __ins1024(var a: ar1024; b : word; s: string);
- var l, i : byte;
- begin
- l := length(s);
- move(a[b], a[b+l], 1024 - b);
- for i := 1 to l do a[b + i - 1] := s[i];
- end;
-
-
- procedure __write1024(var a: ar1024);
- var l : word;
- begin
- l := 1;
- while (l < 1024) and (a[l] <> #0) do begin write(a[l]); inc(l) end;
- end;
-
-
-
-
-
-
-
-
-
-
- { PRIMARY DATA CONVERSION FUNCTIONS XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX }
- function __main(b: longint; w: word): longint;
- begin
- if b mod w = 0 then __main := b else __main := ((b div w) + 1) * w
- end;
-
-
- function __max(v1, v2: longint): longint;
- begin
- if v1 >= v2 then __max := v1 else __max := v2;
- end;
-
-
- function __power(x,y: integer): longint;
- begin
- if x>0 then
- __power := round(exp(y*ln(x))) else if x<0 then
- __power := -1 * (y mod 2) * round(exp(y*ln(x)));
- end;
-
-
-
- procedure __iptrsup(var p : pointer; n : longint);
- var seg,ofs : word;
- begin
- seg := n shr 4; { divide by 16 for paragraphs }
- ofs := n mod 16; { offset }
- inc(seg,_vectoraddr(p)._seg);
- inc(ofs,_vectoraddr(p)._ofs);
- p := ptr(seg + (ofs shr 4),ofs and $000f)
- end;
-
-
- procedure __dptrsup(var p : pointer; n : longint);
- var seg,ofs : word;
- begin {__dptrsup}
- seg := n shr 4; { divide by 16 for paragraphs }
- ofs := n mod 16; { offset }
- p := __nptrsup(ptr(_vectoraddr(p)._seg - seg,
- _vectoraddr(p)._ofs - ofs))
- end; {__iptrsup}
-
-
- function __nptrsup(thisptr : pointer) : pointer;
- begin {__nptrsup}
- __nptrsup := ptr(_vectoraddr(thisptr)._seg +
- (_vectoraddr(thisptr)._ofs shr 4),
- _vectoraddr(thisptr)._ofs and $f)
- end;
-
-
- function __ptr2lsup(thisptr : pointer) : longint;
- var normptr : pointer;
- begin
- normptr := __nptrsup(thisptr);
- __ptr2lsup := (longint(_vectoraddr(normptr)._seg) shl 4) +
- longint(_vectoraddr(normptr)._ofs)
- end;
-
-
- procedure __fillwsup(var target; count : longint; fillword : word); external;
- procedure __fillbsup(var target; count : longint; fillbyte : byte); external;
-
- procedure __repmsup(var target,source; count : longint; sourcesize : word);
- var
- targetptr : pointer;
- i : longint;
-
- begin
- if (count <= 0) then exit;
- case sourcesize of
- 0 : exit;
- 1 : __fillbsup(target,count,byte(source));
- 2 : __fillwsup(target,count,word(source));
- else begin
- targetptr := @target;
- for i := 1 to count do begin
- move(source,targetptr^,sourcesize);
- __iptrsup(targetptr,sourcesize)
- end
- end;
- end {case sourcesize}
- end; {__repmsup}
-
-
- function __alphasup(ch : char) : boolean;
- begin
- if (
- ((ch > #64) and (ch < #91)) or ((ch > #96) and (ch < #123))
- ) then __alphasup := true else __alphasup := false;
- end;
-
-
-
-
-
-
-
-
-
- { DATE FUNCTIONS XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX }
- function __datestr(var year,month,day : word) : string;
- const
- blank = #32;
- comma = #44;
-
- var
- dayofweek : word;
- yearstr : string[5];
- daystr : string[2];
-
- begin
- getdate(year,month,day,dayofweek);
- str(year:5,yearstr);
- str(day,daystr);
- __datestr := _strdays[dayofweek] + blank + _strmonths[month] +
- blank + daystr + comma + yearstr;
- end;
-
-
- function __timestr(
- var hours, minutes,
- seconds, tics : word
- ) : string;
- var
- tmphours,tmpmins : word;
-
- begin
- gettime(hours,minutes,seconds,tics);
- tmphours := hours;
- tmpmins := minutes;
- if (seconds > 30) then begin
- tmpmins := succ(tmpmins) mod 60;
- if (tmpmins = 0) then tmphours := succ(tmphours) mod 24
- end;
- __timestr := __time2str(tmphours,tmpmins,seconds,0,_standard_str);
- end;
-
-
-
- function __dt2ststr(
- year : word;
- month : word;
- day : word;
- datefmt : word
- ) : string;
-
- const
- blank = #32;
- zero = #48;
- comma = #44;
-
- const
- strdays: array[1..12] of word = (31,29,31,30,31,30,31,31,30,31,30,31);
-
- var
- yrstr : string[4];
- mnstr : string[2];
- dystr : string[2];
-
- begin
- __dt2ststr := '';
- if (year < 100) then inc(year,1900);
- if ((month < 1) or (month > 12)) then exit;
- if (((month = 2) and (day = 29)) and ((year mod 4) <> 0)) then exit;
- if ((day = 0) or (day > strdays[month])) then exit;
- str(year,yrstr); str(month:2,mnstr); str(day:2,dystr);
-
- if (yrstr[3] = blank) then yrstr[3] := zero;
- if (mnstr[1] = blank) then mnstr[1] := zero;
- if (dystr[1] = blank) then dystr[1] := zero;
-
- case datefmt of
- _usa_dt_str: begin
- __dt2ststr := mnstr + _strusach + dystr +
- _strusach + copy(yrstr,3,2);
- end;
-
- _euro_dt_str: begin
- __dt2ststr := dystr + _streuroch + mnstr +
- _streuroch + copy(yrstr,3,2);
- end;
-
- _year_dt_str: begin
- __dt2ststr := mnstr + _strusach + dystr +
- _strusach + yrstr;
- end;
-
- _mont_dt_str: begin
- __dt2ststr := dystr + blank + copy(_strmonths[month],1,3) +
- blank + copy(yrstr,3,2);
- end;
-
- _form_dt_str: begin
- str(day,dystr);
- __dt2ststr := _strmonths[month] + blank + dystr +
- comma + blank + yrstr;
- end
- end;
- end;
-
-
-
- procedure __st2dtstr(st: string; var year, month, day: word; datefmt: word);
-
- function rettoken(
- var datestr : string;
- var start : word
- ) : string;
-
- var
- stop : boolean;
- chpos : word;
-
- begin
- rettoken := '';
- stop := false;
- chpos := start;
- while (
- (chpos <= length(datestr)) and
- (datestr[chpos] in ['a'..'z','A'..'Z','0'..'9'])
- ) do inc(chpos);
- rettoken := copy(datestr,start,chpos - start);
- start := succ(chpos);
- end;
-
-
- var
- token : string[9];
- temp1 : word;
- temp2 : word;
- start : word;
- errcode : word;
- i : word;
- match : boolean;
-
- begin
- month := 0; day := 0; year := 0;
- start := 1;
- token := rettoken(st,start);
- case datefmt of
- _usa_dt_str,
- _euro_dt_str,
- _year_dt_str,
- _mont_dt_str : begin
- val(token,temp1,errcode);
- if (errcode <> 0) then exit;
- end;
-
- _form_dt_str : begin
- i := 1;
- repeat
- match := (
- __cvtstr(token,_to_upcase_str) =
- __cvtstr(_strmonths[i],_to_upcase_str)
- );
- inc(i);
- until ((i > 12) or (match));
- if (match) then temp1 := pred(i) else exit;
- end
- end;
-
- token := rettoken(st, start);
- case datefmt of
- _usa_dt_str,
- _euro_dt_str,
- _year_dt_str,
- _form_dt_str : begin
- val(token,temp2,errcode);
- if (errcode <> 0) then exit;
- if (datefmt = _form_dt_str) then inc(start);
- end;
- _mont_dt_str : begin
- i := 1;
- repeat
- match := (
- __cvtstr(token,_to_upcase_str) =
- __cvtstr(copy(_strmonths[i],1,3), _to_upcase_str)
- );
- inc(i);
- until ((i > 12) or (match));
- if (match) then temp2 := pred(i) else exit;
- end;
- end;
- token := rettoken(st,start);
- val(token,year,errcode);
- if (errcode <> 0) then exit;
- if (year < 100) then inc(year,1900);
- case datefmt of
- _euro_dt_str,
- _mont_dt_str : begin
- month := temp2;
- day := temp1
- end else begin
- month := temp1;
- day := temp2
- end;
- end;
- end;
-
-
-
- function __time2str(
- hours, mins : word;
- secs, tics : word;
- format : word
- ) : string;
-
- const
- colon = ':';
- period = '.';
- point = 'ยท';
- space = ' ';
- zero = '0';
- dirbit = $0010;
-
- var
- ahrs : word;
- i : word;
- hstr : string[2];
- mstr : string[2];
- sstr : string[2];
- tstr : string[2];
- timestr : string[14];
-
- begin
- hours := hours mod 24;
- ahrs := hours;
- if ((_12hour_str and format) <> 0) then begin
- if (hours = 0) then hours := 12 else if (hours > 12) then dec(hours,12);
- end;
- str(hours,hstr); str((mins mod 60):2,mstr);
- timestr := hstr + colon + mstr;
- if ((_inc_sec_str and format) <> 0) then begin
- str((secs mod 60):2,sstr);
- timestr := timestr + period + sstr;
- end;
- if ((_inc_tic_str and format) <> 0) then begin
- str((tics mod 100):2,tstr);
- timestr := timestr + point + tstr;
- end;
- for i := 3 to length(timestr) do if (timestr[i] = space) then
- timestr[i] := zero;
- if ((_inc_ampm_str and format) <> 0) then
- timestr := timestr + _ampm_str[ahrs div 12] else
- if ((dirbit and format) <> 0) then
- timestr := timestr + _ap_str[succ(ahrs div 12)];
- __time2str := timestr;
- end;
-
-
-
- function __2timestr(
- timestr : string;
- var hours,mins : word;
- var secs,tics : word
- ) : boolean;
-
- const
- colon = ':';
- period = '.';
-
- var
- i : word;
- len : word;
- startpos : word;
- endpos : word;
- ch : char;
- errorcode : word;
- values : array[1..4] of word;
-
- begin
- __2timestr := false;
- fillchar(values,sizeof(values),0);
- len := length(timestr);
- if (len = 0) then exit;
- endpos := 0;
- for i := 1 to 4 do begin
- startpos := succ(endpos);
- repeat
- inc(endpos);
- ch := timestr[endpos];
- until ((ch = colon) or (ch = period) or (endpos > len));
- if ((endpos - startpos) > 0) then begin
- val(
- copy(timestr,startpos,endpos - startpos),
- values[i], errorcode
- );
- if (errorcode <> 0) then exit;
- end;
- end;
- hours := values[1]; mins := values[2];
- secs := values[3]; tics := values[4];
-
- if (
- (values[1] > 23) or (values[2] > 59) or (values[3] > 59) or
- (values[4] > 99)
- ) then exit;
- __2timestr := true;
- end;
-
-
-
- function __retdowstr(dayofweek: word; ful: boolean): string;
- begin
- if ful then __retdowstr := _strdays[dayofweek] else
- __retdowstr := copy(_strdays[dayofweek], 1, 3);
- end;
-
-
- function __todaystr(ful: boolean): string;
- var y, m, d, dow: word;
- begin
- getdate(y, m, d, dow);
- if ful then __todaystr := _strdays[dow] else
- __todaystr := copy(_strdays[dow], 1, 3);
- end;
-
-
- procedure __jl2dtutl(julian: longint; var year, month, day, weekday: word);
- var temp1 : longint;
- begin
- year := 0; month := 0; day := 0; weekday := 0;
- if (julian < 0) or (julian > 72989) then exit;
- temp1 := julian * 4 + 3;
- year := (temp1 div 1461) + 1900;
- temp1 := ((temp1 mod 1461) div 4 + 1) * 5 - 3;
- month := temp1 div 153;
- day := temp1 mod 153 div 5 + 1;
- if (month < 10) then inc(month,3) else begin dec(month,9); inc(year) end;
- weekday := (julian + 4) mod 7;
- end;
-
-
- function __dt2jlutl(year, month, day : word) : longint;
- const days : array[1..12] of word = (31,29,31,30,31,30,31,31,30,31,30,31);
- begin
- __dt2jlutl := -1;
- if ((year < 1900) and (year > 99)) then exit;
- if (year < 100) then inc(year,1900);
- if ((month < 1) or (month > 12)) then exit;
- if (((month = 2) and (day = 29)) and ((year mod 4) <> 0)) then exit;
- if ((day = 0) or (day > days[month])) then exit;
- if ((year = 1900) and (month < 3)) then exit;
- dec(year,1900);
- if (month > 2) then dec(month,3) else begin inc(month,9); dec(year) end;
- __dt2jlutl := (
- ((longint(1461) * longint(year)) div 4) +
- ((153 * month + 2) div 5) + day - 1
- );
- end;
-
-
- function __daysutl(yr1, mn1, day1 : word; yr2, mn2, day2 : word) : longint;
- var temp1, temp2 : longint;
- begin
- temp1 := __dt2jlutl(yr1,mn1,day1); temp2 := __dt2jlutl(yr2,mn2,day2);
- if (temp1 < 0) or (temp2 < 0) then __daysutl := -1 else
- __daysutl := temp2 - temp1;
- end;
- {
- gordon king in dr.dobbsjournal (number 80, june 1983)
- and originally published in the collected algorithms
- of the acm by r.g. tantzen in 1963.
- }
-
-
- function __dbdate: string;
- var
- year, month, day,
- hour, minute, second, tic : word;
- s, s1 : string;
-
- begin
- s := __datestr(year, month, day);
- s := __timestr(hour, minute, second, tic);
- s := __dt2ststr(year, month, day, _usa_dt_str);
- if length(s1)<8 then s := '0' + s;
- s1 := __time2str(hour, minute, second, tic, 0);
- if length(s1)<5 then s1 := '0' + s1;
- __dbdate := s + ' ' + s1 + ' ';
- end; { __dbdate }
-
-
- function __radate: string;
- var
- year, month, day,
- hour, minute, second, tic : word;
- s, s1 : string;
-
- begin
- s := __datestr(year, month, day);
- s := __timestr(hour, minute, second, tic);
- s := __dt2ststr(year, month, day, _mont_dt_str);
- s1 := __time2str(hour, minute, second, tic, _inc_sec_str);
- if length(s1)<8 then s1 := '0' + s1;
- __radate := '> ' + s1 + ' ';
- end; { __radate }
-
-
- function __curdate: string;
- var
- year, month, day,
- hour, minute, second, tic : word;
- s, s1 : string;
-
- begin
- s := __datestr(year, month, day);
- s := __timestr(hour, minute, second, tic);
- s := __dt2ststr(year, month, day, _mont_dt_str);
- s1 := __time2str(hour, minute, second, tic, _inc_sec_str);
- if length(s1)<8 then s1 := '0' + s1;
- __curdate := s + ' ' + s1;
- end; { __curdate }
-
-
- function __curdate2longint: longint;
- var
- year1, mon1,
- day1, hour1,
- min1, sec1,
- tic1 : word;
- s, s1 : string;
- datetimepack : datetime;
- templong : longint;
-
- begin
- s := __datestr(year1, mon1, day1);
- s := __timestr(hour1, min1, sec1, tic1);
- with datetimepack do begin
- year := year1; month := mon1; day := day1;
- hour := hour1; min := min1; sec := sec1;
- end; packtime(datetimepack, templong);
- __curdate2longint := templong;
- end; { __curdate }
-
-
- function __longint2date(l: longint): string;
- var dt: datetime;
- begin
- unpacktime(l, dt); if dt.year<100 then inc(dt.year, 1900);
- __longint2date := __juststr(
- __num(dt.day), '0', 2, _right_just_str
- ) + ' ' + copy(_strmonths[dt.month], 1, 3) + ' ' +
- __juststr(__num(dt.year), '0', 2, _right_just_str) + ' ' +
- __juststr(__num(dt.hour), '0', 2, _right_just_str) + ':' +
- __juststr(__num(dt.min), '0', 2, _right_just_str) + '.' +
- __juststr(__num(dt.sec), '0', 2, _right_just_str);
- end;
-
-
- function __date2longint(d: string): longint;
- const mons: string[12] = 'JFMAMJJASOND';
- var { 'xx NNN yy HH:MM.ss' }
- st : string; { eg. '22 Aug 69 14:50.11' }
- dt : datetime;
- c : char;
- m : word;
- l : longint;
-
- begin
- with dt do begin
- hour := __str(copy(d, 12, 2));
- min := __str(copy(d, 15, 2));
- sec := __str(copy(d, 18, 2));
- day := __str(copy(d, 01, 2));
- year := __str(copy(d, 08, 2)) + 1900;
- st := copy(d, 4, 3);
- c := upcase(d[4]);
- case c of
- 'A': if st='Apr' then m := 4 else m := 8;
- 'D', 'F', 'N', 'O', 'S': m := pos(c, mons);
- 'J': if st='Jan' then m := 1 else if st='Jun' then m := 6 else m := 7;
- 'M': if st='Mar' then m := 3 else m := 5;
- end;
- month := m;
- end;
- packtime(dt, l); __date2longint := l;
- end;
-
-
- (*
- Format number
- 1 - Xpress method of display last usage date Mmm DD,YYYY HH:MM:SSap
- 2 - opus display method for date written in messages Mmm-DD-YY H:MMap
- 3 - Xpress Sysop menu display of last usage. MM/DD/YY HH:MMap
- 4 - used for opus log DD Mmm HH:MM:SS
- 5 - used for last usage date in user.bbs (opus) DD Mmm YY HH:MM:SS
- 6 - Mmm DD, YY
- 7 - used for new files lister in OPUS 1.70 MM/DD/YY
-
- *)
-
-
- function format_date(dt:datetime;format : byte):string;
- var
- ms, ds, hs,
- m1s, ss, mhs,
- ampm : string[2];
- ys : string[4];
-
- begin
- ampm := 'am';
- with dt do begin
- str(month:2,ms);
- str(day:1,ds);
- str(year:1,ys);
- str(hour:1,mhs);
- if format = 4 then if length(mhs)=1 then mhs := '0'+mhs;
- if format in [3,4,7] then if length(ds)=1 then ds := '0'+ds;
- if format in [2,5] then ys := copy(ys,3,2);
-
- if hour >= 12 then begin
- ampm := 'pm';
- if hour > 12 then hour := hour - 12;
- end;
- str(hour:1,hs); str(min:2,m1s); str(sec:2,ss);
- if (format=3) or (format=7) then if hour < 10 then hs := ' '+hs;
- if m1s[1] = ' ' then m1s[1] := '0';
- if ss[1] = ' ' then ss[1] := '0';
- if ms[1] = ' ' then ms[1] := '0';
- if not (month in [1..12]) then month := 13;
- if year < 1988 then month := 13;
- if year > 2000 then month := 13;
- if (format < 1) or (format > 7) then format := 1;
- case format of
- 1 : format_date := _strmonths[month]+' '+ds+','+ys+' '+hs+':'+m1s+':'+ss+ampm;
- 2 : format_date := _strmonths[month]+'-'+ds+'-'+ys+' '+hs+':'+m1s+ampm;
- 3 : format_date := ms+'/'+ds+'/'+copy(ys,3,2)+' '+hs+':'+m1s+ampm;
- 4 : format_date := ds+ ' '+_strmonths[month]+' '+mhs+':'+m1s+':'+ss;
- 5 : format_date := ds+ ' '+_strmonths[month]+' '+ys+' '+mhs+':'+m1s+':'+ss;
- 6 : format_date := _strmonths[month]+' '+ds+','+ys;
- 7 : format_date := ms+'/'+ds+'/'+copy(ys,3,2);
- end;
- end;
- end;
-
-
- procedure __longint2datetime(d: longint; var dt : datetime);
- var dtst : record date, time : word end absolute d;
- begin
- with dtst do begin
- dt.year := (hi(date) shr 1) + 1980;
- dt.month := (date shr 5) and 15;
- dt.day := lo(date) and 31;
- dt.hour := hi(time) shr 3;
- dt.min := (time shr 5) and 63;
- dt.sec := (lo(time) and 31) * 2;
- end;
- end;
-
-
- function __formatdate(d : longint; format : byte): string;
- var
- dt : datetime;
- begin
- __longint2datetime(d, dt);
- __formatdate := format_date(dt, format);
- end;
-
-
- function __retdow(y, m, d: word): word;
- var oy, om, od, odow : word;
- begin
- getdate(oy, om, od, odow); setdate(y, m, d); getdate(y, m, d, odow);
- setdate(oy, om, od);
- __retdow := odow;
- end;
-
-
- function __today: byte;
- var year, month, day, dow: word;
- begin
- getdate(year, month, day, dow);
- __today := dow;
- end;
-
-
-
-
-
-
-
-
-
- {$IFNDEF USETURBODOS}
- { IMPORTANT DOS FUNCTIONS XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX }
- procedure getdate(var year,month,day,dayofweek : word); external;
-
- procedure setdate(year,month,day : word); external;
-
- procedure gettime(var hour,minute,second,sec100 : word); external;
-
- procedure settime(hour,minute,second,sec100 : word); external;
- function diskfree(drive : byte) : longint; external;
-
- function disksize(drive : byte) : longint; external;
-
- procedure getfattr(var f;var attr : word); external;
-
- procedure setfattr(var f;attr : word); external;
-
- procedure getftime(var f;var time : longint); external;
-
- procedure setftime(var f; time : longint); external;
- procedure findfirst(path : pathstr;attr : word;var f : searchrec); external;
- procedure findnext(var f : searchrec); external;
-
- procedure unpacktime(p : longint;var t : datetime); external;
-
- procedure packtime(var t : datetime;var p : longint); external;
-
- function fexpand(path : pathstr) : pathstr; external;
-
- procedure fsplit(
- path : pathstr;var dir : dirstr;
- var name : namestr;var ext : extstr
- ); external;
- {$ENDIF}
-
-
- {$F+}
- function __existfil(pathname: string): boolean;
- var fileinfo: searchrec;
- begin
- findfirst(__normfil(pathname), anyfile, fileinfo);
- __existfil := (doserror = 0) and not(
- ((fileinfo.attr and volumeid) > 0) or
- ((fileinfo.attr and directory) > 0)
- )
- end;
-
-
- function __progname: string;
- const
- registered : boolean = false;
-
- begin
- if not registered then begin
- registeredprogname := __extractname(paramstr(0)); registered := true;
- end;
- __progname := registeredprogname;
- end;
-
-
- procedure __erasefil(filename : pathstr; var errorcode : word);
- var
- pathlen : word;
- reg : registers;
-
- begin
- pathlen := length(filename);
- move(filename[1],filename[0],pathlen);
- filename[pathlen] := #0;
- with reg do begin
- ax := $4100; ds := seg(filename); dx := ofs(filename); intr($21, reg);
- if ((flags and fcarry) <> 0) then errorcode := ax else errorcode := 0
- end
- end;
- {$F-}
-
-
- {$IFNDEF USETURBODOS}
- procedure intr(intno : byte;var regs : registers); external;
- procedure getintvec(intno: byte;var vector: pointer); external;
- procedure swapvectors; external;
- {$ENDIF}
-
-
- function __dosinkey(var extendedcode : byte) : char;
- var reg : registers;
- begin
- with reg do begin
- ah := $07; intr($21, reg);
- if (al=0) then begin
- __dosinkey := chr(0); ah := $07; intr($21,reg)
- end else __dosinkey := chr(al);
- extendedcode := al
- end
- end;
-
-
- function __exrdykey(
- useextended : boolean;
- var nextch : char;
- var scancode : byte
- ) : boolean;
- var reg : registers;
- begin
- with reg do begin
- flags := 0;
- if (useextended) then ah := $11 else ah := $01;
- intr($16, reg);
- if ((flags and fzero) = 0) then begin
- scancode := ah; nextch := char(al); __exrdykey := true
- end else __exrdykey := false
- end
- end;
-
-
-
- procedure __flushkey;
- var reg : registers;
- begin
- with reg do begin ax := $0c06; dx := $00ff end; intr($21, reg)
- end;
-
-
-
-
-
- function __queuekey : word;
- var
- bufferhead : word absolute _biosseg:$001a;
- buffertail : word absolute _biosseg:$001c;
- bufferstart : word absolute _biosseg:$0080;
- bufferend : word absolute _biosseg:$0082;
- avail : word;
-
- begin
- if (bufferhead > buffertail) then avail := (bufferhead - buffertail) else
- avail := (bufferhead + (bufferend - bufferstart) - buffertail);
- __queuekey := avail;
- end;
-
-
-
-
- function keypressed : boolean;
- begin
- keypressed := crt.keypressed;
- end;
-
-
-
-
- procedure __delay(w: word);
- var i : word;
-
- procedure wait_100; { 01:57:22.13 }
- begin
- starttimer(maxtimer);
- repeat until(__str(copy(getlaptime(maxtimer), 10, 2)) >= 9);
- stoptimer(maxtimer);
- end;
-
- procedure wait_250; { 01:57:22.13 }
- begin
- starttimer(maxtimer);
- repeat until(__str(copy(getlaptime(maxtimer), 10, 2)) >= 23);
- stoptimer(maxtimer);
- end;
-
- procedure wait_1000; { 01:57:22.13 }
- begin
- starttimer(maxtimer);
- repeat until(__str(copy(getlaptime(maxtimer), 7, 2)) >= 1);
- stoptimer(maxtimer);
- end;
-
- begin
- if (w < 5000) and (w > 100) then
- for i := 1 to __main(w, 250) div 250 do wait_250 else
- if (w < 5000) and (w <= 100) then
- for i := 1 to __main(w, 100) div 100 do wait_100 else
- for i := 1 to __main(w, 1000) div 1000 do wait_1000;
- end;
-
-
-
-
- procedure __delaykey(w:word);
- var
- i, jj : integer;
- c : char;
-
- begin
- i := 1;
- while i < (w div 250) do begin
- __delay(250); inc(i);
- if keypressed then begin i := maxint; __flushkey end;
- end;
- end;
-
-
-
- function __paridutl(var cmdprocid : word) : word;
- var cmdptr : pointer;
- begin
- getintvec($2e,cmdptr);
- cmdprocid := _vectoraddr(cmdptr)._seg;
- __paridutl := memw[prefixseg:$16]
- end;
-
-
-
- function cmdenvseg(var cmdprocid: word): word;
- type
- _memctrl = record
- _header : char;
- _ownerpsp : word;
- _size : word;
- _reserved : array[1..11] of byte
- end;
-
- var
- memblockptr : ^_memctrl;
- envseg : word;
- parid : word;
-
- begin
- parid := __paridutl(cmdprocid); memblockptr := ptr(cmdprocid - 1, 0);
- repeat
- __iptrsup(
- pointer(memblockptr),
- 16 * longint(memblockptr^._size + 1)
- );
- envseg := _vectoraddr(memblockptr)._seg + 1
- until (
- (memblockptr^._ownerpsp = cmdprocid) or
- (memblockptr^._header = 'Z')
- );
- if (memblockptr^._ownerpsp <> cmdprocid) then envseg := 0;
- cmdenvseg := envseg
- end;
-
-
-
-
- function __spaceutl(
- drive : byte;
- var availclus, totalclus,
- bytespersec, secsperclus: word
- ): longint;
- var reg : registers;
- begin
- with reg do begin
- ah := $36; dl := drive; intr($21,reg);
- if (ax = $ffff) then begin
- availclus := 0; totalclus := 0; bytespersec := 0;
- secsperclus := 0; __spaceutl := -1
- end else begin
- availclus := bx; totalclus := dx; bytespersec := cx;
- secsperclus := ax;
- __spaceutl := longint(bx) * longint(cx) * longint(ax)
- end
- end
- end;
-
-
-
- function __putenutl(envstr: string): string;
- type
- _memctrl = record
- _header : char;
- _ownerpsp : word;
- _size : word;
- _reserved : array[1..11] of byte
- end;
-
- function retmemblock(
- request: word; var allocbytes: word; var memoryptr: pointer
- ): pointer;
- var tempptr : pointer;
- begin
- allocbytes := 16 * (request + 1) + 15;
- getmem(memoryptr,allocbytes);
- if (memoryptr = nil) then begin
- allocbytes := 0; retmemblock := nil; exit
- end;
- fillchar(memoryptr^,allocbytes,$40);
- if (_vectoraddr(memoryptr)._ofs <> 0) then
- tempptr := ptr(_vectoraddr(memoryptr)._seg + 1,0) else
- tempptr := memoryptr;
- with _memctrl(tempptr^) do begin
- _header := 'M';
- _ownerpsp := prefixseg;
- _size := request;
- fillchar(_reserved,11,0)
- end;
- retmemblock := tempptr
- end;
-
- var
- envsize : word;
- errorcode : word;
- tempptr : pointer;
- newenvmemptr : pointer;
-
- begin
- __putenutl := '';
- if (envmemptr_ = nil) then begin
- envsize := memw[_envseg - 1:3];
- tempptr := retmemblock(envsize + 16,envsize_,envmemptr_);
- if (tempptr = nil) then exit;
- _envptr := ptr(_vectoraddr(tempptr)._seg + 1,0);
- move(memw[_envseg:0],_envptr^,16 * envsize);
- memw[prefixseg:$2c] := _vectoraddr(_envptr)._seg;
- __putenutl := __chgenutl(prefixseg,envstr,errorcode);
- if (errorcode <> 0) then __putenutl := ''
- end else begin
- __putenutl := __chgenutl(prefixseg,envstr,errorcode);
- if (errorcode <> 2) then exit;
- tempptr := retmemblock((envsize_ div 16) + 15, envsize, newenvmemptr);
- if (tempptr = nil) then exit;
- __iptrsup(tempptr,16);
- move(_envptr^,tempptr^,envsize_-_vectoraddr(envmemptr_)._ofs - 16);
- memw[prefixseg:$2c] := _vectoraddr(tempptr)._seg;
- _envptr := tempptr;
- freemem(envmemptr_,envsize_);
- envmemptr_ := newenvmemptr;
- envsize_ := envsize;
- __putenutl := __chgenutl(prefixseg,envstr,errorcode);
- if (errorcode <> 0) then __putenutl := ''
- end
- end;
-
-
-
-
- function __retenutl(var envpos : word) : string;
- type environmentptr = ^_memorychar;
- var
- envptr : environmentptr;
- strlen : integer;
- i : integer;
- tempch : char;
- tempstr : string;
- tempptr : pointer;
-
- begin
- envptr := environmentptr(_envptr);
- strlen := 0;
- i := envpos;
- tempch := envptr^[i];
- while (tempch <> #0) do begin
- inc(strlen);
- tempstr[strlen] := tempch;
- inc(i);
- tempch := envptr^[i]
- end;
-
- tempstr[0] := chr(strlen);
- if (strlen <> 0) then envpos := i + 1;
- __retenutl := tempstr
- end;
-
-
-
- function __chgenutl(progseg: word; envstr: string; var error: word): string;
- const
- equal = '=';
- blank = ' ';
- tab = #9;
-
- var
- envseg : word;
- cmdprocid : word;
- parid : word;
- envptr : ^_memorychar;
- idstr : string[127];
- prevsize : word;
- newsize : word;
- totalsize : word;
- varpos,varsize : integer;
- i,j : integer;
- lenenvstr : integer;
- equalpos : integer;
- eqsign : integer;
- eqpos : integer;
- found : boolean;
- envvar,retstr : string;
- tempch : char;
- locenvptr : pointer;
-
- begin
- __chgenutl := ''; error := 0;
- if (progseg = 0) then progseg := prefixseg;
- if (memw[progseg - 1:1] <> progseg) then begin
- error := 1; exit;
- end;
- envseg := memw[progseg:$2C];
- if (envseg = 0) then begin
- envseg := cmdenvseg(cmdprocid);
- if (progseg <> cmdprocid) then begin
- error := 1; exit;
- end
- end else if (memw[envseg - 1 : 1] <> progseg) then begin
- error := 1; exit
- end;
- locenvptr := _envptr; _envptr := ptr(envseg,0);
- i := 1; found := true; lenenvstr := length(envstr);
- while ((i <= lenenvstr) and found) do if (
- (envstr[i] = blank) or (envstr[i] = tab)
- ) then inc(i) else found := false;
- j := i - 1; lenenvstr := lenenvstr - j;
- eqsign := 0;
- for i := 1 to lenenvstr do begin
- tempch := envstr[i + j];
- if (tempch = equal) then begin inc(eqsign); eqpos := i end;
- if (eqsign <> 0) then envstr[i] := tempch else
- envstr[i] := upcase(tempch)
- end;
- if (eqsign <> 1) then begin error := 3; exit end else begin
- envstr[0] := chr(lenenvstr);
- __chgenutl := envstr
- end;
- envvar := copy(envstr,1,eqpos - 1); varpos := 0; prevsize := 1;
- repeat
- retstr := __retenutl(prevsize);
- if (length(retstr) <> 0) then begin
- if (varpos = 0) then if (
- envvar = copy(retstr,1,pos(equal,retstr) - 1)
- ) then begin varsize := length(retstr)+1; varpos := prevsize-varsize end;
- end;
- until (length(retstr) = 0);
- if (length(copy(envstr,eqpos + 1,255)) = 0) then begin
- newsize := prevsize; lenenvstr := 0
- end else newsize := prevsize + lenenvstr + 1;
- if (varpos <> 0) then newsize := newsize - varsize;
- idstr := ''; j := 0;
- envptr := ptr(envseg,prevsize);
- if (word(pointer(envptr)^) = 1) then begin
- __iptrsup(pointer(envptr),2);
- repeat
- inc(j);
- idstr[j] := envptr^[j]
- until (idstr[j] = #0)
- end;
- idstr[0] := char(j);
- totalsize := newsize + j;
- if (totalsize > (memw[envseg - 1:3] * 16)) then begin
- error := 2; __chgenutl := ''; exit
- end;
- envptr := ptr(envseg,0);
- if (varpos = 0) then move(envstr[1],envptr^[prevsize],lenenvstr) else begin
- move(
- envptr^[varpos + varsize],
- envptr^[varpos],prevsize - varpos - varsize
- );
- move(envstr[1],envptr^[prevsize - varsize],lenenvstr);
- end;
- envptr^[newsize - 1] := chr(0);
- envptr^[newsize] := chr(0);
- if (length(idstr) > 0) then begin
- envptr^[newsize + 1] := #1;
- envptr^[newsize + 2] := #0;
- move(idstr[1],envptr^[newsize + 3],length(idstr))
- end;
- _envptr := locenvptr;
- end;
-
-
-
- function __envpath(st: string): string; { ends on \ }
- var
- envpos : word;
- tmp, envstr: string;
-
- begin
- envpos := 1; envstr := __retenutl(envpos);
- while length(envstr) <> 0 do begin
- if copy(envstr,1, length(st)+1) = (st + '=') then
- tmp := copy(envstr,length(st)+2,length(envstr)-(length(st)+1));
- envstr := __retenutl(envpos)
- end;
- __envpath := tmp;
- end; { __envpath }
-
-
-
- function __getpath(var fname : string) : boolean;
- { returns the full path and filename for a filename if the file }
- { is found in the path. }
-
- var
- found : boolean;
- setpath,
- homedir,
- extractedpath : string;
- i, j, len : byte;
-
- begin
- homedir := __normfil(fname);
- if __existfil(homedir) then begin
- fname := homedir; __getpath := true; exit;
- end;
- setpath := __xlatestr(getenv('PATH'), ';', ' ') + ' ';
- j := 1; len := length(setpath);
- repeat
- inc(j); i := j;
- while (setpath[j] <> ' ') and (j < len) do inc(j); inc(j);
- extractedpath := __backapp(copy(setpath, i-1, j-i));
- found := __existfil(extractedpath + fname);
- until (found) or (j > len) or (i > len);
- if found then fname := extractedpath + fname;
- __getpath := found;
- end;
-
-
-
- function __address(zone, net, node, point: integer): string;
- begin
- __address :=
- __num(zone) + ':' + __num(net) + '/' + __num(node) + '.' + __num(point);
- end;
-
-
-
- procedure __expandnum(
- node : string; var tozone, tonet, tonode, topoint: word
- );
- var { zzzzz:nnnnn/nnnnn.ppppp }
- i, j : byte; { eg. '12:5003/1222.000' }
-
- begin
- i := pos(':', node);
- tozone := __str(copy(node, 1, i - 1));
- j := pos('/', node); if j=0 then j := pos('\', node);
- tonet := __str(copy(node, i + 1, j - i - 1));
- i := pos('.', node);
- if i > 0 then tonode := __str(copy(node, j+1, i-j-1)) else
- tonode := __str(copy(node, j+1, length(node)-j));
- topoint := __str(copy(node, i + 1, length(node) - i));
- end;
-
-
-
- function __expandchr(st: string; c: char; chh: string): string;
- var
- lenst,
- j : byte;
-
- begin
- j := 1; lenst := length(st);
- while (j <= lenst) do begin
- while (j <= lenst) and (st[j] <> c) do inc(j);
- if (j <= lenst) then begin
- delete(st, j, 1);
- if j < lenst then insert(chh, st, j) else st := st + chh;
- inc(lenst, length(chh)); inc(j, length(chh));
- end;
- end;
- __expandchr := st;
- end;
-
-
-
- function __ctrlkey(status : _keystatus) : longint;
- var
- statusloc : word absolute _biosseg:$0017;
- statusloc2 : byte absolute _biosseg:$0096;
- statusword : word;
- statusbyte : byte;
-
- begin
- statusword := 0; statusbyte := 0;
- with status do begin
- if (_insstate ) then statusword := statusword or $8000;
- if (_capsstate ) then statusword := statusword or $4000;
- if (_numstate ) then statusword := statusword or $2000;
- if (_scrollstate ) then statusword := statusword or $1000;
- if (_altshift ) then statusword := statusword or $0800;
- if (_ctrlshift ) then statusword := statusword or $0400;
- if (_leftshift ) then statusword := statusword or $0200;
- if (_rightshift ) then statusword := statusword or $0100;
- if (_insshift ) then statusword := statusword or $0080;
- if (_capsshift ) then statusword := statusword or $0040;
- if (_numshift ) then statusword := statusword or $0020;
- if (_scrollshift ) then statusword := statusword or $0010;
- if (_holdstate ) then statusword := statusword or $0008;
- if (_sysshift ) then statusword := statusword or $0004;
- if (_rightctrlshift) then statusbyte := statusbyte or $0008;
- if (_rightaltshift ) then statusbyte := statusbyte or $0004;
- if (_leftctrlshift ) then statusword := statusword or $0002;
- if (_leftaltshift ) then statusword := statusword or $0001
- end;
- statusloc := swap(statusword);
- statusloc2 := statusloc2 or statusbyte;
- __ctrlkey := longint(statusword) or (longint(statusbyte) shl 16)
- end;
-
-
- function __statkey(var status : _keystatus) : longint;
- var
- statusloc : word absolute _biosseg:$0017;
- statusloc2 : byte absolute _biosseg:$0096;
- statusword : word;
- statusbyte : byte;
-
- begin
- statusword := swap(statusloc); { 8086 stores "backwords" }
- statusbyte := (statusloc2 shr 2) and 3; { flags in 2 low order bits }
- with status do begin
- _insstate := ((statusword and $8000) <> 0);
- _capsstate := ((statusword and $4000) <> 0);
- _numstate := ((statusword and $2000) <> 0);
- _scrollstate := ((statusword and $1000) <> 0);
- _altshift := ((statusword and $0800) <> 0);
- _ctrlshift := ((statusword and $0400) <> 0);
- _leftshift := ((statusword and $0200) <> 0);
- _rightshift := ((statusword and $0100) <> 0);
- _insshift := ((statusword and $0080) <> 0);
- _capsshift := ((statusword and $0040) <> 0);
- _numshift := ((statusword and $0020) <> 0);
- _scrollshift := ((statusword and $0010) <> 0);
- _holdstate := ((statusword and $0008) <> 0);
- _sysshift := ((statusword and $0004) <> 0);
- _leftaltshift := ((statusword and $0002) <> 0);
- _leftctrlshift := ((statusword and $0001) <> 0);
- _rightctrlshift := ((statusbyte and $01) <> 0);
- _rightaltshift := ((statusbyte and $02) <> 0)
- end;
- __statkey := (longint(statusbyte) shl 16) or longint(statusword)
- end;
-
-
-
- function __stuffkey;
- type
- _keyseq = record _ch : char; _scancode : byte end;
-
- function placekey(keystroke : _keyseq) : boolean;
- var
- nextpos : word;
- bufferptr : ^word;
- bufferhead : word absolute _biosseg:$001a;
- buffertail : word absolute _biosseg:$001c;
- bufferstart : word absolute _biosseg:$0080;
- bufferend : word absolute _biosseg:$0082;
-
- begin
- nextpos := buffertail + 2; { we have wrap around }
- if (nextpos >= bufferend) then nextpos := bufferstart;
- { the buffer is full. }
- if (nextpos = bufferhead) then placekey := false else begin
- { put the sequence in right here. }
- bufferptr := ptr(_biosseg,buffertail);
- inline($fa); { disable interrupts }
- bufferptr^ := word(keystroke);
- buffertail := nextpos;
- inline($fb); { enable interrupts }
- placekey := true;
- end;
- end;
-
- var
- i,j : integer;
- lenstr : integer;
- keystroke : _keyseq;
- stuffed : boolean;
-
- begin
- lenstr := length(charstr);
- if (lenstr = 0) then begin { not much to do, so return }
- __stuffkey := charstr;
- exit
- end;
-
- i := 0; { can assume charstr is not empty }
- repeat
- inc(i);
- j := i; { save character position in }
- { case it cannot be stuffed. }
- with keystroke do begin
- _ch := charstr[i]; _scancode := 0
- end;
- stuffed := placekey(keystroke)
- until ((i = lenstr) or (not stuffed));
-
- if (not stuffed) then __stuffkey := copy(charstr,j,lenstr) else
- __stuffkey := ''
- end;
-
-
-
-
- procedure __resetsup(testmem : boolean);
- var
- reset_flag : word absolute $40:$72;
- ch : char;
-
- begin
- if testmem then reset_flag := $0000 else reset_flag := $1234;
- inline($ea/$00/$00/$ff/$ff) { jmp ffff:0000 }
- end;
-
-
-
-
- procedure __resetfil;
- var reg : registers;
- begin
- with reg do begin
- ah := $0d;
- intr($21, reg)
- end;
- end;
-
-
- function fopen; {open untyped file return the dos error code}
- var fm : byte;
- begin
- assign(fv,fn);
- fm := filemode;
- if mode <> _keep_mode then filemode := mode;
- reset(fv,1);
- fopen := ioresult;
- filemode := fm;
- end;
-
-
-
-
- function fclose(var fv : stream) : integer;
- begin
- close(fv);
- fclose := ioresult;
- end;
-
-
-
-
- function shareloaded : boolean;
- var reg : registers;
- begin
- reg.ax := $1000;
- intr($2f,reg);
- shareloaded := ((reg.flags and $01) = 0) and (reg.al = $ff);
- end;
-
-
- {
- Lock or Unlock region of file.
- Input : Handle - turbo untype file variable handle (filerec(fv).handle)
- input : action - action to take. See constants above;
- input : start - beginging file position to lock.
- input : bytes - number of bytes to lock.
- output : ax - ax register return value
- returns TRUE if lock is successful, False otherwise (check AX)
- }
-
-
- function filelock(handle : word; action : byte; start,bytes : longint; var ax : integer): boolean;
- var reg : registers;
- begin
- reg.ax := $5c00 + action;
- reg.bx := handle;
- reg.cx := hi(start);
- reg.dx := lo(start);
- reg.si := hi(bytes);
- reg.di := lo(bytes);
- intr($21,reg);
- filelock := (reg.flags and $01) = $00;
- ax := reg.ax;
- end;
-
-
-
-
- function __exinkey(useextended: boolean; var scancode: byte): char;
- var reg : registers;
- begin
- with reg do begin
- if (useextended) then ah := $10 else ah := 0;
- al := 0; intr($16, reg); scancode := ah;
- __exinkey := char(al)
- end
- end;
-
-
- function __retkey: word;
- var
- ch: char;
- sc: byte;
-
- begin
- ch := __exinkey(true, sc);
- lastkey := ch; lastscan := sc;
- __retkey := __2wordsup(sc, ord(ch))
- end;
-
-
-
- function __retdelaykey(delaytim: byte; default: word): word; { delay < 60 }
- var
- ch: char;
- sc: byte;
-
- begin
- ch := #00;
- if delaytim = 0 then __retdelaykey := __retkey else begin
- starttimer(2);
- repeat __exrdykey(true, ch, sc) until (
- (delaytim > 0) and (__str(copy(getlaptime(2), 7, 2)) >= delaytim)
- ) or (ch <> #00);
- if ch = #00 then begin { timeout occurred }
- if default > 0 then __retdelaykey := default else __retdelaykey := 0;
- end else begin
- lastkey := ch; lastscan := sc;
- __retdelaykey := __2wordsup(sc, ord(ch)); __flushkey
- end;
- end;
- end;
-
-
-
- function __attrfilter(fileattr, filter: byte): boolean;
- {
- only and notnone may only be used in conjunction with other attribs like
- readonly, hidden, sysfile, volumeid, directory and archive.
- }
- type
- filterenum = (r_o, hid, sys, vol, dir, arc, only, notnone);
- filterenumset = set of filterenum;
-
- var
- makefilter : filterenumset;
- filefilter : filterenumset;
-
- begin
- makefilter := filterenumset(filter);
- filefilter := filterenumset(fileattr);
- if (
- (notnone in makefilter) and ((filefilter - [notnone]) = [])
- ) then __attrfilter := false else if only in makefilter then
- __attrfilter := (filefilter + [only] = makefilter) else
- __attrfilter := (filefilter <= makefilter);
- end; { __attrfilter }
-
-
-
- function __bak(s: string): string;
- var
- st : string;
- i : byte;
-
- begin
- st := __extractname(s);
- if pos('.', st) = 0 then __bak := st + '.BAK' else begin
- i := length(s);
- while (i > 0) and (s[i] <> '.') do dec(i);
- __bak := copy(st, 1, i) + 'BAK';
- end;
- end;
-
-
- function __comexebatcmdfilter;
- begin
- __comexebatcmdfilter := (
- __comp(__extractext(s), 'EXE') or __comp(__extractext(s), 'CMD') or
- __comp(__extractext(s), 'COM') or __comp(__extractext(s), 'BAT')
- );
- end;
-
-
-
- function __retdrfil : char;
- var reg : registers;
- begin
- with reg do begin
- ah := $19; intr($21, reg);
- __retdrfil := char(byte('A') + al)
- end
- end;
-
-
- function __curdir: string;
- var s: string;
-
- begin
- getdir(0, s); __curdir := s;
- end;
-
-
-
- function __deverr: string;
- begin
- case doserror of
- 000: __deverr := 'No DosError Detected!';
- 002: __deverr := 'File not found';
- 003: __deverr := 'Path not found';
- 004: __deverr := 'Too many open files';
- 005: __deverr := 'File acces denied';
- 006: __deverr := 'Invalid file handle';
- 012: __deverr := 'Invalid file access code';
- 015: __deverr := 'Invalid drive number';
- 016: __deverr := 'Cannot remove current directory';
- 017: __deverr := 'Cannot rename across drives';
- 018: __deverr := 'No more files found';
- 100: __deverr := 'Disk read error';
- 101: __deverr := 'Disk write error';
- 102: __deverr := 'File not assigned';
- 103: __deverr := 'File not open';
- 104: __deverr := 'File not open for input';
- 105: __deverr := 'File not open for output';
- 106: __deverr := 'Invalid numeric format';
- 150: __deverr := 'Disk is write protected';
- 151: __deverr := 'Unknown unit';
- 152: __deverr := 'Drive not ready';
- 153: __deverr := 'Unknown command';
- 154: __deverr := 'CRC error in data';
- 155: __deverr := 'Bad drive request structure length';
- 156: __deverr := 'Disk seek error';
- 157: __deverr := 'Unknown media type';
- 158: __deverr := 'Sector not found';
- 159: __deverr := 'Printer out of paper';
- 160: __deverr := 'Device write fault';
- 161: __deverr := 'Device read fault';
- 162: __deverr := 'Hardware failure'
- else __deverr := 'Unrecognised Drive Error . . .'
- end; { of case }
- end;
-
-
- procedure __drvparm(drv: char);
- var
- regs : registers;
- error : word;
-
- begin
- if drv = ' ' then begin
- regs.ah := $19;
- intr($21, regs);
- _dosdrv := regs.al; inc(_dosdrv); { dos drive 0 = a }
- _dosdrvchar := chr(_dosdrv + 64); { turbo counts from 1 = a }
- end else _dosdrv := ord(upcase(drv)) - 64; { 65 = ascii(upcase(a)) }
- _dosdiscfree := diskfree(_dosdrv);
- _dosdiscsize := disksize(_dosdrv);
- getdir(_dosdrv, _doscurpath)
- end;
-
-
- (*
- function __envpath(st: string): string; { ends on \ }
- var
- envpos : word;
- tmp, envstr : string;
-
- begin
- envpos := 1; envstr := __retenutl(envpos);
- while length(envstr) <> 0 do begin
- if copy(envstr,1, length(st)+1) = (st + '=') then
- tmp := copy(envstr,length(st)+2,length(envstr)-(length(st)+1));
- envstr := __retenutl(envpos)
- end;
- if tmp[length(tmp)] <> '\' then tmp := tmp + '\';
- if tmp[length(tmp)] = ' ' then tmp := copy(tmp, 1, length(tmp)-1);
- __envpath := tmp;
- end; { __envpath }
- *)
-
-
-
- procedure __erasefiles(s: string);
- var
- error : word;
- st : string;
-
- begin
- while __findfil(s, st) do __erasefil(st, error);
- end;
-
-
-
- {$I+}
- function __existpath(s: string): boolean; { no trailing \ please }
- var atri : searchrec;
- begin
- if s[length(s)]=_dirslash then findfirst(
- __normfil(s + '*.*'), anyfile, atri
- ) else findfirst(
- __normfil(s + '\*.*'), anyfile, atri
- );
- __existpath := (doserror=0)
- end;
- {$I-}
-
-
-
-
- function __extractext;
- var p: byte;
- begin
- p := length(name);
- while (not(name[p] = _dirslash)) and (p > 0) do dec(p);
- while (name[p] <> '.') and (p < length(name)) do inc(p);
- { . or not }
- if (name[p] <> '.') and (__lastchr(name) <> '.') then
- __extractext := '' else
- __extractext := copy(name, p+1, length(name) - p);
- end;
-
-
-
- function __extractname(s : string): string;
- var
- i, j : byte;
-
- begin
- i := length(s);
- if pos('.', s) > 0 then while (s[i] <> '.') and (i > 0) do dec(i);
- j := i;
- while (s[j] <> _dirslash) and (j > 0) do dec(j);
- __extractname := copy(s, j+1, i-j-1);
- end;
-
-
-
- function __extractnamext(s : string): string;
- var
- i, j : byte;
-
- begin
- i := length(s); j := i;
- if pos(_dirslash, s) > 0 then while (s[j] <> _dirslash) and (j > 0) do dec(j);
- __extractnamext := copy(s, j+1, i-j);
- end;
-
-
-
- function __extractpath(s : string): string; { eindigt op \ }
- var
- i : byte;
-
- begin
- i := length(s); while (s[i] <> _dirslash) and (i > 1) do dec(i);
- __extractpath := copy(s, 1, i);
- end;
-
-
-
-
-
- function __findfil(f: string; var s: string): boolean;
- var
- r : searchrec;
- l : string;
- j, e : byte;
-
- begin
- fillchar(r, sizeof(r), #0); findfirst(__normfil(f), $3f, r); e := doserror;
- if ((r.attr and directory)>0) or ((r.attr and volumeid)>0) then e := 0;
- j := length(f);
- if pos(_dirslash, f) > 0 then while f[j] <> _dirslash do dec(j);
- if e = 0 then s := copy(f, 1, j) + r.name else s := __num(e);
- if e = 0 then __findfil := true else __findfil := false;
- end;
-
-
-
- function __inparams(s: string; var i: word): boolean;
- var
- j : byte;
- t : string;
- b : boolean;
-
- begin
- b := false;
- if casesensitive_env then s := __up(s);
- for j := 1 to paramcount do begin
- if casesensitive_env then t := __up(paramstr(j)) else t := paramstr(j);
- if __comp(s, t) then begin i := j + 1; b := true end;
- end;
- __inparams := b;
- end;
-
-
-
- function __checkstr(pa, en: string; var j, k : word): boolean;
- begin
- j := pos(__up(pa), __up(en));
- __checkstr := (j > 0) and (length(pa) > 0) and (length(en) > 0);
- if j > 0 then begin
- inc(j, length(pa)); while (en[j] = ' ') and (j <= length(en)) do inc(j);
- end;
- k := j; while (en[k] <> ' ') and (k <= length(en)) do inc(k);
- {
- j..k is parameter after switch "pa" in "en"
- e.g. PROG /x 12 /u 2
- 1234567890
- __checkstr('/x', '/x 12 /u 2', j, k);
- j = 4
- k = 5
- }
- end;
-
-
-
- function __packfil(str: string; size: byte): string;
- var i,ii: byte;
- begin
- if size < 15 then size := 15;
- str := __xlatestr(__backrem(__normfil(str)), '\', _dirslash);
- if length(str) <= size then __packfil := str else begin
- while length(str) > size+1 do begin
- i := pos(_dirslash,str); inc(i); ii := i;
- while str[ii] <> _dirslash do inc(ii);
- inc(ii); delete(str,i,ii-i);
- end; i := pos(_dirslash,str); delete(str,i,1);
- __packfil := str
- end;
- end;
-
-
-
-
- procedure __parsefil(name: filestr; var nam: namestr; var ext: extstr);
- var p: byte;
- begin
- p := pos('.', name); fillchar(nam, 8, ' '); fillchar(ext, 3, ' ');
- if p = 0 then begin
- nam := name; ext := ' '
- end else begin
- nam := copy(name, 1, p-1);
- ext := copy(name, p+1, length(name)-p);
- end;
- end;
-
-
- function __slashfil;
- begin
- s := __xlatestr(s, '/\', _dirslash+_dirslash);
- __slashfil := s;
- end;
-
-
- function __normfil(filename : pathstr) : pathstr;
- const
- colon = ':';
- fslash = '/';
- bslash = '\';
-
-
- procedure getnextdir(
- filename : pathstr;
- getdrive : boolean;
- var startpos : byte;
- var rettoken : pathstr
- );
- var
- len : byte;
- curdrive : char;
- curdir : string;
-
- begin
- rettoken := '';
- if (getdrive) then begin
- startpos := 1;
- if ((length(filename) > 1) and (filename[2] = colon)) then begin
- curdrive := upcase(filename[1]); inc(startpos,2)
- end else curdrive := __retdrfil;
- rettoken := curdrive + ':\';
- if (
- (startpos > length(filename)) or
- (
- (filename[startpos] <> fslash) and
- (filename[startpos] <> bslash)
- )
- ) then begin
- getdir(byte(curdrive) - 64,curdir);
- if (ioresult = 0) then rettoken := curdir
- end
- end else begin
- if (startpos > length(filename)) then exit;
- if (
- (filename[startpos] = fslash) or
- (filename[startpos] = bslash)
- ) then begin
- len := 1; rettoken[1] := bslash; inc(startpos)
- end else len := 0;
- while (
- (startpos <= length(filename)) and
- (filename[startpos] <> fslash) and
- (filename[startpos] <> bslash)
- ) do begin
- inc(len);
- rettoken[len] := upcase(filename[startpos]);
- inc(startpos)
- end;
- rettoken[0] := char(len)
- end
- end; { subproc }
-
-
- procedure putnextdir(
- token: pathstr;
- var lastdirpos : byte;
- var normfile : pathstr
- );
- var len : byte;
- begin
- if (
- (token = '.') or (token = '\.') or (length(token) = 0)
- ) then exit else if ((token = '..') or (token = '\..')) then begin
- if (lastdirpos > 0) then begin
- if (lastdirpos = 3) then normfile[0] := char(lastdirpos);
- dec(lastdirpos);
- if (lastdirpos > 2) then normfile[0] := char(lastdirpos);
- while (
- (lastdirpos >= 1) and
- (normfile[lastdirpos] <> bslash)
- ) do dec(lastdirpos)
- end
- end else begin
- len := length(normfile);
- if ((normfile[len] = bslash) and (token[1] = bslash)) then begin
- dec(len);
- normfile[0] := char(len)
- end else if (
- (normfile[len] <> bslash) and
- (token[1] <> bslash)
- ) then normfile := normfile + bslash;
- lastdirpos := length(normfile) + 1;
- normfile := normfile + token
- end
- end;
-
-
- var
- nextsubdir : byte;
- lastsubdir : byte;
- subdir : pathstr;
- normalfile : pathstr;
-
-
-
- begin
- nextsubdir := 0;
- getnextdir(filename,true,nextsubdir,normalfile);
- lastsubdir := length(normalfile) - 1;
- while (
- (lastsubdir >= 1) and (normalfile[lastsubdir] <> bslash)
- ) do dec(lastsubdir);
- while (nextsubdir <= length(filename)) do begin
- getnextdir(filename,false,nextsubdir,subdir);
- putnextdir(subdir,lastsubdir,normalfile);
- end;
- __normfil := normalfile
- end;
-
-
-
-
- procedure __splitfil(
- pathname : pathstr;
- var subdir : dirstr;
- var filename : namestr;
- var fileext : extstr
- );
-
- const
- colon = ':';
- fslash = '/';
- bslash = '\';
- period = '.';
-
- var
- i : byte;
- len : byte;
- found : boolean;
- extpos : byte;
- dirpos : byte;
- filelen : byte;
- thischar : char;
-
- begin
- subdir := ''; filename := ''; fileext := ''; len := length(pathname);
- found := false; extpos := 0; i := len;
- while ((not found) and (i >= 1)) do begin
- thischar := pathname[i];
- if (thischar = period) then begin
- found := true;
- if (
- (
- (i > 1) and (pathname[i - 1] <> colon) and
- (pathname[i - 1] <> period) and (pathname[i - 1] <> fslash) and
- (pathname[i - 1] <> bslash)
- ) or
- (
- (i < len) and (pathname[i + 1] <> period) and
- (pathname[i + 1] <> fslash) and (pathname[i + 1] <> bslash)
- )
- ) then extpos := i
- end else dec(i)
- end;
- if (extpos > 0) then begin
- fileext := copy(pathname,extpos,4); i := extpos - 1
- end else i := len;
- found := false; dirpos := 0; filelen := 0;
- while ((not found) and (i >= 1)) do begin
- thischar := pathname[i];
- if (
- (thischar = fslash) or (thischar = bslash) or
- (thischar = colon) or (thischar = period)
- ) then begin dirpos := i; found := true end else begin
- inc(filelen); dec(i)
- end
- end;
- if (filelen > 0) then filename := copy(pathname,dirpos + 1,filelen);
- if (dirpos > 0) then subdir := copy(pathname,1,dirpos)
- end;
-
-
-
-
- function __searchrec(
- src : searchrec;
- nm, woord, mainsize : word;
- takemainsize, extended,
- ampm, show_attr,
- wide : boolean
- ): string;
-
- const
- blank = #32;
- zero = #48;
- period = #46;
-
- var
- i, j : word;
- l,
- tmpstr : string;
- ampmch : string[1];
- namestr : string[8];
- extstr : string[4];
- sizestr : string[26];
- datestr : string;
- hourstr : string[4];
- minstr : string[2];
- attrstr : string[18];
- dt : datetime;
-
-
- begin {__searchrec}
- with src do begin
- fillchar(namestr[1], 8, blank); namestr[0] := #8;
- fillchar(extstr[1], 4, blank); extstr[0] := #4;
- if (name='.') or (name='..') then move(name[1], namestr[1], length(name))
- else begin
- {if ((attr and volumeid) <> 0) then j := 1 else j := 2;} j := 2;
- i := pos('.', name); if (i = 0) then i := succ(length(name))
- else move(name[succ(i)], extstr[j], length(name) - i);
- move(name[1], namestr[1], pred(i));
- end;
- if (((attr and directory)<>0) and not takemainsize) then
- sizestr := ' <DIRECTORY> ' else
- if (((attr and directory)<>0) and takemainsize) then
- sizestr := ' <DIR>' else
- if (((attr and volumeid)<>0) and not takemainsize) then
- sizestr := ' <VOLUMEID> ' else
- if (((attr and volumeid)<>0) and takemainsize) then
- sizestr := ' <VOL>' else
- if ((size=0) and not takemainsize) then
- sizestr := ' <NULFILE> ' else
- if ((size=0) and takemainsize) then
- sizestr := ' <NUL>' else
- if takemainsize then sizestr := __juststr(
- __pntstr(size) + 'K', ' ', 8, _right_just_str
- ) else sizestr := __juststr(
- __pntstr(size), ' ', 13, _right_just_str
- );
- if extended then begin
- if (
- ((attr and directory) <> 0) or ((attr and volumeid) <> 0) or
- (size = 0)
- ) then sizestr := sizestr + ' [USED]' else if not takemainsize then
- sizestr := sizestr + __juststr(
- __num(__main(size, mainsize) div 1024) + 'K', ' ', 7,
- _right_just_str
- );
- end;
-
- unpacktime(time, dt);
- with dt do begin
- if extended then datestr := '' else datestr := ' ';
- if year * month * day <= 0 then
- datestr := datestr + ' ' + __dt2ststr(1993, 1, 1, woord) else
- datestr := datestr + ' ' + __dt2ststr(year, month, day, woord);
- if (hour > 12) and ampm then begin dec(hour, 12); ampmch := 'p' end else
- if ampm then ampmch := 'a' else ampmch := '';
- str(hour:4, hourstr); str(min:2, minstr);
- if (minstr[1] = blank) then minstr[1] := zero
- end;
- if not extended then attrstr := ' ' else attrstr := ' ';
- if show_attr then begin
- if woord <> 4 then begin
- if (attr and readonly)>0 then attrstr := attrstr + 'R/O ' else
- attrstr := attrstr + ' ';
- end else begin
- if (attr and readonly)>0 then attrstr := attrstr + 'R' else
- attrstr := attrstr + ' ';
- end;
- if woord <> 4 then begin
- if (attr and hidden)>0 then attrstr := attrstr + 'Hid ' else
- attrstr := attrstr + ' ';
- end else begin
- if (attr and hidden)>0 then attrstr := attrstr + 'H' else
- attrstr := attrstr + ' ';
- end;
- if woord <> 4 then begin
- if (attr and sysfile)>0 then attrstr := attrstr + 'Sys ' else
- attrstr := attrstr + ' ';
- end else begin
- if (attr and sysfile)>0 then attrstr := attrstr + 'S' else
- attrstr := attrstr + ' ';
- end;
- if woord <> 4 then begin
- if (attr and archive)>0 then attrstr := attrstr + 'Arc ' else
- attrstr := attrstr + ' '
- end else begin
- if (attr and archive)>0 then attrstr := attrstr + 'A' else
- attrstr := attrstr + ' '
- end;
- end;
- if not extended then attrstr := attrstr + ' ';
- if wide then begin
- namestr := __nw(namestr); extstr := __nw(extstr);
- end;
-
- if wide and ((attr and directory)=0) then begin
- tmpstr := __juststr(' ' + namestr + '.'+ extstr, ' ', 16, _left_just_str)
- end else begin
- if ((attr and directory) > 0) then begin
- if wide then tmpstr := __juststr(
- ' [' + namestr + extstr + ']', ' ', 16, _left_just_str
- ) else tmpstr := __juststr(
- ' ' + namestr + extstr, ' ', 14, _left_just_str
- )
- end else tmpstr := ' '+ __juststr(namestr, ' ', 8, _left_just_str)+' '+
- __juststr(extstr, ' ', 3, _right_just_str);
- end;
-
- l := '';
- if extended then l := __juststr(__num(nm), ' ', 3, _right_just_str);
- __searchrec := l + tmpstr + sizestr + datestr + hourstr + ':' +
- minstr + ampmch + attrstr;
- end;
- end; { __searchrec }
-
-
-
-
- function __sizefil(pt: string): longint;
- var atri: searchrec;
- begin
- findfirst(pt, anyfile, atri);
- __sizefil := atri.size;
- end;
-
-
-
-
- function __strattr(attr: byte; full: boolean): string;
- type
- filterenum = (r_o, hid, sys, vol, dir, arc, bit6, bit7);
- fs = set of filterenum;
-
- const
- ats: array[filterenum] of string[9] = (
- 'ReadOnly', 'Hidden', 'System',
- 'VolumeID', 'Directory', 'Archive',
- 'Only', 'NotNone'
- );
-
- var
- st : string;
- len : byte;
- filter : fs;
-
- begin
- filter := fs(attr); st := '';
- if full then len := 9 else len := 1;
- if r_o in filter then st := st + copy(ats[r_o], 1, len);
- if hid in filter then st := st + ', ' + copy(ats[hid], 1, len);
- if sys in filter then st := st + ', ' + copy(ats[sys], 1, len);
- if vol in filter then st := st + ', ' + copy(ats[vol], 1, len);
- if dir in filter then st := st + ', ' + copy(ats[dir], 1, len);
- __strattr := st;
- end;
-
-
-
- procedure __uniquefil( { i.s.o. __tempfil, an unique textfile }
- var pathname: string; var tmpfile: text; var errorcode: word
- );
- var
- pathz : pathstr; { asciiz string for pathname }
- pathlen : byte;
- reg : registers;
- frec : textrec;
-
- begin
- pathlen := length(pathname);
- if (pathname[pathlen] <> _dirslash) then begin { must have a trailing backslash }
- pathname := pathname + _dirslash; inc(pathlen)
- end;
- pathname := __normfil(pathname);
- move(pathname[1],pathz,pathlen);
- pathz[pathlen] := #0;
- with reg do begin { call dos function $5a }
- ax := $5a00; ds := seg(pathz); dx := ofs(pathz); cx := {fileattr} 0;
- intr($21,reg);
- if ((flags and fcarry) <> 0) then errorcode := ax else with frec do begin
- fillchar(frec, sizeof(frec), #0);
- errorcode := 0;
- mode := fminout;
- (*recsize := {rsize} 1;*)
- handle := ax; { the dos file handle }
- move(pathz,pathname[1],67); { return new file path name}
- move(pathz,name,67);
- pathname[0] := #67; { search for the nul byte }
- pathname[0] := chr(pos(#0,pathname)); { and set length }
- textrec(tmpfile) := frec
- end;
- end;
- end; { __uniquefil }
-
-
- {$I-}
- function __copyfil(show: boolean; x1,x2,y,f,b: byte; fs: longint; src, targ: string): byte;
- {
- return codes:
- 0 successful
- 1 source and target the same
- 2 cannot open source
- 3 unable to create target
- 4 error during copy
- 5 cannot allocate buffer
- }
- const
- bufsize = 16384;
-
- type
- fbuf = array[1..bufsize] of char;
- fbf = ^fbuf;
-
- var
- source,
- target : file;
- bread,
- bwrite : word;
- filebuf : ^fbf;
- tr : longint;
- nr : real;
-
- begin
- if memavail > bufsize then new(filebuf) else begin __copyfil := 5; exit end;
- if src = targ then begin __copyfil := 1; exit end;
- assign(source, src); reset(source,1);
- if ioresult <> 0 then begin __copyfil := 2; exit end;
- assign(target, targ); rewrite(target,1);
- if ioresult <> 0 then begin __copyfil := 3; exit end;
- if show then __write(x1+2,y,f,b,__rep(x2-x1-3,'โ')); tr := 0;
- repeat
- blockread(source,filebuf^,bufsize,bread);
- tr := tr + bread; nr := tr/fs;
- nr := nr * (x2-x1-3);
- if show then __write(x1+2,y,f,b,__rep(trunc(nr), 'โ'));
- blockwrite(target,filebuf^,bread,bwrite);
- until (bread = 0) or (bread <> bwrite);
- if show then __write(x1+2,y,f,b,__rep((x2-x1-3),'โ'));
- close(source); close(target);
- if bread <> bwrite then __copyfil := 4 else __copyfil := 0;
- end;
- {$I-}
-
-
- procedure __renamfil(prevname,newname : pathstr; var errorcode : word);
- var
- pathlen : integer;
- reg : registers;
-
- begin
- pathlen := length(prevname); { first transform to asciiz }
- move(prevname[1],prevname[0],pathlen); { strings (i.e., trailing }
- prevname[pathlen] := #0; { nul byte). }
- pathlen := length(newname);
- move(newname[1],newname[0],pathlen);
- newname[pathlen] := #0;
-
- with reg do begin
- ax := $5600;
- ds := seg(prevname); { pointers to the previous and }
- dx := ofs(prevname); { new asciiz strings }
- es := seg(newname);
- di := ofs(newname);
- intr($21, reg);
- if ((flags and fcarry) <> 0) then errorcode := ax else errorcode := 0
- end
- end;
-
-
- function __slicefil(
- x1, x2, y, f, b: byte; haksize: longint; src: string
- ): byte;
- {
- return codes:
- 0 successful
- 1 source and target the same
- 2 cannot open source
- 3 unable to create target
- 4 error during copy
- 5 cannot allocate buffer
- }
- const
- bufsize = 16384;
- max360 = 0360000;
- max720 = 0720000;
- max1200 = 1220000;
- max1440 = 1440000;
- max2880 = 2880000;
-
-
- type
- fbuf = array[1..bufsize] of char;
- fbf = ^fbuf;
- str3 = string[3];
-
- var
- source,
- target : file;
- bread,
- bwrite : word;
- filebuf : ^fbf;
- maxondisc,
- sessionread,
- vn, tr, fs : longint;
- nr : real;
- targ : string;
-
-
- function __volgnum(l: longint): str3;
- begin
- __volgnum := __juststr(__num(l), '0', 3, _right_just_str)
- end;
-
-
- begin
- src := __normfil(src); fs := __sizefil(src); targ := __extractname(src);
- if diskfree(byte(src[1])-byte('A')+1)<fs then begin __slicefil := 6; exit end;
- if haksize = 360 then maxondisc := max360;
- if haksize = 720 then maxondisc := max720;
- if haksize = 1200 then maxondisc := max1200;
- if haksize = 1440 then maxondisc := max1440;
- if haksize = 2880 then maxondisc := max2880;
- if haksize = 0 then maxondisc := max1440 else maxondisc := __main(haksize, 16384);
- if memavail > bufsize then new(filebuf) else begin __slicefil := 5; exit end;
- if src = targ then begin __slicefil := 1; exit end;
- assign(source, src); reset(source,1);
- if ioresult <> 0 then begin __slicefil := 2; exit end;
- __write(x1,y,f,b,__rep(x2-x1-1,'โ'));
- tr := 0; { keeps track on total bytes written for statusbar }
- vn := 1; { virtual number for numbering the chunks }
- repeat
- assign(target, targ + '.' + __volgnum(vn)); rewrite(target,1);
- if ioresult <> 0 then begin __slicefil := 3; exit end;
- sessionread := 0; { keeps track on bytes written to ONE CHUNK }
- __write(50, y, f, b, 'Writing chunk ' + targ + '.' + __volgnum(vn));
- repeat
- blockread(source,filebuf^,bufsize,bread);
- inc(sessionread, bread); inc(tr, bread); nr := tr/fs;
- nr := nr * (x2-x1-3);
- __write(x1, y, f, b, __rep(trunc(nr), 'โ'));
- blockwrite(target,filebuf^,bread,bwrite);
- until (bread = 0) or (bread <> bwrite) or (sessionread >= maxondisc);
- inc(vn);
- close(target);
- until (bread = 0) or (bread <> bwrite);
- __write(x1, y, f, b, __rep((x2-x1-1),'โ'));
- close(source);
- if bread <> bwrite then __slicefil := 4 else __slicefil := 0;
- end;
- {$I-}
-
-
-
- { $ L rdsector}
- procedure rdsector(driveno : word; var errorcode : word); external;
-
- function __isdrvfil(drive : char; var errorcode : word) : boolean;
- const
- needtoread = 99;
-
- var
- driveno : word;
- lastdrive : word;
- reg : registers;
-
- begin
- with reg do begin
- ah := $19;
- intr($21, reg);
-
- ah := $0e;
- dl := al;
- intr($21, reg);
- dec(al);
- lastdrive := al
- end;
-
- driveno := word(upcase(drive)) - word('A');
- if (driveno > lastdrive) then errorcode := 1 else begin
- errorcode := needtoread;
- if (_dosmajorver >= 3) then with reg do begin
- ah := $44;
- al := $08;
- bl := driveno + 1;
- intr($21, reg);
- if ((flags and fcarry = 0) and (ax = 1)) then errorcode := 0;
- end;
- if (errorcode = needtoread) then begin
- rdsector(driveno,errorcode);
- if (errorcode <> 0) then if (errorcode = $0207) then begin
- if (_dosmajorver >= 4) then errorcode := 0 else
- if (
- {(_compaq) and} (_dosmajorver >=3 ) and (_dosminorver >= 31)
- ) then errorcode := 0 else errorcode := 3
- end else if (errorcode = $8002) then errorcode := 2 else
- if (errorcode = driveno) then errorcode := 1 else
- if (errorcode >= 3) then errorcode := 3;
- end
- end;
- __isdrvfil := (errorcode = 0)
- end;
-
-
-
- function __retdtfil : pointer;
- var reg : registers;
- begin
- with reg do begin
- ah := $2f;
- intr($21, reg);
- __retdtfil := ptr(es,bx)
- end
- end;
-
-
- procedure __setdtfil(dtaaddress : pointer);
- var reg : registers;
- begin
- with reg do begin
- ah := $1a;
- ds := _vectoraddr(dtaaddress)._seg;
- dx := _vectoraddr(dtaaddress)._ofs
- end;
- intr($21, reg)
- end;
-
- function __retvlfil(drive : char; var volstamp : longint) : string;
- var
- extendedfcb : array[-7..36] of byte;
- dtaptr : pointer;
- tempdta : array[0..44] of byte;
- driveno : byte;
- volname : string;
- reg : registers;
-
- begin
- dtaptr := __retdtfil;
- __setdtfil(@tempdta);
- driveno := byte(upcase(drive)) - byte('A') + 1;
- extendedfcb[-7] := $ff;
- extendedfcb[-1] := $08;
- extendedfcb[0] := driveno;
- fillchar(extendedfcb[1],11,$3f);
- fillchar(extendedfcb[12],25,0);
-
- with reg do begin
- ah := $11;
- ds := seg(extendedfcb);
- dx := ofs(extendedfcb);
- intr($21, reg);
- if (al = $ff) then begin
- volstamp := 0;
- __retvlfil := ''
- end else begin
- move(tempdta,extendedfcb[-7],39);
- move(extendedfcb[1],volname[1],11);
- volname[0] := #11;
- __retvlfil := volname;
- move(extendedfcb[23],volstamp,4);
- end
- end;
- __setdtfil(dtaptr)
- end;
-
-
-
- function __handlfil(var filevar) : word;
- begin
- if (filerec(filevar).mode = fmclosed) then __handlfil := $ffff else
- __handlfil := filerec(filevar).handle
- end;
-
-
- function __isconfil(handle : word) : boolean;
- var reg : registers;
- begin
- with reg do begin
- ah := $44;
- al := 0;
- bx := handle;
- intr($21,reg);
- __isconfil := ((dl and $80) <> 0) and ((dl and $03) <> 0)
- end
- end;
-
-
-
-
-
- {$F+}
- function callcondition(var search): boolean;
- inline($ff/$1e/conditionfuncptr_);
-
-
-
- {$F+}
- function no_condition(var srec): boolean;
- begin
- no_condition := true;
- end;
-
-
-
- {$F+}
- function std_condition(var srec): boolean;
- var sr: searchrec;
- begin
- sr := searchrec(srec);
- with std_condition_attrs do std_condition := (
- (show_r_o or not((sr.attr and readonly ) > 0)) and
- (show_hid or not((sr.attr and hidden ) > 0)) and
- (show_sys or not((sr.attr and sysfile ) > 0)) and
- (show_arc or not((sr.attr and archive ) > 0)) and
- (show_vol or not((sr.attr and volumeid ) > 0)) and
- (show_dir or not((sr.attr and directory) > 0)) and
- (show_non or (
- ((sr.attr and readonly) > 0) or
- ((sr.attr and hidden ) > 0) or
- ((sr.attr and archive ) > 0) or
- ((sr.attr and sysfile ) > 0)
- )
- )
- );
- end; { std_conditio }
-
-
-
- {$F+}
- function std_sort(var data1, data2): boolean;
- var
- st1, st2: string[3];
- in1, in2: integer;
- dt1, dt2: datetime;
- li1, li2: longint;
- sr1, sr2: searchrec;
-
- begin
- sr1 := searchrec(pointer(data1)^);
- sr2 := searchrec(pointer(data2)^);
- if (
- ((sr1.attr and volumeid) > 0) and
- not( (sr2.attr and volumeid) > 0 )
- ) then std_sort := true else if (
- ((sr1.attr and directory) > 0) and
- not( (sr2.attr and directory) > 0 )
- ) then std_sort := true else if (
- not( (sr1.attr and directory) > 0) and
- ((sr2.attr and directory) > 0 )
- ) then std_sort := false else if (
- ((sr1.attr and directory) > 0) and
- ((sr2.attr and directory) > 0)
- ) then std_sort := (sr1.name < sr2.name) else
- case std_condition_attrs.sort_method of
- on_name: std_sort := sr1.name < sr2.name;
- on_extension: if __comp(
- __extractext(sr1.name), __extractext(sr2.name)
- ) then std_sort := sr1.name < sr2.name else if (
- (__extractext(sr1.name) <> '') and (__extractext(sr2.name) <> '')
- ) then std_sort := (__extractext(sr1.name) < __extractext(sr2.name)) else
- if not __comp(__extractext(sr1.name), '') then std_sort := true else
- std_sort := false;
- on_datetime: begin { by date and time }
- unpacktime(sr1.time, dt1); unpacktime(sr2.time, dt2);
- li1 := __dt2jlutl(dt1.year, dt1.month, dt1.day);
- li2 := __dt2jlutl(dt2.year, dt2.month, dt2.day);
- if li1 <> li2 then std_sort := li1 < li2 else std_sort := (
- (dt1.hour*10000 + dt1.min*100 + dt1.sec) <
- (dt2.hour*10000 + dt2.min*100 + dt2.sec)
- );
- end;
- on_size: std_sort := sr1.size < sr2.size; { by size }
- end; { case }
- end; { std_sort }
- {$F-}
-
-
-
- procedure new_filarray(var fil: filarraytypeptr);
- var i : word;
- begin
- new(fil); for i := 1 to maxfiles do fil^[i] := nil;
- end;
-
-
- procedure dispose_filarray(var fil: filarraytypeptr);
- var i : word;
- begin
- for i := 1 to maxfiles do begin
- {writeln(__ptr2str(fil^[i]));}
- if fil^[i] <> nil then dispose(fil^[i]);
- end;
- dispose(fil);
- end;
-
-
- {$F+}
- procedure set_std_condition_attrs(attrs: condition_attrstype);
- begin
- std_condition_attrs := attrs;
- end;
-
-
- procedure __dirutl;
- const
- no_error = 0;
- invalid_path = 3;
- mem_error = 8;
- no_more_files = 18;
-
- var
- srec : searchrec;
- i : word;
- tt : longint;
-
- begin
- tt := 0;
- if condit = nil then conditionfuncptr_ := @no_condition else
- conditionfuncptr_ := condit;
- filitems := 0; vol_counted := false; error := 0;
-
- findfirst(searchpath, searchattr, srec);
- if (doserror = invalid_path) then begin
- error := invalid_path; exit
- end else if (doserror = no_more_files) then exit;
-
- tt := 0; counted_dirs := 0;
-
- while (doserror = 0) do begin
- if (
- (comexebatcmdfilter and __comexebatcmdfilter(srec.name)) or
- (not comexebatcmdfilter)
- ) then begin
- if callcondition(srec) then begin
- if not(
- ((srec.attr and volumeid) > 0) or
- ((srec.attr and directory) > 0)
- ) then begin
- if (
- manipulate = _to_lowcase_str
- ) then srec.name := __lo(srec.name) else if (
- manipulate = _to_upcase_str
- ) then srec.name := __up(srec.name);
- tt := tt + srec.size;
- end else srec.name := __up(srec.name);
- inc(filitems); if renew_space then new(filar^[filitems]);
- filar^[filitems]^ := srec;
- if ((srec.attr and volumeid) > 0) then vol_counted := true;
- if ((srec.attr and directory) > 0) then inc(counted_dirs);
- end; { test condition, if ok, get it }
- end;
- findnext(srec);
- end;
- totnum := tt;
-
- if sorter <> nil then __qsortsrt(
- filar, filitems, sizeof(pointer), sorter
- );
- end; { __dirutl }
-
-
-
-
-
-
- procedure addtogethertwotimerecords(
- timerecordone : timerecord;
- timerecordtwo : timerecord;
- var resultrecord : timerecord
- ); {this is an internal procedure.}
- begin {additionoftwotimes}
- resultrecord.hundredth := (timerecordone.hundredth+timerecordtwo.hundredth);
- resultrecord.second := (timerecordone.second +timerecordtwo.second);
- resultrecord.minute := (timerecordone.minute +timerecordtwo.minute);
- resultrecord.hour := (timerecordone.hour +timerecordtwo.hour);
- while (resultrecord.hundredth >= 100) do begin
- dec(resultrecord.hundredth,100); inc(resultrecord.second)
- end;
- while (resultrecord.second >= 60) do begin
- dec(resultrecord.second,60); inc(resultrecord.minute)
- end;
- while (resultrecord.minute >= 60) do begin
- dec(resultrecord.minute,60); inc(resultrecord.hour)
- end
- end;
-
-
-
- procedure addonedaytodate(var thedaterecord : daterecord);
- begin
- with thedaterecord do begin
- inc(date);
- case month of
- 1,3,5,7,8,10,12: if (date > 31) then begin dec(date,31); inc(month) end;
- 4, 6, 9, 11 : if (date > 30) then begin dec(date,30); inc(month) end;
- 2 : if (date > 29) then begin dec(date,29); month := 3 end else
- if (
- (date > 28) and not (((year mod 4) = 0) and
- (((year mod 100) <> 0) or ((year mod 400) = 0)))
- ) then begin dec(date,28); month := 3 end
- end; {case month}
- while (month > 12) do begin dec(month,12); inc(year) end;
- inc(dayofweek); dayofweek := (dayofweek mod 7)
- end {with thedaterec}
- end;
-
-
-
- function juliandate(thedate : daterecord) : longint;
- var templongint : longint;
- begin
- templongint := thedate.year;
- templongint := (templongint * 1000);
- case thedate.month of
- 02 : inc(templongint,31);
- 03 : inc(templongint,59);
- 04 : inc(templongint,90);
- 05 : inc(templongint,120);
- 06 : inc(templongint,151);
- 07 : inc(templongint,181);
- 08 : inc(templongint,212);
- 09 : inc(templongint,243);
- 10 : inc(templongint,273);
- 11 : inc(templongint,304);
- 12 : inc(templongint,334)
- end; {case daterecord.month}
- if (((thedate.year mod 4) = 0) and (thedate.month > 2)) then
- if (((thedate.year mod 100) <> 0) or ((thedate.year mod 400) = 0))
- then inc(templongint); {add a day for leapyears}
- templongint := (templongint + thedate.date);
- juliandate := templongint
- end;
-
-
-
- procedure subtractonedayfromdate(var thedaterecord : daterecord);
- begin
- with thedaterecord do begin
- if date = 1 then begin
- if month = 1 then begin dec(year); month := 12; date := 31 end else begin
- dec(month);
- case month of
- 1, 3, 5, 7, 8, 10, 12 : date := 31;
- 4, 6, 9, 11 : date := 30;
- 2 : if (((year mod 4) = 0) and
- (((year mod 100) <> 0) or ((year mod 400) = 0)))
- then date := 29 else date := 28
- end {case month}
- end
- end else dec(date);
- if (dayofweek = 0) then dayofweek := 6 else dec(dayofweek)
- end {with thedaterec}
- end;
-
-
-
-
- function converttimetostring(thetimerec : timerecord) : string;
- var
- tempstring1 : string;
- tempstring2 : string;
- index : byte;
-
- begin
- str(thetimerec.hour:2,{var} tempstring1);
- str(thetimerec.minute:2,{var} tempstring2);
- tempstring1 := (tempstring1 + colon + tempstring2);
- str(thetimerec.second:2,{var} tempstring2);
- tempstring1 := (tempstring1 + period + tempstring2);
- str(thetimerec.hundredth:2,{var} tempstring2);
- tempstring1 := (tempstring1 + separ + tempstring2);
- for index := 1 to length(tempstring1) do
- if (tempstring1[index] = space) then tempstring1[index] := zero;
- converttimetostring := tempstring1
- end;
-
-
-
-
- function datesareequal(
- daterecord1 : daterecord;
- daterecord2 : daterecord
- ) : boolean;
- begin
- if (
- (daterecord1.date = daterecord2.date) and
- (daterecord1.month = daterecord2.month) and
- (daterecord1.year = daterecord2.year)
- ) then datesareequal := true else datesareequal := false
- end;
-
-
-
-
- function juliantime(timerecord : timerecord) : longint;
- var
- templongint : longint;
- tempvariable : longint;
-
- begin
- templongint := timerecord.hour;
- templongint := (templongint * 1000000);
- tempvariable := timerecord.minute;
- templongint := (
- templongint + (tempvariable * 10000) + (timerecord.second * 100) +
- timerecord.hundredth
- );
- juliantime := templongint
- end;
-
-
-
-
- procedure determinelengthbetweentwodatetimes(
- startdaterecord : daterecord;
- starttimerecord : timerecord;
- enddaterecord : daterecord;
- endtimerecord : timerecord;
- var elapsedtimerecord : timerecord
- );
- var julianenddate : longint;
- begin
- with elapsedtimerecord do begin
- hour := 0; minute := 0; second := 0; hundredth := 0
- end;
- if (
- (juliandate(startdaterecord) > juliandate(enddaterecord)) or
- (datesareequal(startdaterecord,enddaterecord) and
- (juliantime(starttimerecord) > juliantime(endtimerecord)))
- ) then addonedaytodate({var} enddaterecord);
- while (endtimerecord.hundredth < starttimerecord.hundredth) do begin
- inc(endtimerecord.hundredth,100);
- if (endtimerecord.second = 0) then begin
- endtimerecord.second := 59;
- if (endtimerecord.minute = 0) then begin
- endtimerecord.minute := 59;
- if (endtimerecord.hour = 0) then begin
- endtimerecord.hour := 23;
- subtractonedayfromdate(enddaterecord)
- end else dec(endtimerecord.hour)
- end else dec(endtimerecord.minute)
- end else dec(endtimerecord.second)
- end;
- elapsedtimerecord.hundredth := (
- endtimerecord.hundredth - starttimerecord.hundredth
- );
- while (endtimerecord.second < starttimerecord.second) do begin
- inc(endtimerecord.second,60);
- if (endtimerecord.minute = 0) then begin
- endtimerecord.minute := 59;
- if (endtimerecord.hour = 0) then begin
- endtimerecord.hour := 23;
- subtractonedayfromdate(enddaterecord)
- end else dec(endtimerecord.hour)
- end else dec(endtimerecord.minute)
- end;
-
- elapsedtimerecord.second := (endtimerecord.second - starttimerecord.second);
- while (endtimerecord.minute < starttimerecord.minute) do begin
- inc(endtimerecord.minute,60);
- if (endtimerecord.hour = 0) then begin
- endtimerecord.hour := 23;
- subtractonedayfromdate(enddaterecord)
- end else dec(endtimerecord.hour)
- end;
- elapsedtimerecord.minute := (endtimerecord.minute - starttimerecord.minute);
- while (endtimerecord.hour < starttimerecord.hour) do begin
- inc(endtimerecord.hour,24);
- subtractonedayfromdate(enddaterecord)
- end; {while (endtimerecord.hour < starttimerecord.hour)}
- elapsedtimerecord.hour := (endtimerecord.hour - starttimerecord.hour);
- julianenddate := juliandate(enddaterecord);
- while (juliandate(startdaterecord) <> julianenddate) do begin
- inc(elapsedtimerecord.hour,24);
- addonedaytodate({var} startdaterecord)
- end
- end;
-
-
-
-
- procedure starttimer (whichclock : byte);
- begin {starttimer}
- if (whichclock = 0) then exit else {can't reset the program-timer clock!}
- with clockarray[whichclock] do begin
- with clockstartdate do getdate({var} year,month,date,dayofweek);
- with clockstarttime do gettime({var} hour,minute,second,hundredth);
- with elapsedtime do begin
- hour := 0; minute := 0; second := 0; hundredth := 0
- end;
- clockisrunning := true
- end
- end;
-
-
-
-
- function getlaptime (whichclock : byte) : string;
- var
- currentdate : daterecord;
- currenttime : timerecord;
- elapsedtime : timerecord;
- tempstring : string[3];
-
- begin
- with currentdate do getdate({var} year,month,date,dayofweek);
- with currenttime do gettime({var} hour,minute,second,hundredth);
- fillchar(elapsedtime,sizeof(elapsedtime),nullchar);
- str(whichclock,{var} tempstring);
-
- determinelengthbetweentwodatetimes(
- clockarray[whichclock].clockstartdate,
- clockarray[whichclock].clockstarttime,
- currentdate, currenttime,
- {var} elapsedtime
- );
- addtogethertwotimerecords(
- elapsedtime, clockarray[whichclock].elapsedtime, {var} elapsedtime
- );
- getlaptime := converttimetostring(elapsedtime)
- end;
-
-
-
-
- procedure restarttimer (whichclock : byte);
- begin
- with clockarray[whichclock] do begin
- with clockstartdate do getdate({var} year,month,date,dayofweek);
- with clockstarttime do gettime({var} hour,minute,second,hundredth);
- clockisrunning := true
- end
- end;
-
-
-
-
-
- function stoptimer (whichclock : byte) : string;
- const cantstopclockzerotext = 'Can''t stop clock #0!';
- var
- currentdate : daterecord;
- currenttime : timerecord;
- elapsedtime : timerecord;
- tempstring : string[3];
-
- begin
- if (
- (whichclock = 0) or (not clockarray[whichclock].clockisrunning)
- ) then stoptimer := (cantstopclockzerotext) else begin
- with currentdate do getdate({var} year,month,date,dayofweek);
- with currenttime do gettime({var} hour,minute,second,hundredth);
- fillchar(elapsedtime,sizeof(elapsedtime),nullchar);
- str(whichclock,{var} tempstring);
-
- determinelengthbetweentwodatetimes(
- clockarray[whichclock].clockstartdate,
- clockarray[whichclock].clockstarttime,
- currentdate, currenttime, {var} elapsedtime
- );
-
- addtogethertwotimerecords(
- elapsedtime, clockarray[whichclock].elapsedtime,
- {var} clockarray[whichclock].elapsedtime
- );
-
- clockarray[whichclock].clockisrunning := false;
- stoptimer := converttimetostring(elapsedtime)
- end
- end;
-
-
-
- procedure __setpurge(b: byte);
- begin
- purge := b - 1;
- end;
-
-
-
- procedure __filapp(fil, s : string);
- var
- i : byte;
- logfile : text;
-
- begin
- {$I-}
- assign(logfile, fil);
- if __existfil(fil) then append(logfile) else rewrite(logfile);
- writeln(logfile, s); close(logfile);
- {$I+}
- end; { __filapp }
-
-
-
- procedure __logapp(s: string);
- var
- i : byte;
- logfile : text;
-
- begin
- assign(logfile, logfilename);
- if __existfil(logfilename) then append(logfile) else begin
- rewrite(logfile);
- for i := 1 to 11 do writeln(logfile, logheader[i]);
- writeln(logfile);
- writeln(logfile, __curdate + ' LOGfile for ' + programname + ' created.');
- writeln(logfile); writeln(logfile);
- end;
- if s<>'' then writeln(logfile, __curdate + ' ' + s) else writeln(logfile);
- close(logfile);
- end; { __logapp }
-
-
-
- function __recent(s: string): boolean;
- var { 27 Jul 91 08:34.12 }
- c : char;
- y, m, d : word;
- st, st2 : string;
-
- begin
- st := 'JFMAMJJASOND'; d := __str(copy(s, 1, 2)); m := mo;
- c := s[4]; st2 := copy(s, 4, 3);
- case c of
- 'A': if st2='Apr' then m := 4 else m := 8;
- 'D', 'F', 'N', 'O', 'S': m := pos(c, st);
- 'J': if st2='Jan' then m := 1 else if st2='Jun' then m := 6 else m := 7;
- 'M': if st2='Mar' then m := 3 else m := 5;
- end;
- y := __str(copy(s, 8, 2));
- {
- use of yr mo & day, because in logpurge, they're set with datestr (today)
- global variables, within scope of implementation
- }
- __recent := abs(__daysutl(yr, mo, da, y, m, d)) <= purge
- end;
-
-
-
- procedure __logpurge;
- type buf = array[1..16386] of char;
- var
- tin, tou : text;
- bin, bou : buf;
- lin : string;
-
- begin
- lin := __datestr(yr, mo, da);
- assign(tin, logfilename); reset(tin); settextbuf(tin, bin);
- assign(tou, 'eco_log.$$$'); rewrite(tou); settextbuf(tou, bou);
- for i := 1 to 15 do begin readln(tin, lin); writeln(tou, lin) end;
-
- readln(tin, lin);
- while not(eof(tin)) and (
- (lin='') or not(lin[1] in ['0','1','2','3']) or not(__recent(lin))
- ) do begin inc(lines); readln(tin, lin) end;
- if not eof(tin) then writeln(tou, lin);
- while not(eof(tin)) do begin
- inc(lines); readln(tin, lin); writeln(tou, lin)
- end;
- close(tin); close(tou);
- __erasefil(logfilename, error); rename(tou, logfilename);
- end;
-
-
-
- procedure __loginit;
- begin
- logheader[01] := 'โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ';
- logheader[02] := 'โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ';
- logheader[03] := 'โ โ โ โ';
- logheader[04] := 'โ โ โ โ';
- logheader[05] := 'โ โ E C O P U R G E โ โ';
- logheader[06] := 'โ โ โ โ';
- logheader[07] := 'โ โ โ โ';
- logheader[08] := 'โ โ โ โ';
- logheader[09] := 'โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ';
- logheader[10] := 'โ All material is protected and licensed. Version 0.00 โ';
- logheader[11] := 'โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ';
- end;
-
-
-
-
- function __rep(n: byte; character: char): string;
- var tempstr: string;
- begin
- if n = 0 then tempstr := '' else begin
- if (n > 255) then n := 1; fillchar(tempstr,n+1,character);
- tempstr[0] := chr(n);
- end; __rep := tempstr;
- end;
-
-
- function __loc(x, y : byte; var fore, back : byte): char;
- var
- pos : _scnpos;
-
- begin
- pos := _scnloc^[((y-1) * _curcolumns) + x];
- back := pos._attr; back := back shr 4; fore := pos._attr;
- fore := fore shl 4; fore := fore shr 4;
- __loc := pos._ch;
- end;
-
-
- function at(f, b : byte): byte;
- begin
- at := (b shl 4) or f
- end;
-
- procedure __scn(col,row,attr:byte; st: str80); external;
- procedure __vid(col,row: byte; st: str80); external;
- procedure changeattr(col,row,attr:byte; number:word); external;
- procedure __speedscn(
- sourceptr,targetptr : pointer;
- count,option,attribute : word;
- wait : boolean
- ); external;
-
-
-
-
- function get_video_mode: byte;
- var regs : registers;
- begin
- with regs do begin
- ax := $0F00; intr($10, regs); get_video_mode := al;
- end;
- end;
-
-
- procedure __movescn(
- x1, y1, x2, y2: byte; bufferptr: pointer; toscreen: boolean
- );
- var
- bufptr : _scnimageptr absolute bufferptr;
- scnptr : _scnimageptr;
- pagelength : word absolute _biosseg:$004c;
- offset : word; { offset into video buffer }
- width : word; { width, in pairs, of each line }
- delta : word; { increment between data lines }
- lines : word; { number of lines to access }
- wait : boolean;
- i,j,k : word;
-
- begin {__movescn}
- if ((_curmode > 3) and (_curmode <> 7)) then exit; { not textmode }
- if (x1 < 1) then x1 := 1 else if (x1 > _curcolumns) then x1 := _curcolumns;
- if (y1 < 1) then y1 := 1 else if (y1 > _currows) then y1 := _currows;
- if (x2 < x1) then x2 := x1 else if (x2>_curcolumns) then x2 := _curcolumns;
- if (y2 < y1) then y2 := y1 else if (y2 > _currows) then y2 := _currows;
- offset := ((y1 - 1) * _curcolumns) + x1;
- width := x2 - x1 + 1; delta := _curcolumns - x2 + x1 - 1;
- lines := y2 - y1 + 1;
- if (_curdisplaypage <> 0) then scnptr := ptr(
- _vectoraddr(_scnloc)._seg,
- _vectoraddr(_scnloc)._ofs + (pagelength * _curdisplaypage)
- ) else scnptr := _scnloc;
- wait := false;
-
- j := offset; k := 1;
- for i := 1 to lines do begin
- if (toscreen) then __speedscn(
- @bufptr^[k], @scnptr^[j], width, 2, 0, wait
- ) else __speedscn(
- @scnptr^[j], @bufptr^[k], width, 3, 0, wait
- );
- inc(j,width + delta);
- inc(k,width);
- end
- end; { __movescn }
-
-
-
- procedure __boxscn(x1,y1,x2,y2,boxtype,fore,back : byte);
- const
- corners : array[1..4,0..3] of char = (
- (#218,#214,#213,#201), { top left corner }
- (#191,#184,#183,#187), { top right corner }
- (#192,#211,#212,#200), { bottom left }
- (#217,#189,#190,#188) { bottom right }
- );
-
- lines : array[1..2,0..1] of char = (
- (#196,#205), { horizontal }
- (#179,#186)
- ); { vertical }
-
-
- var
- boxcorner : array[1..4] of char;
- boxline : array[1..4] of char;
- boxchar : char;
- horchars : byte;
- verchars : byte;
- i : word;
- cursoron : boolean;
- x,y,xtop,xbot : byte;
-
- begin
- if (boxtype > 15) then begin
- boxchar := chr(boxtype);
- fillchar(boxcorner,4,boxchar);
- fillchar(boxline,4,boxchar)
- end else begin
- boxcorner[1] := corners[1,(boxtype and 3)];
- boxcorner[2] := corners[2,((boxtype shr 1) and 3)];
- boxcorner[3] := corners[3,
- ((boxtype and 1) or ( 2 * ((boxtype shr 3) and 1)))];
- boxcorner[4] := corners[4,((boxtype shr 2) and 3)];
- boxline[1] := lines[1,((boxtype shr 1) and 1)];
- boxline[2] := lines[1,((boxtype shr 3) and 1)];
- boxline[3] := lines[2,(boxtype and 1)];
- boxline[4] := lines[2,((boxtype shr 2) and 1)]
- end;
- horchars := x2 - x1 - 1; verchars := y2 - y1 - 1;
- __write(x1, y1, fore, back, boxcorner[1]);
- if (horchars > 0) then __write(x1 + 1, y1, fore, back, __rep(horchars, boxline[1]));
- __write(x2, y1, fore, back, boxcorner[2]);
- for i := 1 to verchars do begin
- __write(x1, y1 + i, fore, back, boxline[3]);
- __write(x2, y1 + i, fore, back, boxline[4])
- end;
- __write(x1, y2, fore, back, boxcorner[3]);
- if (horchars > 0) then __write(
- x1 + 1, y2, fore,back, __rep(horchars, boxline[2])
- );
- __write(x2, y2, fore, back, boxcorner[4]);
- end; { __boxscn }
-
-
-
-
- procedure __write(col, row, f, b: byte; st: str80);
- begin
- __scn(col, row, at(f, b), st);
- end;
-
-
- procedure __hwrite(x, y, f, b, h: byte; st: string);
- var
- c, i,n : byte;
- on : boolean;
-
- begin
- i := 1; n := 0; c := f; on := false;
- while i <= length(st) do begin
- if st[i] = '~' then begin
- inc(n); on := not on; if on then c := h else c := f
- end else __write(x+i-1-n, y, c, b, st[i]);
- inc(i)
- end;
- end;
-
-
-
- { error = 255: debugging mode; else no debuginfo display }
- function __barcheck(s: string; var error: byte): boolean;
- var
- bad : boolean;
- i, j, k,
- len : byte;
- onepart : string;
-
- begin
- j := 1; len := length(s); error := 1; i := 1;
- bad := (pos(' ', s) = 0) or (__cvtstr(s, _rem_white_str) = '');
- if error = 255 then writeln(s);
- if not bad then repeat
- while (s[j] = ' ') and (j < len) do inc(j); i := j;
- while (s[j] <> ' ') and (j < len) do inc(j);
- bad := false;
- onepart := __cvtstr(copy(s, i, j-i), _rem_white_str);
- if onepart <> '' then begin
- for k := 1 to 26 do begin { IS er een hoofdletter? }
- bad := bad or (pos(chr(k+64), onepart) > 0);
- end;
- bad := not bad;
- end;
- if error = 255 then writeln(i:2,' ', j:2, ' "', onepart, '"');
- until bad or (j >= len);
- error := i;
- __barcheck := not bad;
- end;
-
-
-
- function __barchoice(x,x1,y,f,b,h : byte; st: string; timeout: byte): byte;
- const
- quit: boolean = false;
-
- var
- key : word;
- off,i,j, find : byte;
- s : string;
-
- procedure hilite;
- var i : byte;
- begin
- __attrib(x+off, y, x+length(st)-1+off, y, f, b);
- for i := 1 to length(st) do
- if ((st[i]=upcase(st[i])) and (upcase(st[i]) in ['A'..'Z'])) then
- __attrib(x+i-1+off, y, x+i-1+off, y, h, b);
- i := 1;
- while st[i]<>s[find] do inc(i);
- if pos(' ', copy(st, 2, length(st)-2)) <> 0 then begin
- while st[i]<>' ' do dec(i);
- j := i-1; inc(i);
- while st[i]<>' ' do inc(i); dec(i);
- __attrib(j+x+off, y, i+x+off, y, b, f)
- end else __attrib(i+x-1+off, y, i+x-1+off, y, b, f);
- end;
-
- begin
- s := ''; find := 1; quit := false;
- off := ((x1-x) - length(st)) div 2;
- for i := 1 to length(st) do begin
- if (st[i]=upcase(st[i])) and (upcase(st[i]) in ['A'..'Z']) then
- s := s + st[i];
- if st[i] <> '_' then __write(x+i-1+off, y, f, b, st[i]);
- end;
- repeat
- hilite;
- key := __retdelaykey(timeout, _enter);
- if (key = _left) or (key = _padleft) then begin
- if find>1 then dec(find) else find := length(s)
- end else if (key = _right) or (key = _padright) then begin
- if find<length(s) then inc(find) else find := 1
- end else if (key = _enter) or (key = _padenter) then begin
- quit := true
- end else if (key = _esc) then begin
- quit := true; find := 0
- end else if key = _space then begin
- if find < length(s) then inc(find) else find := 1
- end else for i := 1 to length(s) do if s[i] = upcase(lastkey) then begin
- find := i; quit := true
- end;
- until quit;
- if find > 0 then hilite;
- __barchoice := find;
- end;
-
-
-
- procedure __setblwin(blinkon : boolean);
- var reg : registers;
- begin
- if ((_curdevice = _egaadapter) or (_curdevice = _vgaadapter)) then begin
- with reg do begin
- ah := $10;
- al := $03;
- bl := byte(blinkon);
- intr($10, reg)
- end
- end else begin
- port[$3b8] := 8; mem[0:$465] := port[$3b8];
- if blinkon then port[$3b8] := $28;
- end;
- end;
-
-
-
-
- procedure __resscn(sc: _scnimageptr);
- begin
- __movescn(1, 1, _curcolumns, _currows, sc, true)
- end;
-
-
-
- procedure __savscn(sc: _scnimageptr);
- begin
- __movescn(1, 1, _curcolumns, _currows, sc, false)
- end;
-
-
-
- procedure __copyscn(x1, y1, x2, y2, x, y: byte);
- var buffer: _scnimage;
- begin
- __movescn(x1, y1, x2, y2, @buffer, false);
- __movescn(x, y, x+x2-x1, y+y2-y1, @buffer, true);
- end;
-
-
-
- procedure __attrib(x1, y1, x2, y2, f, b: byte);
- var i: byte;
- begin
- for i := y1 to y2 do changeattr(x1, i, at(f, b), succ(x2-x1))
- end;
-
-
-
- procedure __bandwin(del: boolean; x1, y1, x2, y2, f, b, shadow, bt: byte);
- var
- br, ht,
- vt, mih,
- ff, bb,
- miv : byte;
-
- begin
- if del then begin
- miv := y1 + (y2-y1) div 2; mih := x1 + (x2-x1) div 2;
- if y2-y1>5 then vt := 2 else vt := 1;
- if x2-x1>20 then ht := 5 else ht := 3;
- __clrscn(mih - ht, miv - vt + 1, mih + ht, miv + vt, f, b, ' ');
- __boxscn(mih - ht, miv - vt + 1, mih + ht, miv + vt, 15, f, b);
- __delay(100);
- end;
- if bt=1 then br := 00 else br := 15;
- __loc(x1-1, y2+3, ff, bb);
- if shadow = sh_high then begin
- if bb = black then shadow := lightgray else shadow := white
- end;
- if shadow = sh_low then shadow := lightgray;
- if shadow = sh_default then begin
- if bb = black then shadow := darkgray else shadow := black
- end;
- if _currows = 25 then begin
- __attrib(x1-1, y2+3, x2+5, y2+3, lightgray, shadow);
- __attrib(x2+2, y1-1, x2+5, y2+2, lightgray, shadow);
- __clrscn(x1-3, y1-2, x2+3, y2+2, f, b, ' ');
- end else begin
- __attrib(x1-1, y2+3, x2+3, y2+3, lightgray, shadow);
- __attrib(x2+3, y1-1, x2+3, y2+2, lightgray, shadow);
- __clrscn(x1-2, y1-2, x2+2, y2+2, f, b, ' ');
- end;
- __boxscn(x1-1, y1-1, x2+1, y2+1, br, f, b);
- end;
-
-
- procedure __vert(x, y, f, b: byte; s: string);
- var i: byte;
- begin
- for i := 1 to length(s) do __write(x, y + i - 1, f, b, s[i]);
- end;
-
-
- procedure __betwscn(x1, x2, y, f, b: byte; st: string);
- var x : integer;
-
- begin
- if length(st) >= x2 - x1 + 1 then __write(x1, y, f, b, st) else begin
- x := x1 + (x2 - x1 + 1 - length(st)) div 2;
- __write(x, y, f, b, st);
- end;
- end;
-
-
- procedure __clrscn(x1, y1, x2, y2, f, b: byte; c: char);
- var
- y : integer;
-
- begin
- if x2 > 80 then x2 := 80;
- for y := y1 to y2 do __write(x1, y, f, b, __rep(x2-x1+1, c));
- end;
-
-
-
- procedure __cls;
- begin
- __clrscn(1, 1, _curcolumns, _currows, 7, 0, ' ');
- end;
-
-
-
-
- procedure __equipscn;
- const
- active = 1;
- alternate = 2;
-
- var
- savecursor : word;
- crtport : word;
- adisplay : byte;
- i : integer;
- regs : registers;
-
-
- begin
- _monoadapter := _unknown;
- _coloradapter := _unknown;
- _egaadapter := _unknown;
- _hercadapter := _unknown;
- _vgaadapter := _unknown;
- _mcgaadapter := _unknown;
- egamonitor_ := _nomonitor;
- analogmonitor_ := _nomonitor;
- egamemory_ := 0;
- with regs do begin
- ax := $1a00;
- bx := $0000;
- intr($10,regs);
- inline($fb);
- if (al = $1a) then begin
- _monoadapter := _absent;
- _coloradapter := _absent;
- _egaadapter := _absent;
- _hercadapter := _absent;
- _mcgaadapter := _absent;
- _vgaadapter := _absent;
- adisplay := bl;
- for i := active to alternate do begin
- case adisplay of
- $01 : _monoadapter := _mono;
- $02 : _coloradapter := _color;
- $04 : _egaadapter := _color;
- $05 : _egaadapter := _mono;
- $07,$08 : if (adisplay = bl) then
- _vgaadapter := active
- else
- _vgaadapter := alternate;
- $0b,$0c : _mcgaadapter := _color;
- end;
- case adisplay of
- $07,$0b : analogmonitor_ := _anmonomonitor;
- $08,$0c : analogmonitor_ := _ancolormonitor;
- end;
- adisplay := bh
- end;
- end else begin
- _mcgaadapter := _absent;
- _vgaadapter := _absent
- end;
- ax := $1200;
- bx := $ff10;
- cx := $00ff;
- intr($10,regs);
- inline($fb);
- if (_egaadapter = _unknown) then begin
- if ((cl < 12) and (bh <= 1) and (bl <= 3)) then begin
- if (bh = 1) then begin
- _monoadapter := _absent;
- _egaadapter := _mono;
- egamonitor_ := _monomonitor
- end else begin
- _coloradapter := _absent;
- _egaadapter := _color
- end
- end else _egaadapter := _absent
- end;
- if (_egaadapter <> _absent) then begin
- egamemory_ := 64 + (64 * bl);
- if (((cx and $0009) = 9) or ((cx and $0003) = 3)) then
- egamonitor_ := _enhancedmonitor else
- if (egamonitor_ <> _monomonitor) then egamonitor_ := _colormonitor
- end
- end;
-
- if (_monoadapter = _unknown) then begin
- crtport := $3b4;
- port[crtport] := $f;
- savecursor := port[crtport + 1];
- port[crtport + 1] := 90;
- if (port[crtport + 1] = 90) then _monoadapter := _mono else
- _monoadapter := _absent;
- port[crtport + 1] := savecursor
- end;
-
- if (_coloradapter = _unknown) then begin
- crtport := $3d4;
- port[crtport] := $f;
- savecursor := port[crtport + 1];
- port[crtport + 1] := 90;
- if (port[crtport + 1] = 90) then _coloradapter := _color else
- _coloradapter := _absent;
- port[crtport + 1] := savecursor
- end;
-
- if (_vgaadapter > _absent) then with regs do begin
- ax := $0f00;
- intr($10,regs);
- if (_vgaadapter = active) then
- if ((al = 7) or (al = 15)) then _vgaadapter := _mono else
- _vgaadapter := _color else if ((al = 7) or (al = 15)) then
- _vgaadapter := _color else _vgaadapter := _mono
- end;
- end;
-
-
-
-
- {$F+}
- function __retdvscn(
- var dvmode : byte;
- var dvcols : word;
- var dvrows : word;
- var dbactpage : byte;
- var dvdispage : byte
- ): byte;
- var
- reg : registers;
- charheight : word;
-
- begin
- with reg do begin
- fillchar(reg, sizeof(reg), $00);
- ax := $0F00;
- intr($10, reg);
- dvmode := al; dvcols := ah; dbactpage := bh
- end;
- if (dvmode = 7) then begin
- _curdevice := _mono;
- _scnloc := ptr($b000,$0000)
- end else if (dvmode < 13) then begin
- _curdevice := _color;
- _scnloc := ptr($b000,$8000)
- end else begin
- if (dvmode = 15) then _curdevice := _mono else _curdevice := _color;
- _scnloc := ptr($a000,$0000)
- end;
- with reg do begin
- es := _vectoraddr(_scnloc)._seg;
- di := _vectoraddr(_scnloc)._ofs;
- ah := $fe;
- intr($10,reg);
- inline($fb);
- _scnloc := ptr(es,di)
- end;
- if ((_curdevice = _hercadapter) or (_curdevice = _monoadapter)) then begin
- _curmonitor := _monomonitor;
- charheight := 14
- end else if (_curdevice = _coloradapter) then begin
- _curmonitor := _colormonitor;
- charheight := 8
- end else if (
- _curdevice = _egaadapter
- ) then _curmonitor := egamonitor_ else if (
- (_curdevice = _vgaadapter) or
- (_curdevice = _mcgaadapter)
- ) then _curmonitor := analogmonitor_ else _curmonitor := _nomonitor;
- if (
- (_egaadapter = _curdevice) or (_mcgaadapter = _curdevice) or
- (_vgaadapter = _curdevice)
- ) then with reg do begin
- ax := $1130;
- bx := 0;
- intr($10,reg);
- dvrows := dl + 1;
- charheight := cx
- end else dvrows := 25;
- case dvmode of
- 4..6,8..10,17..19: _maxdisplaypage := 0;
- 0,1: if (dvrows = 50) then _maxdisplaypage := 6 else _maxdisplaypage := 7;
- 2,3,7: begin
- if (_curdevice = _mono) then _maxdisplaypage := 0 else
- _maxdisplaypage := 3;
- if (_curdevice = _vgaadapter) then case dvrows of
- 25 : _maxdisplaypage := 7;
- 43,50 : _maxdisplaypage := 3
- end;
- if (_curdevice = _egaadapter) then begin
- if (egamemory_ > 64) then _maxdisplaypage := 7 else
- _maxdisplaypage := 3;
- if (dvrows = 43) then _maxdisplaypage := _maxdisplaypage div 2
- end
- end;
- 13: begin
- _maxdisplaypage := 7;
- if (_egaadapter = _curdevice) then if (egamemory_ = 64) then
- _maxdisplaypage := 1 else if (egamemory_ = 128) then
- _maxdisplaypage := 3;
- end;
- 14: begin
- _maxdisplaypage := 3;
- if (_egaadapter = _curdevice) then if (egamemory_ = 64) then
- _maxdisplaypage := 0 else if (egamemory_ = 128) then
- _maxdisplaypage := 1
- end;
- 15..16: begin
- _maxdisplaypage := 1;
- if (_egaadapter = _curdevice) then if (egamemory_ = 64) then
- _maxdisplaypage := 0;
- end;
- end;
-
- dvdispage := _curdisplaypage;
- _curmode := dvmode;
- _currows := dvrows;
- _curcolumns := dvcols;
- _curactivepage := dbactpage;
- maxscanline_ := charheight - 1;
- __retdvscn := _curdevice
- end;
- {$F-}
-
-
- procedure __stdio;
- begin
- assign(input, ''); reset(input);
- assign(output, ''); rewrite(output);
- end;
-
-
-
-
- procedure newbuffer(var t :textbuffer);
- begin
- t.first := nil;
- t.last := nil;
- end; {newbuffer}
-
-
- procedure deletebuffer(var t :textbuffer);
- var step,temp :textnodeptr;
- begin
- step := t.first;
- while (step <> nil) do begin
- freemem(step^.line,length(step^.line^)+1);
- temp := step;
- step := step^.next;
- dispose(temp);
- end; {while}
- newbuffer(t);
- end; {deletebuffer}
-
-
- function emptybuffer(var t :textbuffer) :boolean;
- begin
- emptybuffer := (t.first = nil);
- end; {emptybuffer}
-
-
- function firstline(var t :textbuffer) :textnodeptr;
- begin
- firstline := t.first;
- end; {firstline}
-
-
- function lastline(var t :textbuffer) :textnodeptr;
- begin
- lastline := t.last;
- end; {lastline}
-
-
- function nextline(var t :textbuffer; pos :textnodeptr) :textnodeptr;
- begin
- nextline := nil;
- if (pos = nil) then exit;
- nextline := pos^.next;
- end; {nextline}
-
-
- function prevline(var t :textbuffer; pos :textnodeptr) :textnodeptr;
- begin
- prevline := nil;
- if (pos = nil) then exit;
- prevline := pos^.prev;
- end; {prevline}
-
-
- function deleteline(var t :textbuffer; var pos :textnodeptr) :textnodeptr;
- begin
- deleteline := nextline(t,pos);
- if (pos=nil) or emptybuffer(t) then exit;
- if (pos^.prev <> nil) then pos^.prev^.next := pos^.next;
- if (pos^.next <> nil) then pos^.next^.prev := pos^.prev;
- if (pos = t.first) then t.first := pos^.next; {pos was first node}
- if (pos = t.last) then t.last := pos^.prev; {pos was last node}
- if (pos^.line <> nil) then freemem(pos^.line,length(pos^.line^)+1);
- {free existing line}
- dispose(pos); pos := nil;
- end;
-
-
- function newnode(line :string) :textnodeptr;
- var temp :textnodeptr;
- begin
- newnode := nil;
- new(temp);
- if (temp=nil) then exit;
- temp^.next := nil;
- temp^.prev := nil;
- getmem(temp^.line,length(line)+1);
- if (temp^.line = nil) then exit;
- temp^.line^ := line;
- newnode := temp;
- end; {newnode}
-
-
- procedure modifytextline(var t: textbuffer; pos: textnodeptr; line: string);
- begin
- if pos = nil then exit;
- if (pos^.line <> nil) then freemem(pos^.line, length(pos^.line^)+1);
- getmem(pos^.line,length(line)+1); { space for new line }
- if (pos^.line = nil) then exit;
- pos^.line^ := line;
- end; {modifytextline}
-
-
- function gettextline(var t: textbuffer; pos :textnodeptr) :string;
- begin
- gettextline := '';
- if pos=nil then exit;
- gettextline := pos^.line^;
- end; {gettextline}
-
-
- procedure addtoend(var t :textbuffer; line :string);
- var temp :textnodeptr;
- begin
- temp := newnode(line);
- if (temp=nil) then exit;
-
- if (t.first = nil) then begin
- t.first := temp;
- t.last := t.first;
- end else begin
- t.last^.next := temp;
- temp^.prev := t.last;
- t.last := temp;
- end; {else}
- end; {addtoend}
-
-
- procedure addinsert(var t :textbuffer; pos :textnodeptr; line :string);
- var temp :textnodeptr;
- begin
- if (emptybuffer(t) or (pos = nil)) then begin
- addtoend(t,line);
- end else begin
- temp := newnode(line);
- if (temp=nil) then exit;
-
- if (pos^.prev <> nil) then
- pos^.prev^.next := temp;
- temp^.next := pos;
- temp^.prev := pos^.prev;
- pos^.prev := temp;
-
- if (pos = t.first) then {new front}
- t.first := temp;
- end; {else}
- end; {addinsert}
-
-
- function bufferlength(var t :textbuffer) :word;
- var
- count :word;
- step :textnodeptr;
- begin
- count := 0;
- step := t.first;
- while (step <> nil) do begin
- step := step^.next;
- inc(count);
- end; {while}
-
- bufferlength := count;
- end; {bufferlength}
-
- {- Create a new, wrapped, buffer. Margin must be reasonable, i.e. not too
- close to 0 or 255 -}
-
-
- procedure wrapbuffer(var t: textbuffer; margin: byte);
- const seperators = [#32..#47,#58..#64,#91..#96,#123..#126];
- var
- w : textbuffer;
- tmpst,
- line : string;
- source : word; {can't be Byte, Length may be 255}
- step : textnodeptr;
- ch : char;
-
-
- procedure finishline;
- begin
- addtoend(w, line);
- line := '';
- end; {finishline}
-
-
- procedure addchar(ch: char);
- var
- overflow : string;
- p : byte;
-
- begin
- if (length(line) >= margin) then begin {break the line}
- overflow := '';
- {first remove excess spaces}
- if (line[length(line)]=' ') then
- while (length(line) > 1) and (line[length(line)-1]=' ') do
- dec(line[0]); {drop last space}
-
- if (length(line) >= margin) then begin
- p := length(line);
- while (p > 0) and not (line[p] in seperators) do
- dec(p); {look backwards for seperator}
-
- if (p=0) then p := margin; {no seperator, one huge word}
-
- overflow := copy(line,p+1,length(line)-p);
- line[0] := char(p);
- end; {if}
-
- finishline;
- line := overflow+ch;
- end else begin
- line := line+ch;
- end; {else}
- end; {addchar}
-
-
- procedure tab;
- var count: byte;
- begin
- for count := 1 to 8 - (pred(length(line)) mod 8) do addchar(' ');
- end; {tab}
-
-
- begin
- newbuffer(w);
- step := t.first; line := '';
- while (step <> nil) do begin
- source := 1;
- tmpst := step^.line^;
- while (source <= length(tmpst)) and (step <> nil) do begin
- ch := tmpst[source];
- case ch of
- ^m : begin
- line := line+^m^j;
- finishline;
- end;
- ^i : tab;
- ^j,#141 : {ignore lf and soft-cr};
- else addchar(ch);
- end; {case}
- inc(source);
- end; {while}
- step := step^.next;
- end; {while}
- if (line <> '') then finishline;
- deletebuffer(t);
- t := w;
- end; {wrapbuffer}
-
-
- {- Create a new, unwrapped, buffer. All the lines except the last one
- in the new buffer will be of length 255 -}
-
-
- procedure unwrapbuffer(var t,w :textbuffer);
- var
- line :string;
- source :word; {can't be Byte, Length may be 255}
- step :textnodeptr;
-
-
- procedure finishline;
- begin
- addtoend(w,line);
- line := '';
- end; {finishline}
-
-
- procedure addchar(ch :char);
- begin
- if (length(line) = 255) then finishline;
- line := line+ch;
- end; {addchar}
-
-
- begin
- newbuffer(w); step := t.first; line := '';
- while (step <> nil) do begin
- for source := 1 to length(step^.line^) do addchar(step^.line^[source]);
- step := step^.next;
- end; {while}
- if (line <> '') then finishline;
- end; {unwrapbuffer}
- { quickbbs message text, credits to p.j. muller }
-
-
-
-
- function __crc32(value: byte; crc: longint) : longint;
- const
- crc32_table : array[0..255] of longint = (
- $00000000, $77073096, $ee0e612c, $990951ba, $076dc419, $706af48f,
- $e963a535, $9e6495a3, $0edb8832, $79dcb8a4, $e0d5e91e, $97d2d988,
- $09b64c2b, $7eb17cbd, $e7b82d07, $90bf1d91, $1db71064, $6ab020f2,
- $f3b97148, $84be41de, $1adad47d, $6ddde4eb, $f4d4b551, $83d385c7,
- $136c9856, $646ba8c0, $fd62f97a, $8a65c9ec, $14015c4f, $63066cd9,
- $fa0f3d63, $8d080df5, $3b6e20c8, $4c69105e, $d56041e4, $a2677172,
- $3c03e4d1, $4b04d447, $d20d85fd, $a50ab56b, $35b5a8fa, $42b2986c,
- $dbbbc9d6, $acbcf940, $32d86ce3, $45df5c75, $dcd60dcf, $abd13d59,
- $26d930ac, $51de003a, $c8d75180, $bfd06116, $21b4f4b5, $56b3c423,
- $cfba9599, $b8bda50f, $2802b89e, $5f058808, $c60cd9b2, $b10be924,
- $2f6f7c87, $58684c11, $c1611dab, $b6662d3d, $76dc4190, $01db7106,
- $98d220bc, $efd5102a, $71b18589, $06b6b51f, $9fbfe4a5, $e8b8d433,
- $7807c9a2, $0f00f934, $9609a88e, $e10e9818, $7f6a0dbb, $086d3d2d,
- $91646c97, $e6635c01, $6b6b51f4, $1c6c6162, $856530d8, $f262004e,
- $6c0695ed, $1b01a57b, $8208f4c1, $f50fc457, $65b0d9c6, $12b7e950,
- $8bbeb8ea, $fcb9887c, $62dd1ddf, $15da2d49, $8cd37cf3, $fbd44c65,
- $4db26158, $3ab551ce, $a3bc0074, $d4bb30e2, $4adfa541, $3dd895d7,
- $a4d1c46d, $d3d6f4fb, $4369e96a, $346ed9fc, $ad678846, $da60b8d0,
- $44042d73, $33031de5, $aa0a4c5f, $dd0d7cc9, $5005713c, $270241aa,
- $be0b1010, $c90c2086, $5768b525, $206f85b3, $b966d409, $ce61e49f,
- $5edef90e, $29d9c998, $b0d09822, $c7d7a8b4, $59b33d17, $2eb40d81,
- $b7bd5c3b, $c0ba6cad, $edb88320, $9abfb3b6, $03b6e20c, $74b1d29a,
- $ead54739, $9dd277af, $04db2615, $73dc1683, $e3630b12, $94643b84,
- $0d6d6a3e, $7a6a5aa8, $e40ecf0b, $9309ff9d, $0a00ae27, $7d079eb1,
- $f00f9344, $8708a3d2, $1e01f268, $6906c2fe, $f762575d, $806567cb,
- $196c3671, $6e6b06e7, $fed41b76, $89d32be0, $10da7a5a, $67dd4acc,
- $f9b9df6f, $8ebeeff9, $17b7be43, $60b08ed5, $d6d6a3e8, $a1d1937e,
- $38d8c2c4, $4fdff252, $d1bb67f1, $a6bc5767, $3fb506dd, $48b2364b,
- $d80d2bda, $af0a1b4c, $36034af6, $41047a60, $df60efc3, $a867df55,
- $316e8eef, $4669be79, $cb61b38c, $bc66831a, $256fd2a0, $5268e236,
- $cc0c7795, $bb0b4703, $220216b9, $5505262f, $c5ba3bbe, $b2bd0b28,
- $2bb45a92, $5cb36a04, $c2d7ffa7, $b5d0cf31, $2cd99e8b, $5bdeae1d,
- $9b64c2b0, $ec63f226, $756aa39c, $026d930a, $9c0906a9, $eb0e363f,
- $72076785, $05005713, $95bf4a82, $e2b87a14, $7bb12bae, $0cb61b38,
- $92d28e9b, $e5d5be0d, $7cdcefb7, $0bdbdf21, $86d3d2d4, $f1d4e242,
- $68ddb3f8, $1fda836e, $81be16cd, $f6b9265b, $6fb077e1, $18b74777,
- $88085ae6, $ff0f6a70, $66063bca, $11010b5c, $8f659eff, $f862ae69,
- $616bffd3, $166ccf45, $a00ae278, $d70dd2ee, $4e048354, $3903b3c2,
- $a7672661, $d06016f7, $4969474d, $3e6e77db, $aed16a4a, $d9d65adc,
- $40df0b66, $37d83bf0, $a9bcae53, $debb9ec5, $47b2cf7f, $30b5ffe9,
- $bdbdf21c, $cabac28a, $53b39330, $24b4a3a6, $bad03605, $cdd70693,
- $54de5729, $23d967bf, $b3667a2e, $c4614ab8, $5d681b02, $2a6f2b94,
- $b40bbe37, $c30c8ea1, $5a05df1b, $2d02ef8d
- );
-
- begin
- if crc = 0 then crc := $ffffffff; { must be set high to start with }
- __crc32 := crc32_table[byte(crc xor longint(value))] xor
- ((crc shr 8) and $00ffffff);
- end;
-
-
-
- function __crc16(value : byte; crc : word): word;
- (* crctab calculated by mark g. mendel, network systems corporation *)
- const
- crc16_table : array[0..255] of word = (
- $0000, $1021, $2042, $3063, $4084, $50a5, $60c6, $70e7,
- $8108, $9129, $a14a, $b16b, $c18c, $d1ad, $e1ce, $f1ef,
- $1231, $0210, $3273, $2252, $52b5, $4294, $72f7, $62d6,
- $9339, $8318, $b37b, $a35a, $d3bd, $c39c, $f3ff, $e3de,
- $2462, $3443, $0420, $1401, $64e6, $74c7, $44a4, $5485,
- $a56a, $b54b, $8528, $9509, $e5ee, $f5cf, $c5ac, $d58d,
- $3653, $2672, $1611, $0630, $76d7, $66f6, $5695, $46b4,
- $b75b, $a77a, $9719, $8738, $f7df, $e7fe, $d79d, $c7bc,
- $48c4, $58e5, $6886, $78a7, $0840, $1861, $2802, $3823,
- $c9cc, $d9ed, $e98e, $f9af, $8948, $9969, $a90a, $b92b,
- $5af5, $4ad4, $7ab7, $6a96, $1a71, $0a50, $3a33, $2a12,
- $dbfd, $cbdc, $fbbf, $eb9e, $9b79, $8b58, $bb3b, $ab1a,
- $6ca6, $7c87, $4ce4, $5cc5, $2c22, $3c03, $0c60, $1c41,
- $edae, $fd8f, $cdec, $ddcd, $ad2a, $bd0b, $8d68, $9d49,
- $7e97, $6eb6, $5ed5, $4ef4, $3e13, $2e32, $1e51, $0e70,
- $ff9f, $efbe, $dfdd, $cffc, $bf1b, $af3a, $9f59, $8f78,
- $9188, $81a9, $b1ca, $a1eb, $d10c, $c12d, $f14e, $e16f,
- $1080, $00a1, $30c2, $20e3, $5004, $4025, $7046, $6067,
- $83b9, $9398, $a3fb, $b3da, $c33d, $d31c, $e37f, $f35e,
- $02b1, $1290, $22f3, $32d2, $4235, $5214, $6277, $7256,
- $b5ea, $a5cb, $95a8, $8589, $f56e, $e54f, $d52c, $c50d,
- $34e2, $24c3, $14a0, $0481, $7466, $6447, $5424, $4405,
- $a7db, $b7fa, $8799, $97b8, $e75f, $f77e, $c71d, $d73c,
- $26d3, $36f2, $0691, $16b0, $6657, $7676, $4615, $5634,
- $d94c, $c96d, $f90e, $e92f, $99c8, $89e9, $b98a, $a9ab,
- $5844, $4865, $7806, $6827, $18c0, $08e1, $3882, $28a3,
- $cb7d, $db5c, $eb3f, $fb1e, $8bf9, $9bd8, $abbb, $bb9a,
- $4a75, $5a54, $6a37, $7a16, $0af1, $1ad0, $2ab3, $3a92,
- $fd2e, $ed0f, $dd6c, $cd4d, $bdaa, $ad8b, $9de8, $8dc9,
- $7c26, $6c07, $5c64, $4c45, $3ca2, $2c83, $1ce0, $0cc1,
- $ef1f, $ff3e, $cf5d, $df7c, $af9b, $bfba, $8fd9, $9ff8,
- $6e17, $7e36, $4e55, $5e74, $2e93, $3eb2, $0ed1, $1ef0
- );
-
- begin
- __crc16 := crc16_table[((crc shr 8) and 255)] xor
- (crc shl 8) xor value;
- end;
-
-
-
-
-
-
-
-
-
-
-
-
-
- procedure setselerror__(error : word);
- begin
- _selerror := error;
- end;
-
-
-
-
- function itemads__(pickptr : _pickptr; itemno : word) : pointer;
- begin
- with pickptr^ do begin
- if (_pointers) then
- itemads__ := pointer(
- pointer(longint(_itemaddr) +
- (pred(itemno) * sizeof(pointer)))^
- ) else itemads__ := pointer(
- longint(_itemaddr) + (pred(itemno) * _itemsize)
- );
- end;
- end;
-
-
-
- procedure uptwnsel__(pickptr : _pickptr);
- var itemno : word;
- begin
- with pickptr^ do begin
- for itemno := _firstpage to _lastpage do __itemsel(
- pickptr, _fore, _back, itemno
- );
- end;
- end;
-
-
-
- procedure __itemsel(pickptr: _pickptr; fore, back: byte; itemno: word);
- const blank = #32;
- var
- x, y, z : word;
- dspstr : string;
-
- begin
- with pickptr^ do begin
- _curitemptr := itemads__(pickptr, itemno);
- fillchar(dspstr, sizeof(dspstr), blank);
- z := length(string(_curitemptr^));
- if (z > _itemlen) then z := _itemlen;
- move(string(_curitemptr^)[1], dspstr, z);
- z := (itemno - _firstpage);
- x := succ(((z mod _numcols) * (_itemlen + _spacing)) + _spacing);
- y := succ(z div _numcols);
- __write(_x1+x-1, _y1+y-1, fore, back,
- __juststr(string(_curitemptr^), ' ', _x2 - _x1 - 1, _center_str)
- );
- end;
- end;
-
-
-
-
- function __makesel(
- x1, y1,
- x2, y2,
- fore, back,
- barfore,
- barback : byte;
- keyproc : pointer;
- itemlen : word;
- numitems : word;
- itemsize : word;
- numcols : word;
- spacing : word;
- itemaddr : pointer;
- ispointers : boolean
- ) : _pickptr;
-
- var
- pickptr : _pickptr;
-
- begin
- _fore := fore; _back := back;
- _x1 := x1; _y1 := y1; _x2 := x2; _y2 := y2;
- getmem(pickptr, sizeof(_pick));
- with pickptr^ do begin
- fillchar(pickptr^, sizeof(_pick), 0);
- _barfore := barfore; _barback := barback;
- _keyproc := keyproc; _numitems := numitems;
- _itemlen := itemlen;
- if (ispointers) then _itemsize := sizeof(pointer) else
- _itemsize := itemsize + 1;
- _numcols := numcols; _spacing := spacing; _itemaddr := itemaddr;
- _pointers := ispointers; _curitemnum := 1;
- end;
- __makesel := pickptr;
- end;
-
-
-
- function __picksel(
- listpickptr : _pickptr;
- var retitem : string;
- var retkey : word
- ) : word;
- type strpointer = ^string;
- var
- pageitems : word;
- found : boolean;
- initkey : boolean;
- return : boolean;
- key : word;
-
-
- procedure redraw(up: boolean; start, stop : word);
- begin
- with listpickptr^ do begin
- if up then __copyscn(_x1, _y1+1, _x2, _y2, _x1, _y1) else
- __copyscn(_x1, _y1, _x2, _y2-1, _x1, _y1+1);
- while (start <= stop) do begin
- __itemsel(listpickptr, _fore, _back, start);
- inc(start)
- end;
- end;
- end;
-
-
- procedure movebar;
- var
- flag : boolean;
- hold : word;
-
- begin
- with listpickptr^ do begin
- __itemsel(listpickptr, _fore, _back, _curitemnum);
- case key of
- _up, _padup : if (_curitemnum > _numcols) then begin
- dec(_curitemnum, _numcols);
- if (_curitemnum < _firstpage) then begin
- dec(_firstpage, _numcols);
- _lastpage := pred(_firstpage + pageitems);
- redraw(false, _firstpage, pred(_firstpage + _numcols));
- end;
- end;
-
- _down, _paddown : if (_curitemnum < _numitems) then begin
- flag := false;
- if (_curitemnum + _numcols <= _numitems) then begin
- inc(_curitemnum, _numcols);
- flag := true;
- end;
- if (
- (
- (_lastpage < _numitems) and (_curitemnum > _lastpage)
- )
- or
- (
- ((_curitemnum + _numcols) > _numitems) and
- (_curitemnum < _numitems) and
- (_lastpage < _numitems) and
- (not flag)
- )
- ) then begin
- inc(_firstpage, _numcols); inc(_lastpage, _numcols);
- if (_lastpage > _numitems) then _lastpage := _numitems;
- redraw(true, succ(_lastpage - _numcols), _lastpage);
- end;
- end;
-
- _right, _padright : if (_curitemnum < _numitems) then begin
- inc(_curitemnum);
- if (_curitemnum > _lastpage) then begin
- inc(_firstpage, _numcols); inc(_lastpage, _numcols);
- if (_lastpage > _numitems) then _lastpage := _numitems;
- redraw(true, _curitemnum, _lastpage);
- end;
- end;
-
- _left, _padleft : if (_curitemnum > 1) then begin
- dec(_curitemnum);
- if (_curitemnum < _firstpage) then begin
- dec(_firstpage, _numcols);
- _lastpage := pred(_firstpage + pageitems);
- redraw(false, succ(_curitemnum - _numcols), _curitemnum);
- end;
- end;
-
- _home, _padhome : if (_curitemnum > 1) then begin
- _curitemnum := 1; _firstpage := 1; _lastpage := pageitems;
- if (_lastpage > _numitems) then _lastpage := _numitems;
- uptwnsel__(listpickptr);
- end;
-
- _end, _padend : if (_curitemnum <> _numitems) then begin
- _curitemnum := _numitems;
- if (_numitems > pageitems) then begin
- __copyscn(_x1, _y1+1, _x2, _y2, _x1, _y1);
- _lastpage := _curitemnum;
- _firstpage := {succ}(
- _curitemnum - (
- pageitems - (
- _numcols - (
- _curitemnum mod _numcols
- )
- )
- )
- );
- uptwnsel__(listpickptr);
- end;
- end;
-
- _pgup, _padpgup : if (_firstpage > 1) then begin
- hold := _curitemnum - _firstpage;
- if (_firstpage < pageitems) then _firstpage := 1 else
- dec(_firstpage, pageitems - _numcols);
- _lastpage := pred(_firstpage + pageitems);
- _curitemnum := _firstpage + hold;
- uptwnsel__(listpickptr);
- end;
-
- _pgdn, _padpgdn : if (_lastpage < _numitems) then begin
- hold := _curitemnum - _firstpage;
- __copyscn(_x1, _y1+1, _x2, _y2, _x1, _y1);
- inc(_lastpage, pageitems - _numcols);
- if (_lastpage > _numitems) then begin
- _lastpage := _numitems;
- _firstpage := succ(
- _lastpage - (
- pageitems - (
- _numcols - (
- _lastpage mod _numcols
- )
- )
- )
- );
- _curitemnum := _firstpage + hold;
- if (_curitemnum > _numitems) then _curitemnum := _numitems;
- end else begin
- inc(_firstpage, pageitems - _numcols);
- _curitemnum := _firstpage + hold;
- end;
- uptwnsel__(listpickptr);
- end;
- end; { case }
- __itemsel(listpickptr, _barfore, _barback, _curitemnum);
- end;
- end;
-
-
-
- begin
- __picksel := 0; retitem := '';
- with listpickptr^ do begin
- pageitems := (_numcols * (_y2 - _y1 + 1));
- if (pageitems > _numitems) then pageitems := _numitems;
- if (_firstpage = 0) then _firstpage := _curitemnum;
- if (_lastpage = 0) then _lastpage := pageitems;
- uptwnsel__(listpickptr);
- __itemsel(listpickptr, _barfore, _barback, _curitemnum);
- initkey := false; return := false;
- repeat
- key := __retkey;
- retitem := strpointer(_curitemptr)^; found := false; movebar;
- if (key=_enter) or (key=_padenter) or (key=_esc) then return := true;
- if (key = _esc) then begin retitem := ''; _curitemnum := 0 end;
- __picksel := _curitemnum;
- until (return);
- end;
- {
- if (_selerror = _noerror_sel) then begin
- with listpickptr^ do __itemsel(listpickptr, _fore, _back, _curitemnum);
- end;
- }
- end;
-
-
-
-
- function __zapsel(var pickptr : _pickptr) : boolean;
- begin
- __zapsel := false;
- freemem(pickptr, sizeof(_pick));
- pickptr := nil;
- __zapsel := true;
- end;
-
-
-
-
-
-
-
-
- function __editline(var st: string; control: _editctrl): boolean;
- const
- insmode : boolean = true;
- insstrs : array[boolean] of string[3] = ('Ovr', 'Ins');
-
- var
- typekey : char;
- strlen,
- edtlen : byte;
- _cur, key : word;
-
- begin
- _cur := 1;
- with control do begin
- strlen := __min(length(st), _vscncols);
- edtlen := _viewx2 - _viewx1 + 1;
- fillchar(st[strlen+1], abs(sizeof(st) - _vscncols+1), ' ');
- __write(
- _viewx1, _viewy1, _vscnfore, _vscnback,
- __rep(_viewx2 - _viewx1, ' ')
- );
- repeat
-
- if _cur <= edtlen then begin
- gotoxy(_viewx1 + _cur - 1, _viewy1);
- __write(
- _viewx1, _viewy1, _vscnfore, _vscnback, copy(st + ' ', 1, edtlen-1)
- )
- end else begin
- gotoxy(_viewx2, _viewy1);
- __write(
- _viewx1, _viewy1, _vscnfore, _vscnback,
- copy(st + ' ', (_cur - edtlen + 1), edtlen-1)
- );
- end;
-
- if _showflags then begin
- __write(_viewx1, _viewy1-1, _vscnfore, _vscnback, insstrs[insmode]);
- if _cur = 1 then __write(
- _viewx2-3, _viewy1-1, _vscnfore, _vscnback, 'Beg'
- ) else if _cur >= strlen then __write(
- _viewx2-3, _viewy1-1, _vscnfore, _vscnback, 'End'
- ) else __write(
- _viewx2-3, _viewy1-1, _vscnfore, _vscnback, ' '
- )
- end;
-
- key := __retkey; typekey := chr(lo(key));
- if not(
- (key = _esc) or (key = _padenter) or (key = _enter)
- ) then case key of
- _left, _padleft : if _cur > 1 then dec(_cur);
- _right, _padright : if (
- (_cur <= strlen) and (_cur < _vscncols)
- ) then inc(_cur);
- _home, _padhome: _cur := 1;
- _end, _padend: _cur := __min(strlen + 1, _vscncols);
- _del, _paddel : if _cur <= strlen then begin
- delete(st, _cur, 1); st[strlen] := ' '; dec(strlen);
- if (_cur > 1) and (_cur > strlen + 1) then dec(_cur);
- end;
- _ins, _padins : insmode := not insmode;
- _backspace : if _cur > 1 then begin
- if _cur > 1 then dec(_cur); delete(st, _cur, 1); dec(strlen);
- end;
- else if (
- (upcase(typekey) in [#32..#126]) and (_cur <= _vscncols)
- ) then begin
- if insmode then begin
- if strlen < _vscncols then begin
- if _cur <= strlen then insert(typekey, st, _cur) else begin
- st := st + typekey;
- end;
- inc(strlen);
- if _cur < _vscncols then inc(_cur);
- end;
- end else begin
- if _cur <= strlen then st[_cur] := typekey else
- if _cur <= _vscncols then begin
- st := st + typekey;
- inc(strlen);
- end;
- if _cur < _vscncols then inc(_cur)
- end;
- end;
- end;
- until (key = _esc) or (key = _padenter) or (key = _enter);
- end;
- __editline := (key <> _esc);
- end;
-
-
-
-
-
-
- procedure __totalmem;
- var reg : registers;
- begin
- with reg do begin
- intr($12, reg);
- dosmemory := ax;
- if true then begin
- ax := $8800;
- intr($15, reg);
- extmemory := ax
- end else extmemory := 0
- end
- end;
-
-
-
-
-
- procedure __availmem;
- const
- copyoff = $12;
- adsoff = $2c;
-
- var
- vdiskptr : pointer;
- copynotice : string[5];
- temp : longint;
- reg : registers;
- firstmemptr : pointer;
- deviceofs : word;
- deviceptr : pointer;
-
- begin
- with reg do begin
- ah := $48;
- bx := $ffff;
- intr($21, reg);
- dosmemory := bx shr 6;
- if (dosmemory > 0) then begin
- ah := $48;
- intr($21, reg);
- memptr := ptr(ax, 0);
- es := ax;
- ah := $49;
- intr($21, reg)
- end else memptr := nil;
- if false then begin
- extads._hibyte := 0;
- extads._loword := 0;
- extmemory := 0
- end else begin
- ah := $88;
- intr($15, reg);
- extmemory := ax;
- ah := $52;
- intr($21, reg);
- firstmemptr := ptr(memw[es:bx - 2] + 1, 0);
- if (_dosmajorver = 2) then deviceofs := $17 else
- if (
- (_dosminorver = 0) and (_dosmajorver = 3)
- ) then deviceofs := $28 else deviceofs := $22;
- deviceptr := pointer(meml[es:bx + deviceofs]);
- with extads do begin
- _hibyte := $10;
- _loword := 0
- end;
- temp := 0;
- while (__ptr2lsup(deviceptr) >= __ptr2lsup(firstmemptr)) do begin
- vdiskptr := ptr(_vectoraddr(deviceptr)._seg, $12);
- move(vdiskptr^, copynotice[1], 5);
- copynotice[0] := char(5);
- if (copynotice = 'VDISK') then begin
- vdiskptr := ptr(_vectoraddr(deviceptr)._seg, $2c);
- move(vdiskptr^, extads, 3);
- with extads do temp := (
- (
- (longint(_loword) + 1023) div 1024) +
- 64 * longint(_hibyte - $10
- )
- );
- end;
- deviceptr := pointer(deviceptr^)
- end;
- dec(extmemory, word(temp));
- if (extmemory = 0) then fillchar(extads, sizeof(_xads), 0)
- end
- end
- end;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- procedure __allocmem;
- var reg : registers;
- begin
- with reg do begin
- ah := $48;
- bx := blockreq;
- intr($21, reg);
- if ((flags and fcarry) <> 0) then begin
- errorcode := ax;
- if (ax = 8) then allocsize := bx else allocsize := 0;
- memptr := nil
- end else begin
- allocsize := blockreq;
- memptr := ptr(ax, 0);
- errorcode := 0
- end
- end
- end;
-
-
-
-
-
- procedure __freemem;
- var reg : registers;
- begin
- with reg do begin
- ah := $49;
- es := _vectoraddr(memptr)._seg;
- intr($21, reg);
- if ((flags and fcarry) <> 0) then errorcode := ax else errorcode := 0
- end
- end;
-
-
-
-
-
-
- procedure __altermem;
- var reg : registers;
- begin
- with reg do begin
- ah := $4a;
- bx := blockreq;
- es := _vectoraddr(memptr)._seg;
- intr($21, reg);
- if ((flags and fcarry) <> 0) then begin
- errorcode := ax;
- if (ax = 8) then altersize := bx else altersize := 0
- end else begin
- altersize := blockreq;
- errorcode := 0
- end
- end
- end;
-
-
-
-
-
- function __firstmem : pointer;
- var reg : registers;
- begin
- with reg do begin
- ah := $52;
- intr($21, reg);
- __firstmem := ptr(memw[es:bx - 2] + 1, 0)
- end
- end;
-
-
-
-
-
-
- function __ctrlmem;
- var blockptr : ^_memctrl;
- begin
- blockptr := ptr(_vectoraddr(memptr)._seg - 1, _vectoraddr(memptr)._ofs);
- with blockptr^ do if ((_header <> 'M') and (_header <> 'Z')) then begin
- __ctrlmem := nil;
- fillchar(memblock, sizeof(_memctrl), #0)
- end else begin
- move(blockptr^, memblock, sizeof(_memctrl));
- if (_header = 'Z') then __ctrlmem := nil else
- __ctrlmem := ptr(_vectoraddr(blockptr)._seg + _size + 2, 0)
- end
- end;
-
-
-
-
-
- procedure __hookmem;
- var
- vectortable : array[0..255] of pointer absolute 0:0;
- i : integer;
- found : boolean;
- nextptr : pointer;
- thisptr : pointer;
- progblock : _memctrl;
- beginaddr : longint;
- endaddr : longint;
- thisaddr : longint;
-
- begin
- thisptr := ptr(progseg, 0);
- nextptr := __ctrlmem(thisptr, progblock);
- with progblock do begin
- if (_header = #0) then begin
- hookvecno := -1;
- exit
- end;
- beginaddr := __ptr2lsup(thisptr);
- endaddr := beginaddr + (16 * longint(_size));
- end;
- i := hookvecno; found := false;
- if ((i < 0) or (i > 255)) then begin hookvecno := -1; exit end;
- while ((i <= 255) and (not found)) do begin
- thisaddr := __ptr2lsup(vectortable[i]);
- if (
- (beginaddr <= thisaddr) and (thisaddr <= endaddr)
- ) then found := true else begin
- inc(i);
- if (i = $30) then inc(i, 2)
- end
- end;
- if (found) then hookvecno := i else hookvecno := -1
- end;
-
-
-
-
-
- procedure __xtmovmem;
- type
- localdesctable = record
- seglimit : word;
- loword : word;
- hibyte : byte;
- dataaccess : byte;
- reserved : word
- end;
-
- globaldesctable = record
- dummy : localdesctable;
- local : localdesctable;
- source : localdesctable;
- target : localdesctable;
- bioscs : localdesctable;
- stack : localdesctable
- end;
-
- var
- gdt : globaldesctable;
- dosads : _xads;
- reg : registers;
- tempseg : word;
- tempofs : word;
- temp : longint;
-
- begin
- if false then begin errorcode := 4; exit end;
- fillchar(gdt, sizeof(gdt), #0);
- tempseg := _vectoraddr(memptr)._seg;
- tempofs := _vectoraddr(memptr)._ofs;
- temp := (16 * longint(tempseg)) + longint(tempofs);
- with dosads do begin
- _hibyte := byte((temp div 65536) and $ff);
- _loword := word((temp - (65536 * longint(_hibyte))) and $ffff)
- end;
-
- with gdt do begin
- if (toext) then begin
- source.hibyte := dosads._hibyte;
- source.loword := dosads._loword;
- target.hibyte := extads._hibyte;
- target.loword := extads._loword
- end else begin
- source.hibyte := extads._hibyte;
- source.loword := extads._loword;
- target.hibyte := dosads._hibyte;
- target.loword := dosads._loword
- end;
- source.seglimit := nowords shl 2;
- target.seglimit := nowords shl 2;
- source.dataaccess := $93;
- target.dataaccess := $93
- end;
- with reg do begin
- ax := $8700;
- cx := nowords;
- es := seg(gdt);
- si := ofs(gdt);
- intr($15, reg);
- if ((flags and fcarry) <> 0) then errorcode := ah else errorcode := 0
- end
- end;
-
-
-
-
-
-
-
-
- procedure errorexit;
- begin
- exitproc := prevexitproc_;
- erroraddr := calleraddr_;
- inline($fb)
- end;
-
-
-
-
-
-
-
- {$F+}
- function __fetchmem; external;
- {$F-}
-
-
-
-
-
-
- { sort management }
- const
- comparesrt_ : pointer = nil;
- iosrt_ : pointer = nil;
- recsizesrt_ : word = 0;
- maxrecsrt_ : word = 0;
- lastrecsrt_ : word = 0;
- curpossrt_ : longint = 0;
- sortdatasrt_ : boolean = false;
- inmemorysrt_ : boolean = false;
- variablesrt_ : boolean = false;
- insortsrt_ : boolean = false;
-
-
-
-
- function calllesssrt__(var data1, data2): boolean;
- inline($ff/$1e/comparesrt_);
-
-
- procedure calliosrt__;
- inline($ff/$1e/iosrt_);
-
- {$F+}
- function ritemsrt__(
- p: pointer; itemsize: word; itemnum: word
- ): pointer; external;
- {$L RITEMSRT}
-
-
-
- procedure __isortsrt;
- var
- i, j : word;
- insertptr : pointer;
-
- begin
- _numsortedsrt := 0;
- if (numrecords = 0) then exit;
- comparesrt_ := lessfunction;
- getmem(insertptr, recordsize);
- if (insertptr = nil) then exit;
- for i := 1 to (numrecords - 1) do begin
- j := i - 1;
- move(ritemsrt__(dataptr, recordsize, i)^, insertptr^, recordsize);
- while (
- (j < i) and
- calllesssrt__(insertptr^, ritemsrt__(dataptr, recordsize, j)^)
- ) do begin
- move(
- ritemsrt__(dataptr, recordsize, j)^,
- ritemsrt__(dataptr, recordsize, j + 1)^,
- recordsize
- );
- dec(j)
- end;
- move(insertptr^, ritemsrt__(dataptr, recordsize, j + 1)^, recordsize);
- end;
- _numsortedsrt := numrecords;
- freemem(insertptr, recordsize);
- end;
-
-
-
-
- procedure __qsortsrt;
- const stack_max = 16;
- type
- stacksize = 1..stack_max;
- partition = record
- lower : word;
- upper : word
- end;
-
- var
- parstack : array[stacksize] of partition;
- parstacktop : word;
- lindex, rindex : word;
- i, j : word;
- lparsize : word;
- rparsize : word;
- parsize : word;
- pivotdataptr : pointer;
- tempdataptr : pointer;
- tempptr1 : pointer;
- tempptr2 : pointer;
-
- begin
- if (numrecords <= _useinsertsrt) then begin
- __isortsrt(dataptr, numrecords, recordsize, lessfunction);
- exit
- end;
- comparesrt_ := lessfunction;
- _numsortedsrt := 0;
-
- getmem(pivotdataptr, recordsize);
- if (pivotdataptr = nil) then exit;
- getmem(tempdataptr, recordsize);
- if (tempdataptr = nil) then begin
- freemem(pivotdataptr, recordsize);
- exit
- end;
-
- parstacktop := 1;
- with parstack[1] do begin
- lower := 0;
- upper := numrecords - 1;
- end;
-
- repeat
- with parstack[parstacktop] do begin
- lindex := lower;
- rindex := upper
- end;
- dec(parstacktop);
-
- repeat
- i := lindex;
- j := rindex;
- move(
- ritemsrt__(dataptr, recordsize, (lindex + rindex) div 2)^,
- pivotdataptr^, recordsize
- );
-
- repeat
- while calllesssrt__(
- ritemsrt__(dataptr, recordsize, i)^,
- pivotdataptr^
- ) do inc(i);
- while calllesssrt__(
- pivotdataptr^,
- ritemsrt__(dataptr, recordsize, j)^
- ) do dec(j);
- if (i <= j) then begin
- tempptr1 := ritemsrt__(dataptr, recordsize, i);
- tempptr2 := ritemsrt__(dataptr, recordsize, j);
- move(tempptr2^, tempdataptr^, recordsize);
- move(tempptr1^, tempptr2^, recordsize);
- move(tempdataptr^, tempptr1^, recordsize);
- inc(i);
- dec(j)
- end
- until (i > j);
-
- rparsize := rindex - i;
- lparsize := j - lindex;
- if (rparsize = 0) then rindex := j else
- if (lparsize = 0) then lindex := i else
- if (rparsize > lparsize) then begin
- if (rparsize <= _useinsertsrt) then __isortsrt(
- ritemsrt__(dataptr, recordsize, i),
- rparsize + 1, recordsize, lessfunction
- ) else begin
- inc(parstacktop);
- with parstack[parstacktop] do begin
- lower := i;
- upper := rindex
- end
- end;
- rindex := j
- end else begin
- if (lparsize <= _useinsertsrt) then __isortsrt(
- ritemsrt__(dataptr, recordsize, lindex),
- lparsize + 1, recordsize, lessfunction
- ) else begin
- inc(parstacktop);
- with parstack[parstacktop] do begin
- lower := lindex;
- upper := j
- end
- end;
- lindex := i
- end;
- parsize := rindex - lindex
- until (parsize <= _useinsertsrt);
- if (parsize > 0) then __isortsrt(
- ritemsrt__(dataptr, recordsize, lindex),
- parsize + 1, recordsize, lessfunction
- )
- until (parstacktop = 0);
- _numsortedsrt := numrecords;
- freemem(pivotdataptr, recordsize);
- freemem(tempdataptr, recordsize)
- end;
-
-
-
-
-
-
- procedure __addsrt;
- var
- tempdataptr : pointer;
- recordsize : word;
-
- begin
- if ((dataptr = nil) or (not insortsrt_)) then begin
- errorcode := 2;
- exit
- end else errorcode := 0;
-
- if ((not variablesrt_) and (lastrecsrt_ > maxrecsrt_)) then begin
- errorcode := 1;
- exit
- end;
-
- if (not inmemorysrt_) then begin
- tempdataptr := _datasrt;
- __iptrsup(tempdataptr, curpossrt_);
- if (not variablesrt_) then recordsize := recsizesrt_ else begin
- recordsize := byte(dataptr^);
- inc(recordsize);
- if ((curpossrt_ + recordsize) > _datasizesrt) then begin
- errorcode := 1;
- exit
- end
- end;
- move(dataptr^, tempdataptr^, recsizesrt_);
- inc(curpossrt_, recordsize)
- end else tempdataptr := dataptr;
- if (not sortdatasrt_) then move(
- tempdataptr, ritemsrt__(_ptrsrt, sizeof(pointer), lastrecsrt_)^,
- sizeof(pointer)
- );
- inc(lastrecsrt_)
- end;
-
-
-
-
- procedure __retsrt;
- begin
- if (not insortsrt_) then begin
- errorcode := 2;
- exit
- end else errorcode := 0;
- if (lastrecsrt_ >= _numsortedsrt) then begin
- errorcode := 1;
- exit
- end;
-
- if (not sortdatasrt_) then dataptr := pointer(
- ritemsrt__(_ptrsrt, sizeof(pointer), lastrecsrt_)^
- ) else dataptr := ritemsrt__(_datasrt, recsizesrt_, lastrecsrt_);
- inc(lastrecsrt_)
- end;
-
-
-
-
- procedure __sortsrt;
- var
- tempptr : pointer;
- tempsrt : word;
-
- begin
- _numsortedsrt := 0;
- errorcode := 0;
- if ((_datasrt <> nil) and (_datasizesrt <> 0)) then
- freemem(_datasrt, _datasizesrt);
- if ((_ptrsrt <> nil) and (_ptrsizesrt <> 0)) then
- freemem(_ptrsrt, _ptrsizesrt);
- recsizesrt_ := recordsize;
- maxrecsrt_ := maxrecords - 1;
- lastrecsrt_ := 0;
- curpossrt_ := 0;
- variablesrt_ := ((sortcontrol and _variable_srt) <> 0);
- inmemorysrt_ := ((sortcontrol and _inmemory_srt) <> 0);
- sortdatasrt_ := (
- (
- ((sortcontrol and _sortdata_srt) <> 0) or
- (recordsize <= 4)
- ) and
- (not inmemorysrt_) and (not variablesrt_)
- );
-
- if (sortdatasrt_) then begin
- _ptrsrt := nil;
- _ptrsizesrt := 0
- end else begin
- _ptrsizesrt := sizeof(pointer) * longint(maxrecords);
- getmem(_ptrsrt, _ptrsizesrt);
- if (_ptrsrt = nil) then begin errorcode := 1; exit end
- end;
-
- if (inmemorysrt_) then begin
- _datasrt := nil;
- _datasizesrt := 0
- end else begin
- _datasizesrt := recordsize * longint(maxrecords);
- getmem(_datasrt, _datasizesrt);
- if (_datasrt = nil) then begin
- _datasizesrt := maxavail - (3 * recordsize);
- maxrecsrt_ := _datasizesrt div recordsize;
- getmem(_datasrt, _datasizesrt);
- if (_datasrt = nil) then begin errorcode := 1; exit end
- end
- end;
-
- insortsrt_ := true;
- if (inputproc <> nil) then begin
- iosrt_ := inputproc;
- calliosrt__
- end else begin
- errorcode := 2;
- insortsrt_ := false;
- exit
- end;
-
- if ((_datasrt <> nil) and (curpossrt_ < _datasizesrt)) then begin
- tempptr := _datasrt;
- tempsrt := curpossrt_ mod 8;
- if (tempsrt <> 0) then curpossrt_ := curpossrt_ + (8 - tempsrt);
- __iptrsup(tempptr, curpossrt_);
- freemem(tempptr, _datasizesrt - curpossrt_);
- _datasizesrt := curpossrt_
- end;
- if ((_ptrsrt <> nil) and (lastrecsrt_ < maxrecords)) then begin
- tempptr := _ptrsrt;
- _ptrsizesrt := longint(lastrecsrt_) * sizeof(pointer);
- tempsrt := _ptrsizesrt mod 8;
- if (tempsrt <> 0) then _ptrsizesrt := _ptrsizesrt + (8 - tempsrt);
- __iptrsup(tempptr, _ptrsizesrt);
- freemem(tempptr, (longint(maxrecords) * sizeof(pointer)) - _ptrsizesrt)
- end;
-
- if (sortdatasrt_) then __qsortsrt(
- _datasrt, lastrecsrt_, recsizesrt_, lessfunction
- ) else __qsortsrt(_ptrsrt, lastrecsrt_, sizeof(pointer), lessfunction);
-
- if (outputproc <> nil) then begin
- lastrecsrt_ := 0;
- iosrt_ := outputproc;
- calliosrt__
- end;
- insortsrt_ := false;
-
- if ((sortcontrol and _leavemem_srt) = 0) then begin
- if ((_datasrt <> nil) and (_datasizesrt <> 0)) then freemem(
- _datasrt, _datasizesrt
- );
- if ((_ptrsrt <> nil) and (_ptrsizesrt <> 0)) then freemem(
- _ptrsrt, _ptrsizesrt
- );
- _ptrsrt := nil;
- _ptrsizesrt := 0;
- _datasrt := nil;
- _datasizesrt := 0
- end
- end;
-
-
-
-
-
-
-
-
- {$F+}
- procedure eco_lib_init;
- begin
- conditionfuncptr_ := @std_condition;
- _envseg := memw[prefixseg:$2c];
- _envptr := ptr(_envseg,0);
- envmemptr_ := nil;
- envsize_ := 0;
- _hidemouse := 0; __equipscn;
- _currows := 25; _curcolumns := 80;
- rows := _currows; cols := _curcolumns;
- _curmode := get_video_mode;
- if _curmode = 7 then baseofscreen := $b000 else baseofscreen := $b800;
- _curdevice := __retdvscn(
- _curmode,_curcolumns,_currows,
- _curactivepage,_curdisplaypage
- );
- vseg := baseofscreen; vofs := 0;
- {zero-out the clockarray.}
- fillchar(clockarray, sizeof(clockarray), nullchar);
- {start the program timer, aka clockarray(0).}
- with clockarray[0] do begin
- with clockstartdate do getdate({var} year,month,date,dayofweek);
- with clockstarttime do gettime({var} hour,minute,second,hundredth);
- clockisrunning := true
- end;
-
- _curdisplaypage := 0; _curactivepage := 0;
- if not __isconfil(__handlfil(output)) then __stdio;
- new(scn1); __savscn(scn1);
- _dospath := getenv('PATH'); __progname;
- end;
- {$F-}
-
-
-
-
-
-
-
- {$IFNDEF USETURBODOS}
- {$L ECO_LIBD}
- {$L INTR}
- {$ENDIF}
-
-
- {$L ECO_LIBS}
-
- {$L FETCHMEM}
- {$L RDSECTOR}
-
-
-
- begin
- eco_lib_init;
- end.
-