Random access files - having and finding multiple types of record in one file 
Author Message
 Random access files - having and finding multiple types of record in one file

My boss wants a GUI to send a series of messages to a list of people on
the network.  He also wants to have more that one list at a time having
messages sent to them.  For memory conservation, I'd like to be able use
random file access on each list that's being used.  The way that the
list files are designed so far (though it may change if I have to) is a
listing of all names followed by a listing of all messages to be sent
with the time that the messages are to be displayed.

What I need to know is HOW to read multiple record types in a file that
has more than 1 record type (below is an example of what the file looks
like).  For example, once message 1 has been displayed for it's given
period of time, then message 2 would be displayed.  I want to go
straight to message 2 without having to re-read the entire file.  I hope
this makes some sense.  I've read the VB Books Online (Online Manual)
and the FAQs, but all I've found so far is that there must be 1 record
type in the file :(

Hope someone can help me... (and this program is NOT for spam)

(example list file)
[NAMES]
name 1
name 2
name 3
name 4

[MESSAGES]
message 1, message time
message 2, message time
message 3, message time
message 4, message time
(EOF)
--
/********************************\
|* I'm a wizard, not an English *|
|* major.  Ignorre my speling   *|
|* mistaks                      *|
\********************************/



Fri, 08 Oct 1999 03:00:00 GMT  
 Random access files - having and finding multiple types of record in one file

Your second file only has one record type -- just more than one record.

Create a UDT:

Type udtMsg
        Message * 1024 As String ' or whatever length works for you
        ShowTime As Double
End Type

Use Get to read the open file:

Dim StoredMsg As udtMsg
Get #1, RecordNumber, StoredMsg

The message is in StoredMessage.Message
The time is in StoredMessage.ShowTime

Random access storage requires fixed length records. That allows you to read any
record by recpord number, so you need not read all the ones that precede it.

This is all covered in my book -- Visual Basic 5 Interactive Course from the
Waite Group Press.

  >My boss wants a GUI to send a series of messages to a list of people on
  >the network.  He also wants to have more that one list at a time having
  >messages sent to them.  For memory conservation, I'd like to be able use
  >random file access on each list that's being used.  The way that the
  >list files are designed so far (though it may change if I have to) is a
  >listing of all names followed by a listing of all messages to be sent
  >with the time that the messages are to be displayed.
  >
  >What I need to know is HOW to read multiple record types in a file that
  >has more than 1 record type (below is an example of what the file looks
  >like).  For example, once message 1 has been displayed for it's given
  >period of time, then message 2 would be displayed.  I want to go
  >straight to message 2 without having to re-read the entire file.  I hope
  >this makes some sense.  I've read the VB Books Online (Online Manual)
  >and the FAQs, but all I've found so far is that there must be 1 record
  >type in the file :(
  >
  >Hope someone can help me... (and this program is NOT for spam)
  >
  >(example list file)
  >[NAMES]
  >name 1
  >name 2
  >name 3
  >name 4
  >
  >[MESSAGES]
  >message 1, message time
  >message 2, message time
  >message 3, message time
  >message 4, message time
  >(EOF)
  >--
  >/********************************\
  >|* I'm a wizard, not an English *|
  >|* major.  Ignorre my speling   *|
  >|* mistaks                      *|
  >\********************************/



Sat, 09 Oct 1999 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Having a problem with Random Access Files...

2. Q. More than one Type in Random file ?

3. Arrays, Type, and Random Access Files Problem

4. Declaring String Lengths in a Type Statement for Random Access Files

5. HELP HELP with arrays in type defs for random access file writing

6. number of records in a random access file?

7. # Records in a RANDOM ACCESS file?

8. Last record in Random Access File

9. Delete a record from a Random Access File?

10. Random Access File - Deleting records

11. How to delete record in random-access file?

12. Accessing file from one CD-ROM in a multiple CD-ROM system

 

 
Powered by phpBB® Forum Software