Article View: comp.lang.modula2
Article #2948Re: Arrays of Records and Sequential File Reading
From: robert leroux
Date: Thu, 26 Oct 1995 08:29
Date: Thu, 26 Oct 1995 08:29
62 lines
2727 bytes
2727 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]
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?
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)).
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
Technical Details
Message-ID:
<46ngu2$r72@grid.Direct.CA>Path:
arc1-ca.pugleaf.net!newsfeed.direct.ca!usenetReferences:
<46iq1p$4id@grid.Direct.CA> <DGysxx.98u@cix.compulink.co.uk>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!newsfeed.direct.ca!usenet From: rleroux@direct.ca (robert leroux) Newsgroups: comp.lang.modula2 Subject: Re: Arrays of Records and Sequential File Reading Date: 26 Oct 1995 08:29:54 GMT Organization: Internet Direct Inc. Message-ID: <46ngu2$r72@grid.Direct.CA> References: <46iq1p$4id@grid.Direct.CA> <DGysxx.98u@cix.compulink.co.uk> NNTP-Posting-Host: 204.174.243.21 X-Newsreader: WinVN 0.92.6+