Add card to stack
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Add card to stack
How do I add a new card to a substack using a "new" button on mainstack?
Re: Add card to stack
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
After this handler has executed, the defaultStack should revert to your main stack.
Kind Regards,
Neil Roger
--
RunRev Support Team ~ http://www.runrev.com
-
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
thx.
Ill try to make it work
Ill try to make it work
Re: Add card to stack
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?
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
Looks OK! How did you fill the variable cName?appmann wrote:I tryed to set cName of mainstack to the text from the field. Then "create card cName of stack "ProfilesSub"".
Re: Add card to stack
Oh, completely overlooked that one: Please use the syntax, that Neil provided! 

Re: Add card to stack
i use Set the cName to field "name"
Re: Add card to stack
...
put fld "name" into cName
## Just like you surely did several times before to PUT something INTO a variable
...
put fld "name" into cName
## Just like you surely did several times before to PUT something INTO a variable

...
Re: Add card to stack
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?
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
You are not putting content into a variable here, but you create a custom property of your stack named "cWhee"!set the cWhee of this stack to fld "fieldname"
As I wrote earlier:
...
put fld "fieldname" into cWhee
set the defaultStack to "substack"
create card cWhee
...
This will do what you want!

Re: Add card to stack
Thx a lot Klaus. Again.
Can u explain when to use set the cName and put into the cName?
What is the difference?
Can u explain when to use set the cName and put into the cName?
What is the difference?
Re: Add card to stack
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
...
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
thx for the explanation Klaus.
That make a lot sence.
Your way to explain actually make the basic understanding a lot easyer.
That make a lot sence.
Your way to explain actually make the basic understanding a lot easyer.