SOLVED - How do you carry variable from stack to sub stack?

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
admin12
Posts: 412
Joined: Wed May 11, 2011 9:47 am

SOLVED - How do you carry variable from stack to sub stack?

Post by admin12 » Sat Jul 30, 2011 10:26 pm

Hello all,

How do you carry a global variable from one stack to a substack?

I have this set of commands on every page of every stack in my project:

on opencard
--Create a global variable for the db
global dbID
global curUserID
global UN

put numtochar(39) into SQ

I then proceed to login to the database (works fine normally) and then access whatever data I need.

I just created a substack called CV with three pages - pgCV1, pgCV2 and pgCV3

I need the login credentials of the user to carry over so the fields on these pages can be populated with the existing data on the database.

The important variable is dbID and curUserID

What do I need to do, other than the global command, to make this happen?

Mike

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

Re: SOLVED - How do you carry variable from stack to sub stack?

Post by dunbarx » Sun Jul 31, 2011 6:42 pm

Globals are valid across any LC session, however you need it. You must declare it in the scripts that you use, however.

So if you have a handler in your mainstack:

Code: Select all

global ccc

on mouseUp
   put 5 into ccc
end mouseUp
And run this in your substack

Code: Select all

global ccc

on mouseUp
   answer ccc
end mouseUp
You are done. Globals are sometimes overused. After you get the hang of them, look into custom properties.

Craig Newman

Post Reply