Passing global array to a different card.
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Passing global array to a different card.
Hello,
I have two cards in my stack. Card1 and Card2
If I have a line of code like this in Card1:
put htmltext of field "company_name" into myData["company_name"]
How would I pass the contents of myData to Card2?
I tried declaring myData globally..
global myData
but the array is empty when I bring up card 2.
Thanks!
I have two cards in my stack. Card1 and Card2
If I have a line of code like this in Card1:
put htmltext of field "company_name" into myData["company_name"]
How would I pass the contents of myData to Card2?
I tried declaring myData globally..
global myData
but the array is empty when I bring up card 2.
Thanks!
Re: Passing global array to a different card.
Hi.
Array variables are treated just like ordinary ones. If declared globally, they are available in any handler where they are declared.
So, what do you mean "pass the contents to Card 2"? The use of "pass" generally indicates that a parameter is sent from one handler to another. In that case, global variables are not required, as they are still alive in the called handler.
But for a later process, Is there a handler in that card that calls for the variable? It can read it if so. Were they declared global in all handlers that need them? There is something wrong with your code somewhere. Write back with what you find.
Craig Newman
Array variables are treated just like ordinary ones. If declared globally, they are available in any handler where they are declared.
So, what do you mean "pass the contents to Card 2"? The use of "pass" generally indicates that a parameter is sent from one handler to another. In that case, global variables are not required, as they are still alive in the called handler.
But for a later process, Is there a handler in that card that calls for the variable? It can read it if so. Were they declared global in all handlers that need them? There is something wrong with your code somewhere. Write back with what you find.
Craig Newman
Re: Passing global array to a different card.
Thanks, Craig.
Yes. You were correct. I did in fact have a bug in my code.
When I selected my button I wasn't filling up the array from the previous card.
I knew this was a bad week to try and give up coffee. It's affecting my thought process
Yes. You were correct. I did in fact have a bug in my code.
When I selected my button I wasn't filling up the array from the previous card.
I knew this was a bad week to try and give up coffee. It's affecting my thought process

Re: Passing global array to a different card.
I'm still all star struck with custom properties
Then add this to any card, any object it says the same thing.
no more declaring "global iMustRememberToAddThisLine"
next new project!
Simon
Code: Select all
on mouseUp
set the htmlText of fld 1 to "<font face=""e&"Comic Sans MS, cursive""e&">Hello</font>"
set the cmyData["company_name"] of this stack to fld 1
set the cmyData["last_name"] of this stack to "Harry"
end mouseUp
Code: Select all
on mouseUp
answer the cmyData["company_name"] of this stack
end mouseUp
next new project!
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
Re: Passing global array to a different card.
Simon.
Are you aware of the stuff you can set a custom property to? Much more than just a string. You can have whole stacks in there. Find the threads that deal with this. Custom properties are really big containers.
Craig
Are you aware of the stuff you can set a custom property to? Much more than just a string. You can have whole stacks in there. Find the threads that deal with this. Custom properties are really big containers.
Craig
Re: Passing global array to a different card.
Hi,tasdvl9 wrote:I tried declaring myData globally..
global myData
but the array is empty when I bring up card 2.
You need to declare (re-declare) global myData
in every script you are using myData.
So, in your case 2 times: in card 1 and card 2 scripts.
HTH,
Thierry
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!