|
Post by Clark-O on Jun 5, 2002 17:21:20 GMT
hi everyone. this is my goal:
I need to create a Qbasic program that will run on a QuickPad PRO. It will be used to store and manage records from a central database. Each night the field devices (quickpad pros) will synch to the server by modem and synch files. We have all the records in an Access2K database.
The only way to do what i need is to store records in CSV (comma seperated value) files. my only problem with this is that i'm not sure how to work with the records in qbasic. i have extended QBasic 7.1 and noticed the ISAM function. Has anyone used it before? Has anyone worked with a database on qbasic before?
|
|
|
Post by brisray on Jun 6, 2002 22:15:46 GMT
I've used databases with QBasic quite extensively. I use v1.1 which doesn't use ISAM, but here's a way of opening CSV files. The fields inside test.csv were RecordNo, Title, Initial, Surname, Address 1, Address 2, Address 3, Address 4, Serial No, and Occupation. CLS OPEN "C:\testcsv\test.csv" FOR INPUT AS #1 WHILE NOT EOF(1) INPUT #1, RecNo$, Title$, Init$, Surname$, Add1$, Add2$, Add3$, Add4$,SerNo$,Occ$ PRINT RecNo$, Title$, Init$, Surname$, Add1$, Add2$, Add3$, Add4$, SerNo$,Occ$ WEND CLOSE This will work whether or not there are quotes around each field in the database, i.e. it copes with "thisdata","thatdata" or thisdata,thatdata. Which is why all the fields are defined as strings in the code above. My website shows some of the disadvantages of using CSV files (commas inside the data etc.) at members.lycos.co.uk/brisray/qbasic/qfile.htmOnce you've gotten the data into the variables you can add them to arrays, change them to numerics, rewrite them back to a file, whatever you want to do with them. You can define each field using DIM before you use it, but remember if you haven't left enough space for the data inside that variable the data will be truncated. You can also use the TYPE command, TYPE MyStruct RecNo AS STRING * 5 Title AS STRING * 15 Init AS STRING * 10 Surname AS STRING * 30 Add1 AS STRING * 30 Add2 AS STRING * 30 Add3 AS STRING * 30 Add4 AS STRING * 10 SerNo AS STRING * 10 Occ AS STRING * 30 END TYPE DIM InRec AS MyStruct CLS OPEN "C:\testcsv\web3.csv" FOR INPUT AS #1 WHILE NOT EOF(1) INPUT #1, InRec.RecNo, InRec.Title, InRec.Init, InRec.Surname, InRec.Add1, InRec.Add2, InRec.Add3, InRec.Add4, InRec.SerNo, InRec.Occ Print InRec.RecNo, InRec.Title, InRec.Init, InRec.Surname, InRec.Add1, InRec.Add2, InRec.Add3, InRec.Add4, InRec.SerNo, InRec.Occ WEND CLOSE This is especially useful if you have mixed numeric and string data in your database. Ray
|
|
|
Post by brisray on Jun 6, 2002 22:23:38 GMT
I forgot something,
QBasic is fine for database work, I've processed files of 4 million + records with it. The only thing wrong with it is that if you plan to do a lot of processing you really need a faster, more powerful database programming language.
I've found that with large DBs both Access and Excel have VERY severe problems. Neither manage very large files or memory at all well. Visual Foxpro is great, I certainly recommend it if you are doing a lot of DB work.
Ray
|
|