How to create a new card in a other stack ?[Solved]

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
atout66
Posts: 266
Joined: Wed Feb 02, 2011 12:31 pm

How to create a new card in a other stack ?[Solved]

Post by atout66 » Wed Jun 03, 2015 2:01 pm

Hello friends,

I'd like to create a new card in a other stack whithout to go there.
I've seen in the dictionnary that the create command creates objects in the current card. That's not what I'm looking for.
I want to create a new card in a specific stack which I know the name. For example, this code below returns an error:

Code: Select all

create card laCardCreation to stack leTypeDeStack 
but you get the idea...
Untill now, I was on a test process, and so, I was used to go from the card source to the last card target, create the new card there, create the fields of the new card, fill them, etc. and then, back to the card source.
This process is too long for me now, as I've 774 cards to create and fill !
If you know a better way to do that, please let me know ;-)

Regards, Jean-Paul.
Last edited by atout66 on Thu Jun 04, 2015 7:35 am, edited 1 time in total.
Discovering LiveCode Community 6.5.2.

Klaus
Posts: 14267
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: How to create a new card in a other stack ?

Post by Klaus » Wed Jun 03, 2015 2:08 pm

Hi Jean-paul,

you need to set "the defaultstack"!
This will do the trick:
...
set the defaultstack to "name of your other stack here"
create cd "name of new card"
...

Best

Klaus

atout66
Posts: 266
Joined: Wed Feb 02, 2011 12:31 pm

Re: How to create a new card in a other stack ?

Post by atout66 » Wed Jun 03, 2015 2:47 pm

Thanks Klaus, I give a look, but I'm afraid it doesn't work, because the dictionnary says:
Value:
The defaultStack is the name of an open stack.

My problem is that I proceed from the main stack and the others are not open.
In fact, I've to build the content of the application now that the interface is done.
But I try first to see, who knows...

Regards, Jean-Paul.
Discovering LiveCode Community 6.5.2.

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

Re: How to create a new card in a other stack ?

Post by dunbarx » Wed Jun 03, 2015 3:06 pm

Hi.

That is misleading. The use of the defaultStack usually refers to the topmost stack, but it does not have to.

Make two stacks. Name one "AA" and the other "BB". Save both. In a button on "AA":

Code: Select all

on mouseUp
   set the defaultStack to "longNameOfStackBB" --you understand this, right?
   create card
end mouseUp
Now quit LC. Open stack "AA" and hit the button. If you now go to stack "BB", you will find a new card there.

Craig Newman

atout66
Posts: 266
Joined: Wed Feb 02, 2011 12:31 pm

Re: How to create a new card in a other stack ?

Post by atout66 » Wed Jun 03, 2015 3:16 pm

dunbarx wrote:That is misleading...
This sounds nice. I'll give it a try in two hours, when the calculations of LC will finish.

I'll let you know ;-)

Regards, Jean-Paul.
Discovering LiveCode Community 6.5.2.

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

Re: How to create a new card in a other stack ?

Post by SparkOut » Wed Jun 03, 2015 7:56 pm

When I get a chance (using phone here) I will check, but that is interesting. When you create a card it normally becomes the active card. Does it not force the destination stack open to become active?
I have always created new cards in the current stack, and had to lock screen, and revert to the original card in order to simulate "silently" creating a new card.
(Using "invisible" has never worked for cards for me)

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

Re: How to create a new card in a other stack ?

Post by dunbarx » Wed Jun 03, 2015 8:22 pm

Sparkout.

Try it. The target stack does not appear in the stacksInUse. It never seems to rear its head.

But note that just because you can create a new card on that remote stack, those new cards will not stick unless you save that stack. So in a sense, you very well may have to "go" there, even if only to save the stack by specifying its pathname:

Code: Select all

save stack "yourPathNameHere"
Craig
Last edited by dunbarx on Thu Jun 04, 2015 2:42 pm, edited 1 time in total.

atout66
Posts: 266
Joined: Wed Feb 02, 2011 12:31 pm

Re: How to create a new card in a other stack ?

Post by atout66 » Thu Jun 04, 2015 7:33 am

I did the test and it works very well, even more than what I expected :wink:
I can do all the process on the same card all the time and let the machine populate the cards; great ;-)
Thanks a lot to all of you for your help, this forum is fantastic !

Regards, Jean-Paul.
Discovering LiveCode Community 6.5.2.

Post Reply