home *** CD-ROM | disk | FTP | other *** search
- {
- ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
- ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
- ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
- ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
- ▓▓▓▓▓▓▓▓·── ──·▓▓▓▓▓▓▓▓▓▓▓
- ▓▓▓▓▓▓▓▓│ │░░▓▓▓▓▓▓▓▓▓
- ▓▓▓▓▓▓▓▓ Unit was conceived, designed and written ░░▓▓▓▓▓▓▓▓▓
- ▓▓▓▓▓▓▓▓ by Floor A.C. Naaijkens for ░░▓▓▓▓▓▓▓▓▓
- ▓▓▓▓▓▓▓▓ UltiHouse Software / The ECO Group. ░░▓▓▓▓▓▓▓▓▓
- ▓▓▓▓▓▓▓▓ ░░▓▓▓▓▓▓▓▓▓
- ▓▓▓▓▓▓▓▓ (C) MCMXCII by EUROCON PANATIONAL CORPORATION. ░░▓▓▓▓▓▓▓▓▓
- ▓▓▓▓▓▓▓▓ All Rights Reserved for The ECO Group. ░░▓▓▓▓▓▓▓▓▓
- ▓▓▓▓▓▓▓▓ ░░▓▓▓▓▓▓▓▓▓
- ▓▓▓▓▓▓▓▓│ │░░▓▓▓▓▓▓▓▓▓
- ▓▓▓▓▓▓▓▓·── ──·░░▓▓▓▓▓▓▓▓▓
- ▓▓▓▓▓▓▓▓▓▓░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▓▓▓▓▓▓▓▓▓
- ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
- ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
- ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
- }
- {base convert unit for turbo-pascal 5.5}
- {copyright (c) 1989 christoph h. hochstätter}
-
-
- {$A+,B-,D+,F-,I-,L+,R-,S-,V-}
- unit eco_bcnv;
-
- interface
-
- type basestr = string[32];
-
- var baseerror: byte;
-
- function base(x:longint;b:byte):basestr; {convert x to base b}
- function basef(x:longint;b,f:byte):basestr; {convert x to base b length f}
- function hex(x:longint):basestr; {convert x to base 16}
- function hexf(x:longint;f:byte):basestr; {convert x to base 16 length f}
- function dez(x:basestr;s:byte):longint; {convert x from base s to decimal}
- function dezh(x:basestr):longint; {convert hexadecimal x to decimal}
-
- implementation
-
- var o: basestr;
- const h: string[36] = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
- var i: byte;
- const n: string[31] = '0000000000000000000000000000000';
-
- function base;
-
- procedure base1(x: longint);
- begin
- if x>pred(b) then base1(x div b);
- o:=o+h[succ(x mod b)];
- end;
-
- begin {base}
- if b>36 then begin
- baseerror:=1;
- exit;
- end else
- baseerror:=0;
- if x<0 then
- o:='-'
- else
- o[0]:=chr(0);
- base1(abs(x));
- base:=o;
- end;
-
- function hex;
- begin
- hex:=base(x,16);
- end;
-
-
- function basef;
- begin
- o:=base(x,b);
- if baseerror <> 0 then exit;
- if ord(o[0])>f then
- baseerror:=2
- else begin
- n[0]:=chr(f-ord(o[0]));
- if x<0 then i:=2 else i:=1;
- insert(n,o,i);
- end;
- basef:=o;
- end;
-
- function hexf;
- begin
- hexf:=basef(x,16,f);
- end;
-
- function dez;
- var a: byte;
- b,c: longint;
- begin
- baseerror:=0;
- c:=1;
- b:=0;
- for i:=length(x) downto 1 do
- if baseerror=0 then begin
- a:=pred(pos(upcase(x[i]),h));
- if (a=255) or (a>=s) then baseerror:=1;
- b:=b+c*a;
- c:=s*c;
- end;
- dez:=b;
- end;
-
- function dezh;
- begin
- dezh:=dez(x,16);
- end;
-
- end.
-