Creating field at runtime in a new card

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

Creating field at runtime in a new card

Post by atout66 » Sat Apr 05, 2014 6:22 pm

Hi to all (again :!: ),

From the main stack, I send a mouseUp handler to a button. It creates a new card, name it, in a existing other stack. 'till now, every thing is OK.
All the variables are correct. I can notice the new card created, with its new name in the right stack in the Application Browser.
Here is the piece of code with problem:

Code: Select all

go to card laCardCreated -- the card just created
send "createTheField leNomDuField,laCardCreated ,leNomDeLaStack" to me
-- ...
on createTheField leNomDuField,laCardCreated ,leNomDeLaStack
   create field leNomDuField in card laCardCreated -- of stack leNomDeLaStack -- with or without <leNomDeLaStack > doesn't change anything
I always get the error message: (Chunk: can't find card), char 17.
LC don't find the card while I can see its name in the browser !?!
Any idea may be ?

Kind regards.
Discovering LiveCode Community 6.5.2.

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

Re: Creating field at runtime in a new card

Post by Klaus » Sat Apr 05, 2014 6:50 pm

Bonsoir atout66,

try this:

Code: Select all

...
go to card laCardCreated -- the card just created
## Whatever you do now, the target will be that card in that stack -> laCardCreated
## That means you should not supply and use the name of the card in your "createTheField" handler
## In fact "create xyz" does not even  allow to also supply a cardname as parameter, only GROUPnames! Sad, but true.

## But since you GO to that new card, everything should work :-)

## No need to SEND, the handler is in the message path, so just call it:
createTheField leNomDuField
...

on createTheField leNomDuField
   create field leNomDuField
end createTheField
Best

Klaus

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

Re: Creating field at runtime in a new card

Post by atout66 » Sat Apr 05, 2014 7:56 pm

Thanks Klaus,

You're logical is mine :wink: As I didn't get any error with the message:

Code: Select all

go to card laCardCreated -- the card just created
the use of parameters <leNomDuField,laCardCreated ,leNomDeLaStack> is not necessary anymore, since I'm on the card. You found it out.
But I don't understand when you say
## No need to SEND, the handler is in the message path, so just call it:
createTheField leNomDuField
What do you mean by " so just call it" ?

Because I still use

Code: Select all

send "createTheField leNomDuField"
Now LC create the field in the fist card of the main stack from where the handler mouseUp come from... and not in the right card where I am supposed to be :shock:

Kind regards.
Discovering LiveCode Community 6.5.2.

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

Re: Creating field at runtime in a new card

Post by atout66 » Sat Apr 05, 2014 8:12 pm

Ah! I got it Klaus :)
I didn't understand the message path and why the <send> command was useless.
It was because of the <send> command that I had troubles after trying to fix the issue.

Thanks a lot for your help, and I hope I won't touch this computer before monday :wink:
Discovering LiveCode Community 6.5.2.

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

Re: Creating field at runtime in a new card

Post by Klaus » Sat Apr 05, 2014 8:23 pm

atout66 wrote:Thanks a lot for your help, and I hope I won't touch this computer before monday :wink:
Hehe, I highly doubt! :D

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

Re: Creating field at runtime in a new card

Post by atout66 » Mon Apr 07, 2014 1:08 pm

Klaus, you lost :wink:
Discovering LiveCode Community 6.5.2.

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

Re: Creating field at runtime in a new card

Post by Klaus » Mon Apr 07, 2014 1:28 pm

atout66 wrote:Klaus, you lost :wink:
Avec plaisir, monsieur! 8)

Post Reply