Post
by sturgis » Sat Sep 13, 2014 5:43 pm
Actually, relative pathing may not be such a good idea. If the executable is going to be available to all users, that means it will be in /bin or /sbin or.. somewhere in the path, and its doubtful that a regular user will have write rights to that folder. If its only in userspace, then not such a big deal.
I'm wondering, what permissions are set on the file and folder that are created. They SHOULD be user writable but it doesn't hurt to check.
One other thing you might do is to adjust (just for testing) how you are creating the folder and file.
So, you might.., set the defaultfolder to "~/Documents"
create the folder (no pathing needed, you're already in the right spot due to setting the defaultfolder)
and then pop up a dialog listing "the folders"
Then set the defaultfolder to "~/Documents/yourFolderName"
and try to create the database. Again, no pathing needed, just the filename because you're already sitting in the correct folder (having set it to the defaultfolder)
then pop up a dialog to list the files.
Also, and probably the best method to sort this out (having thought about it while typing) your code doesn't check your tDbaseId after doing the revdatabaseopen() If the db wasn't created, the variable you used will contain an error message, and in fact, you should always do a check after trying to open the database.
something like..
put revopendatabase("sqlite",tpath,,,,) into tTempId
if tTempId is not an integer then
answer information "There was an error: " && tTempId"
else
answer information "Database created with ID: " && tTempId
put tTempId into tDbaseId
end if
This way, if an error occurs it'll pop up the dialog and show you the error. Otherwise, if it worked it will tell you the ID and put the id into a more permanent variable. You might also look at naming conventions. It helps if you name your variables in ways that indicate their scope. Many people name temp vars (handler only, then gone) with a preceeding t tTempVar Globals with a g
and script locals (persistent in the script) with an s. Makes it SO much easier to keep track of things.