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

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;
 
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. :
 
I don't know if you got my previous message, but converting this to a
random file & field statement is a piece of cake.  The only trick is the
real; hopefully CVS can convert it properly.  A field statement for the
above would be:
 
open "pascal.dat" as #1 len=68
field #1,1 as name_len$, 30 as name_emp$, 1 as addr_len$,_
30 as address$, 4 as salary$, 1 as married$, 1 as num_children$
 
get #1,1
 
print left$(name_emp$,asc(name_len$))
print left$(address$,asc(addr_len$))
print cvs(salary$)
if asc(married$)=1 then print "married" else print "single"  
print asc(num_children$)
 
how to do using PB's type structure, I have no idea...maybe just port
the field statement over directly into type variables.  one of these
daze i'll mess with PB's types, just haven't done much reading of
pascal data files lately (well, I do it all the time using old programs
that used field statements, written long before PB had type structures;
we're talking TB daze here).        eric
--- QM v1.00
---------------
* Origin: Creekside Manor (805) 484-8016 CdCom Support BBS (1:206/2512.0)

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™.