Author |
Topic: RANDOM ACCESS LIBRARY? (Read 547 times) |
|
joker
Global Moderator
member is offline
Gender:
Posts: 157
|
|
RANDOM ACCESS LIBRARY?
« Thread started on: Oct 20th, 2015, 10:48am » |
|
Being new to LBB and LB, but not new to BASIC I am reluctant to reinvent random access file routines. "In the old days" I had a library of "generic" routines for opening, closing, indexing, get record, put record, delete record, recovering space, etc. Are routines like that available that I can use?
I had thought to try SQLite, but seems like so much overkill for my simple program, because there won't be thousands of records.
|
|
Logged
|
|
|
|
Richard Russell
Administrator
member is offline
Posts: 1348
|
|
Re: RANDOM ACCESS LIBRARY?
« Reply #2 on: Oct 20th, 2015, 11:59am » |
|
on Oct 20th, 2015, 10:48am, pnlawrence wrote:Being new to LBB and LB, but not new to BASIC I am reluctant to reinvent random access file routines. "In the old days" I had a library of "generic" routines for opening, closing, indexing, get record, put record, delete record, recovering space, etc. Are routines like that available that I can use? |
|
LB/LBB natively supports Random Access Files with open, close, get record and put record statements. What you don't get 'built in' is full database functionality such as the ability to delete a record and recover the space.
It may be that a library for that already exists, but I don't personally know of one (of course only LBB supports 'true' libraries; with LB the routines would need to be appended to your own program).
If you do decide to use an off-the-shelf database package SQLite is not necessarily the best choice. LB/LBB can easily interface with ODBC (it's a standard component of Windows) which has the advantage of not tying you to one particular database manager.
Richard.
|
|
Logged
|
|
|
|
joker
Global Moderator
member is offline
Gender:
Posts: 157
|
|
Re: RANDOM ACCESS LIBRARY?
« Reply #3 on: Oct 20th, 2015, 12:13pm » |
|
I should have used the words "stored procedure" in my post.
A "stored procedure" being a little higher level function/sub/gosub encapsulation of database functions.
What I like to do in my programs is "insulate" myself from myself!
Quote:LB/LBB can easily interface with ODBC |
|
I hadn't thought of ODBC. I'll do some searching there.
|
|
Logged
|
|
|
|
joker
Global Moderator
member is offline
Gender:
Posts: 157
|
|
Re: RANDOM ACCESS LIBRARY?
« Reply #4 on: Oct 20th, 2015, 12:33pm » |
|
Searching ...
Damn! Everything about BASIC is frustratingly OLD like me! Seems like every solution I run across is from 10 years ago.
I think RAF will be plenty robust enough for my program. tsh73, I have looked at all the resource links you provided and am studying how to make my own procedures.
Perhaps its time for a project to define a library of "stored procedures" for RAF.
|
|
Logged
|
|
|
|
Mystic
Junior Member
member is offline
Gender:
Posts: 53
|
|
Re: RANDOM ACCESS LIBRARY?
« Reply #5 on: Oct 23rd, 2015, 12:33am » |
|
I would love to see some functions made that perform some simple SQL-like functions using the native RAF system...
Thought about trying to write some of my own but time is lacking.
|
|
Logged
|
- Rick
|
|
|
joker
Global Moderator
member is offline
Gender:
Posts: 157
|
|
Re: RANDOM ACCESS LIBRARY?
« Reply #6 on: Oct 23rd, 2015, 11:09am » |
|
I'm starting to believe that it can be done, but only with a lot of "low level" routines serving as some sort of "interpreter" between the "SQL-like" statements and LB/LBB.
There doesn't seem to be much benefit for spending all the time involved.
|
« Last Edit: Oct 23rd, 2015, 11:10am by joker » |
Logged
|
|
|
|
Alincon
Full Member
member is offline
Posts: 147
|
|
Re: RANDOM ACCESS LIBRARY?
« Reply #7 on: Oct 24th, 2015, 5:34pm » |
|
I don't use Random Access Files because you can't access them randomly - unless you know the record number - which means a separate index file - which means more work keeping the index and main file in synch.
I think the simplest thing to do is use one-record files and access them (randomly !) with the file dialog statement.
r.m.
|
|
Logged
|
|
|
|
Richard Russell
Administrator
member is offline
Posts: 1348
|
|
Re: RANDOM ACCESS LIBRARY?
« Reply #8 on: Oct 24th, 2015, 7:25pm » |
|
on Oct 24th, 2015, 5:34pm, Alincon wrote:which means more work keeping the index and main file in synch. |
|
There's not much effort involved in keeping them 'in sync' because the only way they can ever lose synchronisation is when you rebuild the data file to recover the space occupied by deleted records. Typically you would perform that operation only infrequently.
Quote:I think the simplest thing to do is use one-record files and access them (randomly !) with the file dialog statement. |
|
That's likely to be very wasteful of disk space. Consider the classic example of a database - an address list. A record might need to be something like 200 bytes long to contain (for example) a name, address, telephone number and email. But the minimum amount of disk space occupied by a file (however small) is typically 4 Kbytes - and that doesn't take into account the size of the directory itself - so you could easily end up using more than 20 times the amount of disk space than your database should occupy!
Richard.
|
|
Logged
|
|
|
|
joker
Global Moderator
member is offline
Gender:
Posts: 157
|
|
Re: RANDOM ACCESS LIBRARY?
« Reply #9 on: Oct 24th, 2015, 7:33pm » |
|
Can you explain what application uses a "randomly" accessed file system?
on Oct 24th, 2015, 5:34pm, Alincon wrote:I think the simplest thing to do is use one-record files and access them (randomly !) with the file dialog statement. |
|
|
|
Logged
|
|
|
|
|