Add card to 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
appmann
Posts: 33
Joined: Wed Oct 09, 2013 9:08 pm

Add card to stack

Post by appmann »

How do I add a new card to a substack using a "new" button on mainstack?
LCNeil
Livecode Staff Member
Livecode Staff Member
Posts: 1223
Joined: Wed Oct 03, 2012 4:07 pm

Re: Add card to stack

Post by LCNeil »

Hi Appmann,

To do this you must first set the defaultStack property to your substack and then create a new card.

An example of this in a button is

Code: Select all

on mouseUp
   set the defaultStack to "mySubstack"
   create card "this is a test"
end mouseUp

After this handler has executed, the defaultStack should revert to your main stack.

Kind Regards,

Neil Roger
--
RunRev Support Team ~ http://www.runrev.com
-
appmann
Posts: 33
Joined: Wed Oct 09, 2013 9:08 pm

Re: Add card to stack

Post by appmann »

thx.

Ill try to make it work
appmann
Posts: 33
Joined: Wed Oct 09, 2013 9:08 pm

Re: Add card to stack

Post by appmann »

when i create the new card of substack, I want to name it with the info from a field on my mainstack. How does this work?

I tryed to set cName of mainstack to the text from the field. Then "create card cName of stack "ProfilesSub"".

Do i have to create the card and give it a random name, before i change the name to text from field?
Klaus
Posts: 14324
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Add card to stack

Post by Klaus »

appmann wrote:I tryed to set cName of mainstack to the text from the field. Then "create card cName of stack "ProfilesSub"".
Looks OK! How did you fill the variable cName?
Klaus
Posts: 14324
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Add card to stack

Post by Klaus »

Oh, completely overlooked that one: Please use the syntax, that Neil provided! 8)
appmann
Posts: 33
Joined: Wed Oct 09, 2013 9:08 pm

Re: Add card to stack

Post by appmann »

i use Set the cName to field "name"
Klaus
Posts: 14324
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Add card to stack

Post by Klaus »

...
put fld "name" into cName
## Just like you surely did several times before to PUT something INTO a variable 8)
...
appmann
Posts: 33
Joined: Wed Oct 09, 2013 9:08 pm

Re: Add card to stack

Post by appmann »

I really cant make this work

Im trying to:
take som text from a field on my mainstack and put it into the name of a new card of substack, just created.

i did this:
set the cWhee of this stack to fld "fieldname"
set the defaultStack to "substack"
create card cWhee

I want to put the string into a variable cWhee (or something else), to use later in the same script.

I tryed to put the fieldname into the cWhee but it didnt work either.
the code does set the defaultstack to substack and also creates a new card. But it sets the name to cWhee. ???

Is´it possible to set a variable on mainstack and use it on substack?
Klaus
Posts: 14324
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Add card to stack

Post by Klaus »

set the cWhee of this stack to fld "fieldname"
You are not putting content into a variable here, but you create a custom property of your stack named "cWhee"!

As I wrote earlier:
...
put fld "fieldname" into cWhee
set the defaultStack to "substack"
create card cWhee
...
This will do what you want! 8)
appmann
Posts: 33
Joined: Wed Oct 09, 2013 9:08 pm

Re: Add card to stack

Post by appmann »

Thx a lot Klaus. Again.

Can u explain when to use set the cName and put into the cName?

What is the difference?
Klaus
Posts: 14324
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Add card to stack

Post by Klaus »

Hi appman,

...
put "Whatever" into this_or_that
...
Will PUT content into a variable or object

...
set THE cWhatever OF (object reference) to any_value
...
Will put -> any_value into the custom property named cWhatever of whatever object you supply.

A custom property is similar to a variable (but its neither local or global) and is TIED to a specific Livecode object,
be it stack/card/field/button or whatever.

But it can be accessed form anyhwere in your current LC session:
...
put the cMyProp of stack "not the current stack" into myvalue
...

The main difference is that a CP will be SAVED with the stack, so the values are not temporary if you want them to.


Best

Klaus
appmann
Posts: 33
Joined: Wed Oct 09, 2013 9:08 pm

Re: Add card to stack

Post by appmann »

thx for the explanation Klaus.

That make a lot sence.

Your way to explain actually make the basic understanding a lot easyer.
Post Reply