Author Topic: Simple permanent storage library  (Read 5811 times)

0 Members and 1 Guest are viewing this topic.

Offline keybone

  • Forum Regular
  • Posts: 116
  • My name a Nursultan Tulyakbay.
    • View Profile
Simple permanent storage library
« on: August 02, 2018, 07:39:36 pm »
Post Deleted
« Last Edit: April 14, 2022, 08:46:20 am by RCcola1987 »
I am from a Kazakhstan, we follow the hawk.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Simple permanent storage library
« Reply #1 on: August 02, 2018, 10:42:10 pm »
Have you took a look at my QBDbase library?  It seems to me that what you're doing here is very similar to it -- using _MEM to create a database system to use in QB64 programs. 

If [abandoned, outdated and now likely malicious qb64 dot net website - don’t go there] ever comes back up, you can find the instructions and library files there. 
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline keybone

  • Forum Regular
  • Posts: 116
  • My name a Nursultan Tulyakbay.
    • View Profile
Re: Simple permanent storage library
« Reply #2 on: August 03, 2018, 07:05:42 am »
Have you took a look at my QBDbase library?  It seems to me that what you're doing here is very similar to it -- using _MEM to create a database system to use in QB64 programs. 

If [abandoned, outdated and now likely malicious qb64 dot net website - don’t go there] ever comes back up, you can find the instructions and library files there.

If .net ever comes back up ill be sure to check it out. :)
I am from a Kazakhstan, we follow the hawk.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Simple permanent storage library
« Reply #3 on: August 03, 2018, 09:27:18 am »
Funny, I have recently been thinking of building a set of array tools: Insert, Delete, Append, Sort... but did not consider using MEM which makes good sense for speed.

Can strings be done? How to handle different types? How to handle user defined Record type?

Sorry keybone this might be more than you wanted to get into but building a set of Dbase tools is great idea.

I hear it's better the 2nd time around. :-))


Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Simple permanent storage library
« Reply #4 on: August 03, 2018, 12:54:45 pm »
Funny, I have recently been thinking of building a set of array tools: Insert, Delete, Append, Sort... but did not consider using MEM which makes good sense for speed.

Can strings be done? How to handle different types? How to handle user defined Record type?

Sorry keybone this might be more than you wanted to get into but building a set of Dbase tools is great idea.

I hear it's better the 2nd time around. :-))

QBDbase library: https://www.dropbox.com/s/8mouscuqh127vpm/QBDbase.7z?dl=1

And a little sample program which reads from the included QBD file (which is the file extension which I chose to stand for a self contained QBDbase file):

Code: QB64: [Select]
  1. 'QB64 Code Auto-Generated by the QBDbase Library
  2. 'On 08-03-2018
  3.  
  4. 'QBDbase Library coded and designed by Steve McNeill
  5. 'smcneill@swva.net
  6.  
  7. 'And is open source and free for all use - both commercial and private -- with no expection of credit needed nor required.
  8. 'But if you want to send me a cute picture of a beautiful girl in a swimsuit (swimsuit optional), feel free to use the email above.
  9.  
  10.  
  11. 'QB64 code starts here:
  12.  
  13. '$Include:'DataLibraryH.BI'
  14.  
  15. TYPE QBDdefaultType ' feel free to change this if you want a custom name type
  16.     InValid AS _BYTE
  17.     Word AS STRING * 75
  18.     length AS _UNSIGNED _BYTE
  19. DIM MyRecord AS QBDdefaultType
  20. TypeMem(0) = _MEM(MyRecord)
  21.  
  22. Filehandle = OpenData("SpellList.QBD", 0)
  23. PRINT QBDRecordsUsed(Filehandle); "records exist in database"
  24. FOR i = 1 TO 10
  25.     PRINT "Record #"; i,
  26.     ReadData Filehandle, i
  27.     IF NOT MyRecord.InValid THEN
  28.         PRINT LEFT$(MyRecord.Word, MyRecord.length)
  29.     ELSE
  30.         PRINT "Deleted"
  31.     END IF
  32.  
  33. FOR i = 1 TO 10
  34.     ReadData Filehandle, i
  35.     IF MyRecord.InValid THEN
  36.         UnDeleteData Filehandle, i
  37.     END IF
  38.  
  39. FOR i = 1 TO 10
  40.     PRINT "Record #"; i,
  41.     ReadData Filehandle, i
  42.     IF NOT MyRecord.InValid THEN
  43.         PRINT LEFT$(MyRecord.Word, MyRecord.length)
  44.     ELSE
  45.         PRINT "Deleted"
  46.     END IF
  47.  
  48.  
  49.  
  50. '$Include:'DataLibraryF.BM'
  51.  

