🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.modula2
Article #2951

Re: Arrays of Records and Sequential File Reading

#2951
From: "Mark Morgan Lloyd "
Date: Thu, 26 Oct 1995 16:48
95 lines
3399 bytes
> In article <DGysxx.98u@cix.compulink.co.uk>, 
> mark_tbu@cix.compulink.co.uk ("Mark Morgan Lloyd ") says:
> >
> >Post the appropriate part of your code here and let's see what we can 
> do. >It'll make a change from all this cross-posted wibble about Ada vs 
> C++ >(or ADA vs Fortran, as one participant would have it).
> >
> >Mark Morgan Lloyd
> >mark_tbu@cix.compulink.co.uk
> >
> >[Opinions above are the author's, not those of his employers or 
> >colleagues]
> 

YHM

> 
> Thanks for responding.
> 
> I darn near have the program working.  I just have to read in a string 
> from the keyboard and compare it to the revelant record.  I am doing 
> this as per following program snippet:
> 
> IF IsMatch = Str.Match (title,singlebook[x].TITL THEN
>   (*print the whole RECORD of singlebook[x].????*)
>  ELSE
>   (*Display to user that no match was found.  Then loop back to start 
> of program to allow another search*)
> 
> I am using 'x.' so that the whole ARRAY will be searched along with the 
> field.
> IsMatch is declared as a BOOLEAN.
> 
> Am I on the right track?
> 

Not quite sure here what you mean by "I am using 'x.'" etc. Also, is that 
boolean expression quite right, or do you mean IF Str.Match() ?

> As for the actual record:
> 
> BOOK = RECORD
>         TITL : Title;         (*TITL, AUTH, COPI AND DATE are an ARRAY 
of CHAR*)
>         AUTH : Author;
>         COPI : String;
>         DATE : Due;           (*Eventually this will be arrayed so that 
I can have up 
> to      END;                    four Dates per book*)
> 
> Library = ARRAY [1..maxbook] OF BOOK;  (*according to all the 
> references I read, this line should take the four fields in record BOOK 
> and address them per ARRAY until it reaches the maximum or before (if 
> the data file is shorter than maxbook)).
> 

What functions are you using to write and read the file? In general, they 
won't know about your data representation, so it's down to you to check 
for EOF etc.

> I found out that this is not the case, since my data file is set up 
> like:
> TITL
> AUTH
> COPI
> DATE
>     :
>     :
> DATE
>  
> maxbook relates to the number of lines in the data file.  
> 
>       After some work the other day, I successfully called random 
fields, 
> within the program, from the array and displayed them.  I did this by 
> changing the 'x' to 1, 2, 3 . . . for whatever book II wanted along 
> with the field.  This is what I initially had problems with.  Now when 
> I do a search from the keyboard to find the title of a book for 
> instance, I can pull up anything I want, which should not be.
>       Is it something to do with the variable 'x' as noted above with 
the 
> Match.  Or should I approach this from a different angle.
> 
> Thanks.
> 
> rleroux@direct.ca
> 

Hope that's been of some help

Mark Morgan Lloyd
mark_tbu@cix.compulink.co.uk

[Opinions above are the author's, not those of his employers or 
colleagues]
Technical Details
Message-ID: <DH2EpC.MIo@cix.compulink.co.uk>
Path: arc1-ca.pugleaf.net!cix.compulink.co.uk!usenet
References: <46ngu2$r72@grid.Direct.CA>

Show Full Headers
Complete Article Headers
Newsgroups: comp.lang.modula2
Path: arc1-ca.pugleaf.net!cix.compulink.co.uk!usenet
From: mark_tbu@cix.compulink.co.uk ("Mark Morgan Lloyd ")
Subject: Re: Arrays of Records and Sequential File Reading
Message-ID: <DH2EpC.MIo@cix.compulink.co.uk>
Organization: KDG Mobrey Telemetry
References: <46ngu2$r72@grid.Direct.CA>
Date: Thu, 26 Oct 1995 16:48:48 GMT
X-News-Software: Ameol