[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference hydra::amiga_v1

Title:AMIGA NOTES
Notice:Join us in the *NEW* conference - HYDRA::AMIGA_V2
Moderator:HYDRA::MOORE
Created:Sat Apr 26 1986
Last Modified:Wed Feb 05 1992
Last Successful Update:Fri Jun 06 1997
Number of topics:5378
Total number of notes:38326

2277.0. "AmigaBasic Random File Problem" by ADODEM::MCGHIE (looking for a door...) Fri Feb 24 1989 23:53

    Hi People,
    
    Just a warning about using AmigaBasic for those people who use it.
    
    I was trying to write a program to test Random file access.

    I wrote a small program to write 100 records to a random file. It
    then let me read a record specified by record number. I was using
    the EOF function to determine whether or not the record had been
    read correctly. When I initialised the file each record contained
    the record number as part of the record structure.
    
    What I found was the following :-
	Action			Result
    
    	Read record 10		Got record 10, eof false
	Read record 45		Got record 45, eof false
    	Read record 1000	Got record 46, eof false
    	Read record 500		Got record 47, eof false
    	Read record 75		Got record 75, eof false
    	Read record 101		Eof true.
	Read record 102		Eof true.
    
    I haven't tested it any further to date, I've been out of town for
    a week. My test file was in the ram disk.
    
    I'm going to test it further at some point and post the results
    here.
    
    Regards
    	Mike
T.RTitleUserPersonal
Name
DateLines
2277.1work-around availableCGFSV1::WADLEIGHDave in Calgary, AlbertaSat Feb 25 1989 01:377
    What to do?
    
    When you write a record that causes the file to be extended beyond
    the previous EOF, the EOF will be unreliable until you close the
    file and re-open it again.
    
    Just close and reopen the file after you've extended it, and you'll be OK.
2277.2deleteing records from raf'sNZOV01::MCKENZIENuke the Leprechaun!Sun Feb 26 1989 14:277
    just out of interest - how do you DELETE records from a random access
    file???
    
    I know GET is used to read and PUT to write but how do you cream
    a record from a file permanantly??
    
    Phil
2277.3exitADODEM::MCGHIElooking for a door...Sun Feb 26 1989 18:5919
    re: .1
    
    Thanks for that, I'll check it some more. But after trying to use
    amigabasic for a largish program (>25k) I'm of the opion that its
    basically a waste of time to use it. However given the cost of
    compilers I don't have a lot of choice at the moment.
    
    re: .2

    Typically you don't delete records out of random files. Once the
    record space has been allocated, that's it.
    
    I would put an in-user flag into the record and set it to false
    if it was to be deleted so it could be re-used. The other alternative
    is to run a small program to re-claim 'deleted' (i.e. not in use)
    by copying in-user records to a new file.
    
    regards
    	Mike