i1neal@exnet.iastate.edu (Neal Rauhauser -- ELT Computer Applications Group) (01/07/91)
Here it is, follow the directions in comments and see if it works for
you - it certainly fails on any machine I try it on.
-- this code goes in the script for the book you are
-- going to use
-- don't forget to use the command window to "send enterbook"
-- after you enter this code
-- link the dll's we are going to use for this demo
to handle enterbook
linkdll "TBKFILE.DLL"
INT fileExists(STRING)
end linkdll
linkdll "TBKDB3.DLL"
STRING getDBErrorString(INT)
INT closeDBFile(STRING)
INT openDBFile(STRING)
end linkdll
end
-- cleanup after ourselves on exit
to handle leavebook
unlinkdll "TBKDB3.DLL"
unlinkdll "tbkfile.dll"
end leavebook
--place this code in a button
--
-- try this with and without a dBase file called test.dbf
-- in your root directory
-- content or structure of the dbase file matters not
to handle buttonup
-- see if the file exists
get fileExists("c:\test.dbf")
-- any toolbook return value that doesn't go to a specific
-- variable is put in the global variable IT
-- in this case, IT contains the return value of
-- the above function invocation
-- fileExists returns a 1 if the file is there
if IT <> 1
request "The file does not exist."
else
request "The file exists."
end
-- now see what the dBase DLL has to say about this nonexistent
-- file
get openDBFile("c:\test.dbf")
-- this shows a popup requestor containing the string returned by
-- getDBErrorString(). IT contains the error code returned by
-- openDBFile()
request getDBErrorString(it)
end buttonup