TIP: Click on subject to list as thread! ANSI
echo: power_bas
to: ERIC SCHONNING
from: LAWRENCE GORDON
date: 1996-07-01 18:34:00
subject: Re: Reading Pascal Files

Quoting Eric Schonning to Lawrence Gordon:
ES> LG> type
LG>  employee = record
LG>  name : string[30];
LG>  address : string[30];
LG>  salary : real;
LG>  married : boolean;
LG>  num_children : byte;
LG> end;
ES>
LG> Your mission, should you choose to accept it, is to help me convert
LG> this data structure to a PB record-type and give me a clue to reading
LG> the file, with particular attention given the string-length offsets. :
ES>
ES> I don't know if you got my previous message, but converting this to a
ES> random file & field statement is a piece of cake.  The only trick is the
ES> real; hopefully CVS can convert it properly.  A field statement for the
ES> above would be:
ES>
ES> open "pascal.dat" as #1 len=68
ES> field #1,1 as name_len$, 30 as name_emp$, 1 as addr_len$,_
ES> 30 as address$, 4 as salary$, 1 as married$, 1 as num_children$
ES>
ES> get #1,1
ES>
ES> print left$(name_emp$,asc(name_len$))
ES> print left$(address$,asc(addr_len$))
ES> print cvs(salary$)
ES> if asc(married$)=1 then print "married" else print "single"
ES> print asc(num_children$)
Thanks for the algorithm, Eric. It works great. The only problem I have, as I 
told Bob Dunnell, is that TP stores real numbers in 6 bytes, whereas PB 
stores them in 4 (or 8 if you're using double precision real numbers).
Have any clues for converting a Pascal 6 byte real to a PB 4 (or 8) byte 
al?
 * WCE 2.1G1/2081 * 
--- InterEcho 1.18
---------------
* Origin: Toast House * (314) 994-0312 * (1:100/560)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.