Hi all!
Where i can find a scanf version for FPK?
Thanks in advance!
RRC²Soft
Mailing lists / fpc-pascal / 2001-08
scanf for pascal?
11 messages · 7 people · –
- UUnknown author 3
- HHakimov Rahmatjon 2
- MMichael Van Canneyt 2
- AArne Hanssen 1
- BBarry Kelly 1
- GGabor DEAK JAHN 1
- +1 more
Reply by email Subscribe to this list Your subscription
Read-only archive. Use j and k to move between messages.
Hi all
Does anybody know how to convert a real type from bpw to fpc and vice- versa:
i explain : bpw real have 6 byte long and fpc 8 !
I have to translate somes struct binary files from bpw to fpc!
Lionel Drevon
Adeli http://www.adeli.fr
618 Av. Gal de Gaulle Tel 04 78 66 11 85
69760 Limonest Fax 04 78 66 04 33
Thus spoke ():
Show quoted text 5 lines
I don't know how to do this in FPC, but using BP (or VP) you can read data files using REAL an write them using the DOUBLE data type.
Example:
----------------------------------------------------------
type
oldrec = record
:
data: real;
:
end;
newrec = record
:
data: double;
:
enc;
var
olddata: oldrec;
newdata: newrec;
begin
:
read( oldfile, olddata );
newdata.data := olddata.data; // convert real to double
write( newfil, newdata );
:
end.
----------------------------------------------------------Hi all Does anybody know how to convert a real type from bpw to fpc and vice- versa: i…
Show quoted text 5 lines
Look at the Contributed units, there is a unit available which does this.
Michael.
Date sent: Wed, 3 Oct 2001 00:02:49 +0200 (W. Europe Daylight Time) From: Michael Van Canneyt
To:
Subject: Re: [fpc-pascal]Real bpw and fpc
Send reply to:
TANKS a lot
i found one bug on it..
how put correction on it (the original sender is unknow!) ?
Show quoted text 18 lines
Lionel Drevon
Adeli http://www.adeli.fr
618 Av. Gal de Gaulle Tel 04 78 66 11 85
69760 Limonest Fax 04 78 66 04 33
Show quoted text 11 lines
Send it to me; I'll implement it in the RTL, I think we should have had that a long time ago.
Michael.
Salom! Can anybody send me full install package of free C or C++ for DOS/Win32? Thanks.…
Hakimov Rahmatjon wroteCan anybody send me full install package of free C or C++ for DOS/Win32?
For Win32:
http://sf.net/projects/mingw
http://www.borland.com/bcppbuilder/freecompiler
-- Barry
Date sent: Wed, 3 Oct 2001 00:02:49 +0200 (W. Europe Daylight Time) From: …
Salom!
Can anybody send me full install package of free C or C++ for DOS/Win32? Thanks.
Rahmatjon.
At 10/9/01 08:32 AM, you wrote:
Rahmatjon,
Can anybody send me full install package of free C or C++ for DOS/Win32?
For C only, but otherwise excellent, visit:
http://www.cs.virginia.edu/~lcc-win32
Regards,
Gabor DEAK JAHN
------------------------------------------------------------------- Gabor DEAK JAHN -- Budapest, Hungary.
WWW: www.tramontana.co.hu
E-mail:
Send it to me; I'll implement it in the RTL, I think we should have had that a long time…
Date sent: Mon, 8 Oct 2001 23:57:00 +0200 (W. Europe Daylight Time)
From: Michael Van Canneyt
To:
Subject: Re: [fpc-pascal]Real bpw and fpc
Send reply to:
the correction is only for convert the double into borland real when egal 0
i just try some convert but not trying all !
Show quoted text 25 lines
Lionel Drevon
Adeli http://www.adeli.fr
618 Av. Gal de Gaulle Tel 04 78 66 11 85
69760 Limonest Fax 04 78 66 04 33
unit borreal;{************************************************************************** Title : Quick and dirty borland-style reals
Author : Ren van der Zee
Compiler: Freepascal
Platform: developed on Win32
E-mail : r.van.der.zee!nospam-remove
Version : 0.3
Why? : because I want to read files with borland-style reals in them!
TODO :
- more functions
- make it more 'transparent' (how?)
- maybe build it IN the freepascal compiler
---------------CORRECTION------------------
in the setvalue
if (d=0) then
begin
e:=0;
f:=0;
sf:=0;
.....
USAGE:
<borlandreal>:=<double>;
<double>:=<borlandreal>;
double(<borlandreal>)
EXAMPLES:
var
r:borlandreal;
d:double;
begin
r:=-1.25e10;
writeln(double(r):1:11)
r:=d;
d:=r;
end;-------------------------------------------------------------------------- !! if you make usefull changes to the unit or implement a TODO above or if you fixed a bug, PLEASE send me a copy !!
**************************************************************************}
interface{7654321076543210765432107654321076543210765432107654321076543210 sxxxxxxxxxxxFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFfffffffffffff IEEE float64 sfffffffffffffffffffffffffffffffffffffffeeeeeeee borland real siiiiiiiiiiifffffffffffffffffffffffffffffffffffffff0000000000000 real>float64 where i=e-129+1023
sFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFjjjjjjjj float64>real where J=x-1023+129
}
type
borlandreal=packed object
e : byte;
f : longint;
sf : byte;
function value:double;
procedure setvalue(d:double);
end; {Because no virtual functions are used, the size is 6 bytes}
operator := (b:borlandreal) d:double;
operator := (d:double) b:borlandreal;
var res:borlandreal;
implementation
operator := (b:borlandreal) d:double;
begin
d:=b.value();
end;
operator := (d:double) b:borlandreal;
begin
b.setvalue(d);
end;
function borlandreal.value:double;
var
af:packed record
case integer of
1: (f2:word; f:longint; sxf:word);
2: (r:double);
end;
ie:word;
begin
if e=0 then
fillchar(af,sizeof(af),#0)
else begin
ie:=e-129+1023;
af.sxf:=((sf and 128) shl 8) or (ie shl 4) or ((sf and $7f) shr 3);
af.f:=((sf and $7) shl 29) or (f shr 3);
af.f2:=(f and $7) shl 13
end;
value:=af.r;
end;
procedure borlandreal.setvalue(d:double);
var
af:packed record
case integer of
1: (f2:word; f:longint; sxf:word);
2: (r:double);
end;
w:word;
ie:integer;
raf:^borlandreal;
begin
{TODO}
if (d=0) then
begin
e:=0;
f:=0;
sf:=0;
end else
begin
af.r:=d;
w:=(af.sxf shr 4) and $7ff;
ie:=w-1023+129;
if (ie>255) or (ie<0) then {overflow};
e:=ie;
f:=((af.f and $1FFFFFFF) shl 3) or (af.f2 shr 13);
sf:=((af.sxf and $8000) shr 8) or ((af.sxf and $f) shl 3) or (af.f shr 29);
end;
end;
end.For C only, but otherwise excellent, visit: http://www.cs.virginia.edu/~lcc-win32 …
For C only, but otherwise excellent, visit: http://www.cs.virginia.edu/~lcc-win32 �� Gabor DEAK JAHN
Salom!
I don't have on-line access to Internet, therefore I can't download. If it possible, please, send me in attach full package of C with examples and docs.
Thank you very much.
Rahmatjon.