If you look in the DataLibraryF.BM (the footer file which goes at the end of your code), you'll see that we have all sorts of nice tools already at our disposal with QBDbase.  It counts records, add records, deletes records, UNDELETES records (as the above demo illustrates) for when we screw up and delete the wrong record, sorts by field.  It packs databases to purge deleted files when we need it to, to minimize file size and memory usage.  It allows us to password protect our databases, and to write our own password routines if we want...  It can EXPORT the database into several various formats which we can use in different programs such as Word or Excel.  (CSV format, TXT format, DBF -- yes, that's native DBF file export capability, BAS GET/PUT format, and even user defined formats...)  It tells us how many records we've used, and what we've allocated as a max number of records for our database (which we can change if needed)...  It can quickly blank and reset records...

Heck, it even takes an existing QBDbase file and can extract information from it to generate the BAS code required to access that file for you!!

AND, it does even more than all this....

IF somebody has a copy of V1.4 which I had uploaded to [abandoned, outdated and now likely malicious qb64 dot net website - don’t go there].  What we have here is an older version which I managed to drag up on my computer, but I can't seem to locate the latest, greatest version which I'd shared and posted for the world to enjoy.  My main PC, where I usually work and store all my QB64 stuff, is offline until I replace several of the fans to keep the motherboard/CPU from overheating, and this older version is all I can dig up on my laptop's drives....

If I remember correct, v1.4 also allows us to print out the contents of the database (complete, or just specific records), and it was modified to make use of enhancements which were added to QB64 since the original QBDbase was written waaaaaay back in QB64-SDL times.   (Such as not needing the string compare routines which this version accesses via a *.h file.)

If you're looking for a database program for use with QB64, you might consider digging into this one for a little bit, bplus.  It might do all you're looking for -- and then some!  ;)
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Qwerkey

  • Forum Resident
  • Posts: 755
    • View Profile
Re: Simple permanent storage library
« Reply #5 on: August 03, 2018, 01:12:10 pm »
Have you took a look ...

Hey, Master Wordsmith!  Take: Past tense took, past participle taken.  What were you thinking?!

Richard

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Simple permanent storage library
« Reply #6 on: August 03, 2018, 01:36:45 pm »
Thanks Steve, I will check it out!

So String types are no problem with memory?

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Simple permanent storage library
« Reply #7 on: August 03, 2018, 01:38:08 pm »
Have you took a look ...

Hey, Master Wordsmith!  Take: Past tense took, past participle taken.  What were you thinking?!

Richard

"took a look" is perfectly valid Applachian English (the regional dialect where I live).  https://en.m.wikipedia.org/wiki/Appalachian_English

Usually, in professional settings, I try to avoid our local colloquialisms as much as possible as they often come across as sounding "Mountain Hillbilly"ish to many folks, but sometimes they sneak into writing even when I try to keep them out of it.  If you think it reads funny, you should try and talk to me on the phone sometime -- I'm much worse at censoring the dialect verbally than I am when writing.

T'ain't ah big deal a-toll, if'n ya gits ta learn'n da local vee-nacular!  ;)
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Simple permanent storage library
« Reply #8 on: August 03, 2018, 01:41:03 pm »
Thanks Steve, I will check it out!

So String types are no problem with memory?

QBDbase uses _MEM for everything, so it supports fixed-length strings but not variable length ones.  Variable length strings can move in memory at anytime, so they don't really place nice with _MEM.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline TerryRitchie

  • Seasoned Forum Regular
  • Posts: 495
  • Semper Fidelis
    • View Profile
Re: Simple permanent storage library
« Reply #9 on: August 20, 2018, 02:57:10 am »
I did not originally see this thread when I created a new one about Steve's database library, sorry.

So, does anyone have version 1.4 to share?
In order to understand recursion, one must first understand recursion.