Need SimpleDataBank Tutorial
BlitzMax Forums/BlitzMax Beginners Area/Need SimpleDataBank Tutorial
| ||
Hi, Anybody here written a databank in MAX, I need one for my CD/DVD collection would love to write one in MAX but I am no expert, could someone point me in the write direction, Tutorial would be good as I have no Idea how to even start. I have read “Waves beginning Blitzmax” but this is not really relevant to Databank programming. There must be some way To accomplish such a small task without using SQL or what ever. Thanks in advance. |
| ||
You can use TMaps. Check the help docs and: http://blitzbasic.com/Community/posts.php?topic=79711 Or you can use TLists. It's a bit easier. I have thrown together a simple example: SuperStrict ' always use it! Type TDatabase Field dvdlist:TList = New TList Method AddDVD(nameofDVD:String, publishedyear:String) ' create a new type Local newdvd:TDVD = New TDVD newdvd.name = nameofDVD newdvd.year = publishedyear Self.dvdlist.AddLast(newdvd) ' add new type to list End Method ' Method RemoveDVD(nameofDVD:String) For Local dvd:TDVD = EachIn Self.dvdlist If dvd.name = nameofDVD Self.dvdlist.Remove(Self) End If Next End Method ' Method FindDVD:tdvd(nameofdvd:String) For Local dvd:TDVD = EachIn Self.dvdlist ' search whole list for dvd with give name If dvd.name = nameofdvd Return dvd End If Next End Method End Type Type TDVD Field name:String Field year:String End Type ' Main Local mydatabase:TDatabase = New TDatabase ' create a new database mydatabase.AddDVD("Matrix", "1999") ' add some data Local movie:TDVD = mydatabase.FindDVD("Matrix") ' search database for movie Matrix Print movie.year |