Page 1 of 2

LDB ( Little DataBase ) 1.0 Beta

Posted: Sun Mar 20, 2005 2:17 pm
by Droopy
This library is for managing little database, with sort and search function.

I code it only with PB function ( without Api function )

If you find a bug, or error in my doc, please answer me

I provide a CHM help file and a Word file that described all command by function

Download the Library

Here's a test code

Code: Select all

; Test for the Ldb library ( Little Database )
; launch it in debug mode

; Initialize the Library
LdbInit()

; Create a new Database with 3 fields
LdbCreate("c:\Drivers.db","Birth Date,Name,Surname")

; Add one Record
LdbInsertRecord(-1)
; Write data to this record
LdbWrite(1,"1969") ; 1st field
LdbWrite(2,"Schumacher") ; 2nd field
LdbWrite(3,"Michey") ; 3rd field

; Add another Record
LdbInsertRecord(-1)
; Write data to this record
LdbWrite(1,"1980") ; 1st field
LdbWrite(2,"Button") ; 2nd field
LdbWrite(3,"Jenson") ; 3rd field

; Add another Record
LdbInsertRecord(-1)
; Write data to this record
LdbWrite(1,"1981") ; 1st field
LdbWrite(2,"Alonso") ; 2nd field
LdbWrite(3,"Fernando") ; 3rd field

; Add another Record
LdbInsertRecord(-1)
; Write data to this record
LdbWrite(1,"1971") ; 1st field
LdbWrite(2,"Villeneuve") ; 2nd field
LdbWrite(3,"Jacques") ; 3rd field

; Insert a record at 3rd position
LdbInsertRecord(3)
; Write data to this record
LdbWrite(1,"1975") ; 1st field
LdbWrite(2,"Schumacher") ; 2nd field
LdbWrite(3,"Ralph") ; 3rd field

; Move to 1st record cause bad surname
LdbSetPointer(1)
; Change Field 3 with good surname
LdbWrite(3,"Michael")

; Sort the database by field 1 ( Birth Date )
LdbSortNum(1)

; Show all drivers sorted by birth Date
Debug "Drivers sorted by birth date"
For n=1 To LdbCountRecord()
  LdbSetPointer(n)
  Debug LdbRead(1)+" "+LdbRead(2)+" "+LdbRead(3)
Next
Debug ""

; Sort the database by Drivers names
LdbSortAlpha(2,0)

; Show all drivers sorted by name
Debug "Drivers sorted by name"
For n=1 To LdbCountRecord()
  LdbSetPointer(n)
  Debug LdbRead(1)+" "+LdbRead(2)+" "+LdbRead(3)
Next
Debug ""

; Search all name = Schumacher
LdbSearchInit(2,"Schumacher",0)

; Show all drivers = Schumacher
Debug "Drivers with name = Schumacher"
Repeat
Champ=LdbSearch()
If Champ=0 : Break : EndIf ; if 0 --> search finished
LdbSetPointer(Champ)
Debug LdbRead(1)+" "+LdbRead(2)+" "+LdbRead(3)
ForEver
Debug ""

; Database Infos
Debug "Database Infos"
Debug "Number of fields "+Str(LdbCountField())
Debug "Name of field"
For n=1 To LdbCountField()
  Debug "Field n° "+Str(n)+" = "+LdbGetFieldName(n)
Next

Debug "Number of records "+Str(LdbCountRecord())

; Save Database to disk
LdbSaveDatabase()
; Close the Database
LdbCloseDatabase()

Posted: Sun Mar 20, 2005 3:51 pm
by thefool
Hi droopy!
i cant download your lib, the file is not reachable..

edit:
it seems that purestorage [purebasic.myftp.org] is not reachable..

Posted: Sun Mar 20, 2005 4:14 pm
by Droopy
I'm downloading the lib without problem.

AnybodyElse has the same problem ?

Posted: Sun Mar 20, 2005 4:39 pm
by thefool
sry my fault my PeerGuardian blocked it.. Why?

Posted: Sun Mar 20, 2005 11:06 pm
by Bonne_den_kule
thefool wrote:sry my fault my PeerGuardian blocked it.. Why?
The reason may be because the server don't send the filesize of the file

Posted: Sun Mar 20, 2005 11:20 pm
by thefool
could be. it writes "Genuity" as the range.. [range is here the stuff to block. Othertimes it writes "fake fileservers block" etc]

Posted: Sun Mar 20, 2005 11:30 pm
by ricardo
Nice!!!!

This you test how much stable it is? Speed if database grows?

I was wanting something like this some time ago, thanks!!

Posted: Sun Mar 20, 2005 11:43 pm
by thefool
forgot to test the lib :D

it looks pretty nice! it works without any problems. It seems
nice if you need a small database for your program!

Posted: Mon Mar 21, 2005 12:49 am
by Beach
thefool, are you still having issues downloading? Is my site being blocked by "peergaurd"??

Posted: Mon Mar 21, 2005 9:49 am
by thefool
@beach: peerguardian 2 blocked it, but it has an ability to "Dont block http" so i turned that on and it worked. In PG2 log, it said "Genuity"
as bonne said "The reason may be because the server don't send the filesize of the file", that might be true.

info about peerguardian 2: http://www.methlabs.org/
But many users. 11,383 registered forum users, most online 472 users, so i would say its a widely known software. Also i didnt even find it on the internet i got it recommended by a friend :)

well it would be as bonne said, but why does it block the main page then?

Re: LDB ( Little DataBase ) 1.0 Beta

Posted: Mon Mar 21, 2005 12:37 pm
by zikitrake
Droopy wrote:This library is for managing little database, with sort and search function.
Your lib will be very useful for me.

Thank you!

Posted: Mon Mar 21, 2005 5:23 pm
by Beach
well it would be as bonne said, but why does it block the main page then?
I bet it is because of the redirect. "purebasic.myftp.org" redirects to my main web site. I just did this so I could move PureStorage easily if I needed to.

This database lib looks awsome... sorry to hijack the thread...

This is good stuff

Posted: Wed Mar 23, 2005 2:04 pm
by Fangbeast
Droopy, I'd like to use this with my Diabetes testing loggger and I have a question..

Is there any way to build in a search function (easily) that behaves like MySQL's?

Like: "=, Starts with, Ends With, Contains, <, >"

If not, I will have to start thinking (and that hurts!!)

Posted: Wed Mar 23, 2005 5:28 pm
by Droopy
Is there any way to build in a search function (easily) that behaves like MySQL's?

Like: "=, Starts with, Ends With, Contains, <, >"
= is the defaulf search
Contains = option #Everywhere

"Ends / < / > / Starts" I think it's not a big job
You have to add options ( #< #> #Start #Ends ) and in the search procedure treat this options


I provide the source code with the library

Thanks Droopy

Posted: Thu Mar 24, 2005 4:16 am
by Fangbeast
I will give it a good read. Ever since I was diagnosed, I found a need for a small, local database like this one.