copy values of a variable from one stack to another stack
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
copy values of a variable from one stack to another stack
Hi all,
I've implemented a calendar picker in my solution from a sample script on the forums. I just now need to get the feedback from the calendar into my field. So I've got a stack called myCosts and I am on a card called projects. There is a field called fld_start_date, which has an on mouseEnter script attached which pops up a calendar from the calendar stack. The user can den select a date from the Calendar stack, and Ive converted it to short system date and put it in a dialog so I can see the right date is being generated to store.
My question is, instead of display it in the answer command I would like to post it to the fld_start_date in the projects card. So I have tried the following but I keep getting an error fld_start_date, no such object.
theDate is the variable that contains the date
put theDate into field "fld_start_date" into stack "myCosts" and card "Projects"
What am I doing wrong. I know I'm on the calendar stack and need to somehow go to the Projects card which contains the field
I've implemented a calendar picker in my solution from a sample script on the forums. I just now need to get the feedback from the calendar into my field. So I've got a stack called myCosts and I am on a card called projects. There is a field called fld_start_date, which has an on mouseEnter script attached which pops up a calendar from the calendar stack. The user can den select a date from the Calendar stack, and Ive converted it to short system date and put it in a dialog so I can see the right date is being generated to store.
My question is, instead of display it in the answer command I would like to post it to the fld_start_date in the projects card. So I have tried the following but I keep getting an error fld_start_date, no such object.
theDate is the variable that contains the date
put theDate into field "fld_start_date" into stack "myCosts" and card "Projects"
What am I doing wrong. I know I'm on the calendar stack and need to somehow go to the Projects card which contains the field
Re: copy values of a variable from one stack to another stac
You are nearly there...
Try putting the variable into a field of a card of a stack.
I think you should be able to get it from that .D
Try putting the variable into a field of a card of a stack.
I think you should be able to get it from that .D
Re: copy values of a variable from one stack to another stac
Thanks SparkOut, that did the trick 

Re: copy values of a variable from one stack to another stac
Hi jalz,
...
put theDate into field "fld_start_date" of card "Projects" of stack "myCosts"
...
?
Best
Klaus
Well, what about:jalz wrote:...
theDate is the variable that contains the date
put theDate into field "fld_start_date" into stack "myCosts" and card "Projects"
...
put theDate into field "fld_start_date" of card "Projects" of stack "myCosts"
...
?

Best
Klaus
Re: copy values of a variable from one stack to another stac
Hi Klaus,
That what I ended up with in the end, I seem to be mixing my syntax up, but the more I read about messages, the more it kinda makes sense. I've got that part working, but Im now getting an odd error on a simple mouseUp code. Funny thing is the code thats producing the error seems to be working OK, up until I call the calendar stack on mouseEnter which populates the date correctly now, but when I switch cards, I seem to get Handler:error in statement on the line go to card "Customers"
reading up to see what could be causing this, as the go to card code works fine until I call the calendar popup
That what I ended up with in the end, I seem to be mixing my syntax up, but the more I read about messages, the more it kinda makes sense. I've got that part working, but Im now getting an odd error on a simple mouseUp code. Funny thing is the code thats producing the error seems to be working OK, up until I call the calendar stack on mouseEnter which populates the date correctly now, but when I switch cards, I seem to get Handler:error in statement on the line go to card "Customers"
reading up to see what could be causing this, as the go to card code works fine until I call the calendar popup
Code: Select all
on mouseUp
go to card "Customers"
end mouseUp
Re: copy values of a variable from one stack to another stac
Hi jalz,
I strongly suspect that the "mouseenter" handler has changed the "defaultstack" (to your "calender" stack?)!
Set it back to whatever it should be and that's it:
Best
Klaus
I strongly suspect that the "mouseenter" handler has changed the "defaultstack" (to your "calender" stack?)!
Set it back to whatever it should be and that's it:
Code: Select all
on mouseup
set the defaultstack to "name of your supposed stack here..."
go cd "a card in that above mentioned stack"
end mouseup
Klaus
Re: copy values of a variable from one stack to another stac
Hi Klaus,
Thanks for the hint, I suspected the default stack was changing as well but to my surprise this doesn't seem to be the issue. I've narrowed down the issue to cards that have some sort of connection to a database.
Further troubleshooting has led me to believe its the global variable changing. I've got a global variable setup on openStack called gConnID, which inserts the database connection id
Everytime I hover over the calendar date picker, the gConnID increases and does not resemble what the livecode opened with and used. As soon as I put the original value back into gConnID using the message box, the buttons work fine. So I'm assuming every time I hover over the start date field with the calendar drop down, the openstack is being triggered which generates a new gConnID.
Is there anyway to stop this? I've tried wrapping the openStack code around if gConnID is empty then.... but that didn't work. Will investigate further tomorrow. The message path is starting to make sense
Thanks
Thanks for the hint, I suspected the default stack was changing as well but to my surprise this doesn't seem to be the issue. I've narrowed down the issue to cards that have some sort of connection to a database.
Further troubleshooting has led me to believe its the global variable changing. I've got a global variable setup on openStack called gConnID, which inserts the database connection id
Code: Select all
on openStack
put the effective filename of this stack into filepath
set the itemdelimiter to slash
put "db2.sqlite" into the last item of filepath
put revOpenDatabase("sqlite", filepath,,,,,,) into gConnID
end openStack
Is there anyway to stop this? I've tried wrapping the openStack code around if gConnID is empty then.... but that didn't work. Will investigate further tomorrow. The message path is starting to make sense

Thanks
Re: copy values of a variable from one stack to another stac
Hi jalz,
sound like your calendar picker stack does NOt haven a "openstack" script and thus
is executing the mainstack "openstack" script!
Add a "dummy" script to the calendar picker:
and you are done!
Another, maybe better option:
Put all "pre-/openstack" hanlder into the script of the first card of that stack!
This way, they will also work, but only for that stack!
Best
Klaus
sound like your calendar picker stack does NOt haven a "openstack" script and thus
is executing the mainstack "openstack" script!
Add a "dummy" script to the calendar picker:
Code: Select all
on openstack
## Nada!
end openstack
Another, maybe better option:
Put all "pre-/openstack" hanlder into the script of the first card of that stack!
This way, they will also work, but only for that stack!

Best
Klaus
Re: copy values of a variable from one stack to another stac
Thanks Klaus,
That did the trick brilliantly....
That did the trick brilliantly....