BBS: Inland Empire Archive Date: 01-09-93 (04:55) Number: 344 From: WES GARLAND Refer#: NONE To: RICK NEWMAN Recvd: NO Subj: DATABASE STRUCTURE Conf: (2) Quik_Bas
'=======CONTINUED FROM PREVIOUS MESSAGE=======
Function GetRecipe$ (Handle as integer, RHdr as RecipeType)
' Gets a recipe starting at the current file position
Dim Str as string
Str = string$(0,len(RHdr)) ' Creates a string the length of the header,
' filled with nulls. Args MIGHT
be reversed.. :-) Get Handle, ,Str
StrToType (Str, RHdr) ' Read in the RecipeHeader
Str = string$(0,RHdr.RecipeLen)
Get Handle, ,Str ' Read in the recipe. NOTE! The recipe CANNOT
' be longer than the max size of a string using
' this exact method. I THINK
that's about 11K.. :) GetRecipe = Str
End FUNCTION
' Main Code starts here...
Handle = FREEFILE
open "recipes.dat" for binary as Handle
' First, we'll view a recipe
For N=1 to 3 ' Lets view the third recipe
Temp = GetRecipe (Handle, RecipeHeader)
' Its not really computer-sciencely correct to have a function
' return TWO values - the result and RecipeHeader, but what the
' hell. Convert to a sub if you're feeling useless. :-) Next N
print "Title: "+RecipeHeader.Title
print "Keywords: "+RecipeHeader.KeyWord1 + ",
"+RecipeHeaderKeyWord2 print string$("-",79) ' Prints 79
minusses. Args might be reversed? print Temp
' Now, we'll write one!
seek (Handle,LOF(Handle)) ' Go to the end of the file. Not
sure about Syntax input "Recipe Name: ",RecipeHeader.Title
input "Keyword 1: ",RecipeHeader.KeyWord1
input "Keyword 2: ",RecipeHeader.KeyWord2
' INSERT YOUR EDITOR HERE. MAYBE A SHELL, WITH Q.EXE LOADED IN, THEN
' COPIED FROM A TEMP FILE TO A VARIABLE, USING THE LOF() COMMAND TO
' CALCULATE THE LENGTH OF THE RECIPE
' Write routine expects the recipe in Str, and recipe length in FileLen
RecipeHeader.RecipeLen = FileLen
Temp = TypeToStr(RecipeHeader)
Put Handle, ,Temp
Put Handle, ,Str
close Handle
print "Hello, World!"
Let me know if you find any of this useful. Thanks to Scott
Dudley for writing the Max IPC page routines in a format
eerily similar to this :-)
Cheers,
Wes
PS: This is just off the top of my head, so there are likely syntax errors
all over the place, and maybe a bug or two. Check your manual for
details! :-)
--- Maximus 2.01wb
* Origin: Terminal Velocity Kingston *CANADA* (613)542-4613/6594, (1:249/128)

Books at Amazon:
Back to BASIC: The History, Corruption, and Future of the Language
Hackers: Heroes of the Computer Revolution (including Tiny BASIC)
Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution
The Advent of the Algorithm: The Idea that Rules the World
Moths in the Machine: The Power and Perils of Programming
Mastering Visual Basic .NET