I've got a main stack file with a number of cards. I've also got a substack within that file called Scripts and a card within that substack called ScriptUtils and I plan to paste all the reusable code snippets in there. Two of the main handlers I have are the following database.
Code: Select all
global gConnID -- connection ID
command GetDatabaseID
put the effective filename of this stack into filepath
set the itemdelimiter to slash
put "mydb.sqlite" into the last item of filepath
put revOpenDatabase("sqlite", filepath,,,,,,) into gConnID
answer gConnID
end GetDatabaseID
on CloseDatabaseID
if (gConnID > 0) then
revCloseDatabase gConnID
end if
end CloseDatabaseID
Code: Select all
global gConnID
local sInitializedFlag
on openStack
if sInitializedFlag is not true then
start using stack "Scripts"
put true into sInitializedFlag
end if
pass openStack
GetDatabaseID
end openStack