Newbie question

Jim Bufalini jim at visitrieve.com
Sat May 16 11:50:16 EDT 2009


John Hunter wrote:

> I'm looking at Rev and RB and was wondering if there are any samples /
> demo stacks that show how to use sqlite databse without using buttons
> to create or connect to.
> It would be really helpful to see how to create / connect to sqlite
> databases using code as opposed to buttons.

Hi John,

What Joe said is correct. Just to expand on what he said...

When you click on a button it generates a mouseUp message. So let's say you
create a command like:

On OpenMyDatabase
 get revOpenDatabase("sqlite", "C:/testdbsqlite.db", , , , ) -- right from
the docs on opening an SQLite DB
End OpenMyDatabase

Or:

On OpenMyDatabase pDataBasePathAndName
 get revOpenDatabase("sqlite", pDataBasePathAndName, , , , )
End OpenMyDatabase


Then, on the mouseUp handler of the button, you could have:

On mouseUp
  OpenMyDatabase -- executes your OpenMyDatabase command on the click of the
button
End mouseUp

But there are many actions that generate messages like opening a stack
(preOpenStack and OpenStack) and opening a card (preOpenCard and openCard)
as well as mouse movements and all manner of actions. You can hook your
OpenMyDatabase into any message, not just the messages associated with a
click on a button.

So, you can hook your OpenMyDatabase command into any message. For example,
if you want to open the database when your stack first launches, you could
have:

On preOpenStack
  OpenMyDatabase "c:\WhateverDirectory\WhateverDBName.db" --Calls
OpenMyDatabase with a PC path & name of the SQLite DB.
End preOpenStack

This would open the database as soon as your stack launches and before it
displays.

Hope these examples help. Look at the Rev dictionary for type "message" to
see all the different places you can hook your own code into.

Aloha from Hawaii,

Jim Bufalini





More information about the use-livecode mailing list