Liberty BASIC Community Forum
« RANDOM ACCESS FILE »

Welcome Guest. Please Login or Register.
Sep 21st, 2017, 7:55pm


Rules|Home|Help|Search|Recent Posts|Notification


« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: RANDOM ACCESS FILE  (Read 5 times)
nooneyouknow
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 39
xx RANDOM ACCESS FILE
« Thread started on: Oct 13th, 2015, 10:36am »

Back when a fast computer was a "386" (it had to have an "X" in the name or it wouldn't sell), BASIC was compiled by MS, but you had to add libraries of functions to compete (microHELP comes to mind) we used to worry about "corrupting" files on disc.

I had a customer that required me to add constant "comma" fields in between regular fields and "carriage return/line feed" as the last 2 character field in their random access files. This way they surmised they could recover the files in a sequential manner (read only) as well as randomly record by record.

Anyway, I got into the habit of keeping "CR/LF" as the last 2 character field in the random access files that I used. It came in handy then for "recovery" operations. I know, but it worked.

Since I'm getting back into basic programming on the PC, my question is to find out what others think about these old methods.

I haven't had a hard drive go "bad" in decades where it wasn't totally fatal, so it may be a moot point.
User IP Logged

MKnarr
Senior Member
ImageImageImageImage


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 430
xx Re: RANDOM ACCESS FILE
« Reply #1 on: Oct 13th, 2015, 1:53pm »

A few thoughts. RAF files can always be read sequentially or by record. Second they are actually in plain text so can easily be read by any word processor. I don't see the need to add commas or CR/LF but they can be added.

I wouldn't be to worried about hard drive failing because one should always follow the rule. The road to Hades is fill with the the souls that failed to backup.

I have a commercial program that allows backup of files to a folder in the My Documents directory because that is the most common folder that backup program want to backup to an alternate site/hard drive/thumb drive.
User IP Logged

Stefan Pendl
Global Moderator
ImageImageImageImageImage


member is offline

Avatar

Computers are like babies, you must teach them what you like them to do ...


Homepage PM

Gender: Male
Posts: 5295
xx Re: RANDOM ACCESS FILE
« Reply #2 on: Oct 13th, 2015, 2:47pm »

A RAF is not supposed to be a CSV file.
Altering a RAF by a regular text editor is more likely to corrupt the file.
If you keep away from adding field separators (commas) and record separators (CrLf), you are more likely to not have the file corrupted.

If you want a CSV file, create and use one, too many options will result in too complex code.
User IP Logged

Stefan

Make sure to read and follow the Forum Guidelines

Liberty BASIC Pro 4.04, Windows 10 Professional x64, Intel Core i7-4710MQ 2.5GHz, 16GB RAM
nooneyouknow
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 39
xx Re: RANDOM ACCESS FILE
« Reply #3 on: Oct 14th, 2015, 04:57am »

Perhaps I didn't make the point of adding those extra characters clear enough.

The point was not to use the RAF as a SEQ file, it was to recover data once the file suffered from some corruption.

The file can be opened in a text editor and uncorrupt data can be recovered in a simple way, because the record separators made it easier, and because at that point one would be desperate enough to do this. cry
User IP Logged

G. Rahman
Guru
ImageImageImageImageImage


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 1145
xx Re: RANDOM ACCESS FILE
« Reply #4 on: Oct 17th, 2015, 10:52am »

Hello pnlawrence,

By now you have studyed the helpfile (File Operations).

LB is an easy language.
It builds (write) your file in ASCII.
It automatically places "," and so on for you when needed (seq.-files).

Just let LB write some test files and view them with your notebloc.

LB can always read any file (even one character at a time).
You can always change any character in a file ..... (and corrupt it)
You can SEEK your filepointer to a specifik point in a file.

Here a place to look too.
http://lbpe.wikispaces.com/IntroToFiles

Gordon

« Last Edit: Oct 17th, 2015, 10:52am by G. Rahman » User IP Logged

Gordon Rahman

http://www.libertybasic.nl
Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

Rules|Home|Help|Search|Recent Posts|Notification

Donate $6.99 for 50,000 Ad-Free Pageviews!

| |

This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls