1 Attachment(s)
Re: Feeling nostalgic I fired up QuickBASIC and wrote a Brain***** interpreter!
Okay, after putting it off for a while I got around to having a look at that Bookgen example in order to figure out what exactly ISAM is.
I attached a copy of the example to this post. I did strip out most comments because I feel they make the code inreadable in this case and I can always refer to the original example and online help in the IDE in this case.
A quick look at the code gives me the strong impression that the example provided by Microsoft is a bit overdeveloped, I really don't like it when bells and whistles are crammed into an example that aren't really related to what the example is supposed to demonstrate. The Bookgen example, is meant to demonstrate ISAM but has an entire IDE attached to it as well and well, comments are all nice and dandy but every little bit of code had been documented. You'd think someone who wants to learn about ISAM would know the essentials of BASIC programming and how to use the online help. *sigh*. Any way back on topic, here are some code snippets:
Code:
OPEN "BOOKS.MDB" FOR ISAM Books "BookStock" AS cBookStockTableNum
Which looks a lot like a slightly more advanced version of the "OPEN ... FOR RANDOM " and "GET/PUT" record based features of earlier BASIC dialects. The next snippet:
Code:
TYPE Books
IDnum AS DOUBLE
Price AS CURRENCY
Edition AS INTEGER
Title AS STRING * 50
Publisher AS STRING * 50
Author AS STRING * 36
END TYPE
It looks like any data is defined by the structure above. And this is what an operation on said data looks like:
Code:
INSERT cBookStockTableNum, BigRec.Inventory
Not really all that complicated, but it will take me some time to really figure this out. I will probably build a small ISAM based app myself in VBDOS and call it a day.
PS:
And speaking of overwritten, VBDOS's online help is wonderful but does tend to throw a lot of info at the user all at once too, imho. :-)
PS PS:
The Bookgen example uses the *.mdb extension for its "database" file, don't read too much into that, it doesn't appear to be even remotely compatible with Microsoft Access. :-)
PS PS PS:
Qbx 7.1 (or whatever you want to call it) also supports ISAM. It's online help appears to be less cluttered than VBDOS's but its demo's state I have to first build a new library from other libraries first. Probably not worth the effort given that I suspect those demo's will demonstrate essentially the same as those in VBDOS.
Re: Feeling nostalgic I fired up QuickBASIC and wrote a Brain***** interpreter!
I see a few people downloaded the example I posted! :-)
According to this thread: http://www.petesqbsite.com/phpBB3/viewtopic.php?t=1098 - qbx's 7.1's ISAM (and therefore VBDOS) isn't truly a database system but more some kind of file access method. One that produces files that are hardly compatible with any database software at that. Still I am curious to learn more about it. It might provide some clues as to how other old DOS software managed their data, which could be fun to investigate.
Anyway, it gives me an excuse to indulge in playing with VBDOS. :-)
3 Attachment(s)
Re: Feeling nostalgic I fired up QuickBASIC and wrote a Brain***** interpreter!
Okay, I briefly glanced over the command line utilities provided with VBDOS and does seem there are utilities for conversions between other databases and its ISAM (pseudo?-) database files.
Attached to this post are three pages from VBDOS's online help printed to a text file which seem most relevant atm. They're best viewed with a fixed-width font that supports box drawing ASCII characters such as Terminal and word-wrapping disabled in Notepad or similar editor.
Also, I found some interesting debugging utiltiies which distracted me, but those could be useful to investigate how VBDOS programs work internally. I know a bit about assembly language, it's probably going to be tedious even with a good debugger. :-)
Re: Feeling nostalgic I fired up QuickBASIC and wrote a Brain***** interpreter!
Success!
Code:
OPTION EXPLICIT
DEFINT A-Z
TYPE NumberStr
Number AS STRING * 10
END TYPE
DECLARE SUB CreateDataBase (Numbers() AS NumberStr)
DECLARE SUB DeleteNumberTable ()
DECLARE SUB DisplayDatabase ()
DECLARE SUB ReadNumberList (Numbers() AS NumberStr)
DIM Numbers() AS NumberStr
CLS
DeleteNumberTable
ReadNumberList Numbers()
CreateDataBase Numbers()
DisplayDatabase
END
NumberList:
DATA "zero"
DATA "one"
DATA "two"
DATA "three"
DATA "four"
DATA "five"
DATA "six"
DATA "seven"
DATA "eight"
DATA "nine"
DATA "ten"
DATA "*"
SUB CreateDataBase (Numbers() AS NumberStr)
DIM FileH AS INTEGER
DIM Index AS INTEGER
FileH = FREEFILE
OPEN "Numbers.mdb" FOR ISAM NumberStr "NumberTable" AS FileH
FOR Index = LBOUND(Numbers) TO UBOUND(Numbers)
INSERT #FileH, Numbers(Index)
NEXT Index
CLOSE FileH
END SUB
SUB DeleteNumberTable ()
ON LOCAL ERROR RESUME NEXT
IF NOT DIR$("Numbers.mdb") = "" THEN
DELETETABLE "Numbers.mdb", "NumberTable"
END IF
END SUB
SUB DisplayDatabase ()
DIM FileH AS INTEGER
DIM Index AS INTEGER
DIM NumbersInDatabase(0 TO 0) AS NumberStr
FileH = FREEFILE
OPEN "Numbers.mdb" FOR ISAM NumberStr "NumberTable" AS FileH
DO
RETRIEVE #FileH, NumbersInDatabase(UBOUND(NumbersInDatabase))
MOVENEXT FileH
IF EOF(FileH) THEN
EXIT DO
END IF
REDIM PRESERVE NumbersInDatabase(LBOUND(NumbersInDatabase) TO UBOUND(NumbersInDatabase) + 1) AS NumberStr
LOOP
CLOSE FileH
FOR Index = LBOUND(NumbersInDatabase) TO UBOUND(NumbersInDatabase)
PRINT NumbersInDatabase(Index).Number
NEXT Index
END SUB
SUB ReadNumberList (Numbers() AS NumberStr)
RESTORE NumberList
REDIM Numbers(0 TO 0) AS NumberStr
DO
READ Numbers(UBOUND(Numbers)).Number
IF RTRIM$(Numbers(UBOUND(Numbers)).Number) = "*" THEN
REDIM PRESERVE Numbers(LBOUND(Numbers) TO UBOUND(Numbers) - 1) AS NumberStr
EXIT DO
END IF
REDIM PRESERVE Numbers(LBOUND(Numbers) TO UBOUND(Numbers) + 1) AS NumberStr
LOOP
END SUB
It creates and displays a simple database with a single table! No extras, just the basics. :-) Of course this program is rather rough around the edges and a true data management program would be far more complex with more safeguards and what not.
Run PROISAMD.EXE before trying to run it first.
Re: Feeling nostalgic I fired up QuickBASIC and wrote a Brain***** interpreter!
Up next, something else I never really got, those financial functions. To be honest I never really got much deeper into that than adding income and subtracting expenses and how your interest increases as you accumulates as long as your balance does.
I never really got why BASIC would provide fancy financial calculation functions in later BASIC dialects. While Visual Basic for DOS is pretty close to being a really good programming language imho, would anyone in their right mind do any serious financial calculations with it? It is still BASIC, no matter how many fancy features you stuff it with. :-)
Re: Feeling nostalgic I fired up QuickBASIC and wrote a Brain***** interpreter!
Re ISAM. The beauty of ISAM is that you can create a file with multiple indexes and use these indexes to quickly locate required record(s). So from the TYPE in post #61 you might have an ISAM file with indexes for Publisher, Author etc so that extracting all books for specific author(s) or publisher(s) would be quick as it would not require a full database search. Once established the maintenance of these indexes would be automatic without specific user code being needed. You won't see the benefit of this method for a file with just a few records, but when you have tens of thousands of records you can easily see the time difference between accessing an indexed field to one which isn't indexed.
Re: Feeling nostalgic I fired up QuickBASIC and wrote a Brain***** interpreter!
@2kaud: I suspect that this ISAM if used properly is indeed a pretty solid way of managing large amounts of data. The BookGen example which I complained about as being overly complex probably demonstrates that better than the tiny program I uploaded. However, I believe my code better gets the basics of how to use ISAM across. Also, I believe the user complaining on PetesQb site (link is somewhere in this thread) got a bit overwhelmed by the online-help, like me, and in his rush to get something done overlooked the conversion command line utility which does seem to support actual database systems that were popular. ISAMIO appears to support BTrieve for example and dumping to a text file also is possible. In fact you could do that manually with some code if you really wanted/needed to. Anyway, I just really wanted to know what this whole thing about ISAM in BASIC was all about. Now I know and unless I feel like building some kind of database manager for fun, which I don't I am not going to investigate it further.
I briefly considered the possiblity there might be some older programs using a format compatible with BASIC's ISAM, but I doubt there'd be that many. Also, if there were any, I'd still need to guess how they structured their data, or would I? In fact, while I feel I now know enough about what ISAM is, I am still curious as to what exactly is stored in the files created with it and what isn't.
Anyway, I feel like leaving it at that and looking at the finance related functions because I never really got what those were for either.
Re: Feeling nostalgic I fired up QuickBASIC and wrote a Brain***** interpreter!
Alright, I had a first real look at those financial functions... They all return double precision floating numberic values! Isn't that asking for the last thing you would want while doing financial calculations? Rounding errors when large numbers are involved? Why did they even add the currency datatype to begin with in that case? Worst of all, vb6 happily uses double precision values too for supposedly financial calculations too.
And before anyone points this out, yes before I knew better I tried developing a few programs for keeping track of finances and used the double datatype which means those programs are worthless in the practical sense except for trivial calculations. Heck, you'd be better off using Microsoft Excel. :-)
Anyway, I still am curious what those functions do. :-)
Re: Feeling nostalgic I fired up QuickBASIC and wrote a Brain***** interpreter!
Okay, I have looked at those financial functions, nothing more than highly specialized bookkeeping stuff imho. Not really worth looking at any further.