Liberty BASIC Community Forum
« defining the field of random access files »

Welcome Guest. Please Login or Register.
Apr 24th, 2017, 9:49pm


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


« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: defining the field of random access files  (Read 441 times)
Zabo
Full Member
ImageImageImage


member is offline

Avatar

Yes. It work's. ha


PM

Gender: Male
Posts: 110
xx defining the field of random access files
« Thread started on: Oct 13th, 2016, 2:19pm »

Hello,

i have a simple question about the random access files.

open ''data.dat" for random as #data len=140
field #data, 50 as one$, 40 as two$, _
30 as three$, 20 as fourth$
put #data, place
close #data


The field command.

There is the name one$ and two$ as names
for the fields.

Is it possible that the user is choosing the name of theese fields by himself , before the file is opening ,
with a normal input.

With a variable string ?

input "Choose a name for the first field :" ; first$

then

field #data, 50 as "first$" , 40 as etc.

place a string here that contains the name of the field.

I know that this input can only make ONCE for the
file , before the file is created.
To rename the fields of a already existing record i suppose the file has to be erased and a new one
must be created.


Altogehter :

I want to make a random access file where the user
defines the field names ONCE before he is using
the database.

___________________________________________

If it is not possible i know that a neutral name for
every field is to make that fits all kind of data names
such like :

open ''data.dat" for random as #data len=140
field #data, 50 as A1$, 40 as A2$, _
30 as A3$, 20 as A4$
put #data, place
close #data

open ''data.dat" for random as #data len=140
field #data, 50 as B1$, 40 as B2$, _
30 as B3$, 20 as B4$
put #data, place
close #data

____________________________________________


WBR


Zabo





« Last Edit: Oct 13th, 2016, 2:46pm by Zabo » User IP Logged

JackKelly
Guest
xx Re: defining the field of random access files
« Reply #1 on: Oct 13th, 2016, 4:13pm »

Zabo,

What you want to do is exactly what Database Management Systems do. These are preprogrammed package systems that allow you to set up a random access file with field names of your, or the user's, choice -- as well as field types (character, numeric with decimal places, date, logical-true/false), and field size. To do all this from scratch using BASIC code is a major programming task. Are you sure you want to reinvent the wheel? Or would you be happy to use established subroutines and function definitions that do the same thing? Even doing that is still not simple and easy by any means. Think about it and let me know...

Jack
User IP Logged

Rod
Global Moderator
ImageImageImageImageImage


member is offline

Avatar

Graphics = goosebumps!


PM

Gender: Male
Posts: 5245
xx Re: defining the field of random access files
« Reply #2 on: Oct 14th, 2016, 01:41am »

Perhaps RAF is the wrong choice. Look at BINARY file commands. You can use SEEK to move the record pointer and you only need to build routines to load and save the variables from each "record".

This avoids the need for the field definition, BINARY is a very flexible file type.
User IP Logged

tsh73
Board Moderator

member is offline

Avatar

Anatoly (real name)


PM

Gender: Male
Posts: 1618
xx Re: defining the field of random access files
« Reply #3 on: Oct 14th, 2016, 02:44am »

Quote:
Is it possible that the user is choosing the name of theese fields by himself , before the file is opening ,
with a normal input.

With a variable string ?

No.
And - what use it will be for a user? Fields names are used in a program, by a programmer. User never sees them.

Quote:
To rename the fields of a already existing record i suppose the file has to be erased and a new one
must be created.

No.
File stores only data. Field names exist only in a program (field lengths too).
So you can write file with one FIELD setting then read it with another one.
« Last Edit: Oct 14th, 2016, 02:45am by tsh73 » User IP Logged

The existence of bug reports means somebody is using the software and actually cares to report back to you that he is having a problem with it, instead of just deleting it from their hard disk.
(Janusz Marcin Gorycki)
Zabo
Full Member
ImageImageImage


member is offline

Avatar

Yes. It work's. ha


PM

Gender: Male
Posts: 110
xx Re: defining the field of random access files
« Reply #4 on: Oct 14th, 2016, 1:22pm »

02.03.2017
Hi all. I make the thing ready. Really.
Have made a house move.
The only things i have done in the last days
are carrying heavy weights.

Now i am back online.
Zabo

Hi ,

thank you to all this feedback.

(I''m just back from sitework.
We have installed network cameras in industry.)

I understand. The user don't see the field definitions.
So i make it neutral A1 B1 C1 etc.

I am only interesting in that commands.

Easy. The user input the category name in a string.
That string is equal to as example A1.
A1 = string$

I will take an eye on the binary file handling.


Before that i will deliver the complete sequential database with GUI and sound. etc. Rapid Database.

I can tell that i have chosen the option for the user
that he can input a static text , as category.
Then he input this dataword under the exact place
of the static text in the GUI textbox.
A simple solution.
There is only one line of record data.
But every word of the line can be placed under the static text.
So you have a unreal pointer. ha
Not for sorting. Only for every single record.


WBR

Zabo






tongue
« Last Edit: Mar 2nd, 2017, 12:31pm by Zabo » User IP Logged

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