
================================================================================
From: sg0026@aixrs1.hrz.uni-essen.de (Frank Borally)
Subject: pcb and pascal real
Date: 6 May 1996 18:26:59 GMT
Distribution: world

MAVERICK (maverick@phcc.org) wrote:
: -> most pcboard data files use a 'single real' which is 4 bytes. Now the
: -> problem is that this real-type hasn't got the same 'bit-layout' as the
: -> pascal real-type. Does any one know how to convert from pcb to pascal and
: -> back ?

I had pretty problems to get the uploaded/downloaded bytes from pcboard
USERS file into my programs. so i coded two functions:

function atopcb(input:string;np:boolean):double;
type doub=array[0..7] of byte;
var
   pasreal : real;
   R       : array [0..5] of byte absolute pasReal;
   i       : integer;
   b       : doub;
   t       : double;
begin
     for i:=0 to 7 do b[i]:=ord(input[i+1]);
     PasReal := 0;
     t:=0;
     move(B[2],R[1],5);
     R[0] := B[7];
     t:=PasReal;
     if ((t<0) and (np=false)) then t:=4294967295.0+t+1;
     atopcb:=t;
end;

function pcbtoa(input:double):string;
type doub=array[0..7] of byte;
var
   pasreal : real;
   R       : array [0..5] of byte absolute pasReal;
   i       : integer;
   b       : doub;
   t       : double;
   s       : string;
begin
     s:='';
     fillchar(B[0],8,0);
     pasreal:=input;
     B[7]:=R[0];
     move(R[1],B[2],5);
     for i:=0 to 7 do s[i+1]:=chr(b[i]);
     s[0]:=chr(8);
     pcbtoa:=s;
end;

The basic idea is from s.smith, but his routine was only able to handle
-2gb to 2gb.. since pcboards total bytes records are non signed, they
went from 0 to 4,29gb...

i don't comment the sources, if you know pascal and pcb you should
understand them.. if not, email me!

cya
Frank Q. of Q-TIP PCBoard Productions


