Question

I have a script in a stack called "loader" and I want to create a new card in another stack called "theData". If I just use create card the cards are created in the stack "loader". How do I specify that the new card is created in the stack "theStackName"?

Something like

on mouseUp
   put field "theStackName" into tStack

   create stack tStack with background "BGdata"
   -- the background "BGdata" which has been defined before
   -- contains a field "data"

   set the defaultStack to tStack

   put "something" into field "data"

   create card
   put "somethingElse" into field "data" 
end mouseUp
Was it helpful?

Solution

A few ways to do this, all using the create card command.

Method 1

You can navigate to the target stack, perhaps locking the screen so that nothing changes visibly, and create the card there. This has the advantage of being able to create the new card anywhere in the target stack, which might already have several cards. You can then always return to your starting place, if you want to.

or you can:

Method 2

set the defaultStack to "theData"
create card

Sort of the same thing.

OTHER TIPS

Where did the field "data" come from? It would not be present in a newly created stack.

When you create a new stack, it becomes the topmost, or default stack. So you cannot just put something into a field unless you first create that field.

I assume your error was something like:

execution error... (Chunk: no such object) near "data".

If you are creating new stacks as well as new cards in a remote stack, well and good. Experiment with all this. Write back if you get stuck.

Craig Newman

To my knowledge there is no way to create objects in stacks without being in that stack. I would do something like this after you have created the new stack:

push card
lock messages
lock screen # optional but probably a good idea
go invisible stack "mynewstack"
create card "foo"
# at this point you'll be on that card
create field "data"
put "stuff" into field "data"
group field "data"
set the name of field "data" to "bgData"
pop card
unlock messages
unlock screen

So in essence you're going to the new stack and doing stuff behind the user's back. But it's fast and should seem instantaneous.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top