How to cal code from another card/stack

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
neatgadgets
Posts: 17
Joined: Sat Dec 21, 2013 12:14 pm

How to cal code from another card/stack

Post by neatgadgets » Tue Dec 23, 2014 8:54 am

I was wanting to have database connection and disconnection code in a stack (or card) and be able to call it from any card. I've found a number of options but none seem to work.

Example:

on dbConnect
insertcode here
end dbConnect

to call it I have tried

call dbConnect from card "cardname"

I also tried just calling it given the card should be able to access anything in the stack

SparkOut
Posts: 2943
Joined: Sun Sep 23, 2007 4:58 pm

Re: How to cal code from another card/stack

Post by SparkOut » Tue Dec 23, 2014 11:13 am

if you have th dbConnect handler in the stack script, then from any card in the stack, you can just:
dbConnect
as a statement which will fire a message to seek the dbConnect handler.

No need for "call" or "from". For great information about how the message path works, see: http://www.fourthworld.com/embassy/arti ... _path.html

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10305
Joined: Wed May 06, 2009 2:28 pm

Re: How to cal code from another card/stack

Post by dunbarx » Tue Dec 23, 2014 3:00 pm

Hi.

What Sparkout said about just sending the message "dbConnect".

But read the dictionary entry on "call". The syntax does not allow the use of the word "from". Rather, it requires either no object identifier, or "of" and a valid identifier.

The danger of LC is that the language is so English-like, that it appears that what is logically and grammatically correct should also be syntactically correct. Not often, as we see here.

Craig Newman

Post Reply