Hi, I came from Business BASIC (BBx, ProvideX, PxPlus, etc), and bought a PureBASIC because I used it several (many!) years ago, and I liked it a lot. But, now, I think perhaps I can write some programs in PB instead of Business BASIC; but my main concern is I don't know if there a file storage similar to Business BASIC, where I can do:
! MYFILE is simple file, like STUDENTS.DAT or XXX.TXT or NOTHING.PNG, just with an internal structure
open(chan)MYFILE$
input "Key: ",cust_code$
read (chan,key=cust_code$)
...
write(chan)
...
The record access is made by a string (alphanumeric) key and is almost instantly; not Databases, no external tools, just a plain file with a excellent I/O method, and very fast (and we can store millions of records). Of course the language also support DataBase access, but that's not the question for me...
I've read a lot of pages, and only found a map structure that looks like keyed files, but I don't know if they can be used in the same (or similar) way. I know each language has is advantages and differences, but I'm used to this kind of storage and is ideal (for me) in small projects.
Best regards,
Jean H//
Keyed access file or similar?
-
- New User
- Posts: 3
- Joined: Thu Aug 04, 2022 10:28 pm
- Location: Valencia, Venezuela
Re: Keyed access file or similar?
I suppose you could use preference... but really, there WAS something else going on - some library that was linked in to provide that functionality.
I suppose you could say if you use sqlite, nothing "external" is used, it's all in one exe and provides full database support.
I think (I'm not sure) but if you search forums for "simple database" or "text database" you'll find code for something simple; but I'm not sure it will still work; I recall it from years ago, and purebasic has a way of dropping or changing functions over time.
I think preferences will be your simplest & easist solution.
I suppose you could say if you use sqlite, nothing "external" is used, it's all in one exe and provides full database support.
I think (I'm not sure) but if you search forums for "simple database" or "text database" you'll find code for something simple; but I'm not sure it will still work; I recall it from years ago, and purebasic has a way of dropping or changing functions over time.
I think preferences will be your simplest & easist solution.
-
- New User
- Posts: 3
- Joined: Thu Aug 04, 2022 10:28 pm
- Location: Valencia, Venezuela
Re: Keyed access file or similar?
Thanks for yourfast and kindly answer ... I'll look into preferences.
Jean H//
Jean H//
Re: Keyed access file or similar?
it's not ideal by any stretch, but it's probably the closest thing you're after...jhendrickx wrote: ↑Mon Jun 05, 2023 11:55 pm Thanks for yourfast and kindly answer ... I'll look into preferences.
Re: Keyed access file or similar?
It does sound a bit like you want to use a huge file with fixed-length records to avoid using some kind of database "for speed reasons".
You can simply do that in purebasic with the file commands - where you use fileseek to position absolutely on a specific record.
IMHO it is a bad idea from the past, but you can easily implement that in purebasic.
Databases can be super fast, a better way would probably to find the best database solution for your task and access it with purebasic.
You can simply do that in purebasic with the file commands - where you use fileseek to position absolutely on a specific record.
IMHO it is a bad idea from the past, but you can easily implement that in purebasic.
Databases can be super fast, a better way would probably to find the best database solution for your task and access it with purebasic.
Re: Keyed access file or similar?
If you use a structure with fixedstrings instead of dynamic one, you can write it to disk in one go with https://www.purebasic.com/documentation ... edata.html and use fileseek (using SizeOf(YourStructure))
-
- New User
- Posts: 3
- Joined: Thu Aug 04, 2022 10:28 pm
- Location: Valencia, Venezuela
Re: Keyed access file or similar?
Thanks! I'll take a look into the answers!
Jean H//
Jean H//