Page 1 of 1

Add card to stack

Posted: Fri Oct 18, 2013 2:39 pm
by appmann
How do I add a new card to a substack using a "new" button on mainstack?

Re: Add card to stack

Posted: Fri Oct 18, 2013 2:49 pm
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
-

Re: Add card to stack

Posted: Fri Oct 18, 2013 2:51 pm
by appmann
thx.

Ill try to make it work

Re: Add card to stack

Posted: Fri Oct 18, 2013 6:08 pm
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?

Re: Add card to stack

Posted: Fri Oct 18, 2013 6:11 pm
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?

Re: Add card to stack

Posted: Fri Oct 18, 2013 6:13 pm
by Klaus
Oh, completely overlooked that one: Please use the syntax, that Neil provided! 8)

Re: Add card to stack

Posted: Fri Oct 18, 2013 8:21 pm
by appmann
i use Set the cName to field "name"

Re: Add card to stack

Posted: Fri Oct 18, 2013 8:34 pm
by Klaus
...
put fld "name" into cName
## Just like you surely did several times before to PUT something INTO a variable 8)
...

Re: Add card to stack

Posted: Sun Oct 20, 2013 1:19 pm
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?

Re: Add card to stack

Posted: Sun Oct 20, 2013 1:31 pm
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)

Re: Add card to stack

Posted: Sun Oct 20, 2013 6:52 pm
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?

Re: Add card to stack

Posted: Mon Oct 21, 2013 11:51 am
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

Re: Add card to stack

Posted: Mon Oct 21, 2013 11:58 am
by appmann
thx for the explanation Klaus.

That make a lot sence.

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