Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!usc!samsung!uunet!jarthur!ucivax!milne From: milne@ics.uci.edu (Alastair Milne) Newsgroups: comp.lang.pascal Subject: Re: more fun things to do with files Message-ID: <26CDE72C.6371@ics.uci.edu> Date: 19 Aug 90 01:11:08 GMT References: <6789.26caaab3@jetson.uh.edu> Organization: UC Irvine Department of ICS Lines: 45 In <6789.26caaab3@jetson.uh.edu> chem4m@jetson.uh.edu writes: >If i have TWO datastructures w/ NO pointers, and I know that i am only going >to save one of each and accordingly will read only one of each, How would >I save these both into ONE file. >To save them into two files would be an easy matter... >TP has a type file; which is an untyped file, but the reset/rewrite command >asks for the byte size of the data structure and as I can call reset/rewrite >only once (since it resets to the beginning of the data file) the untyped file; >format defeats it's own purpose for me. >Any help in this matter would be greatly appreciated >Avijit Ghosh chem4m.jetson.uh.edu >by the way > reset(f,1) { set the byte size to one } > blockread(f,c,sizeof(c),recordread); >doesn't work either.. First, don't bother with BLOCKREAD. It's for untyped files, and you want typed files. Also, with typed files, RESET doesn't need the record size. TYPE FlRec = record case IsType1Entry:boolean of true:( entry1: MyFirstDataType); false:( entry2: MySecondDataType); end; VAR DataFile: FILE OF FlRec; ... RESET( DataFile); ... READ( DataFile, NextRec); IF NextRec.IsType1Entry THEN UseType1Structure( NextRec.Entry1) else... Not without its drawbacks, since every record in the file will be large enough to take the larger of these two, but it should take care of most of the work for you. I don't know how it's going to affect DOS' disc I/O time. I understand that a record size which is not a power of two (or perhaps it's "multiple of 128"?) makes disc I/O rather slower. Hope this helps. Alastair Milne