message path trouble
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 349
- Joined: Tue Oct 28, 2008 1:23 am
- Contact:
message path trouble
Hi: i'm having a strange issue with message paths, and i cannot figure out why.
I am calling a handler which is in the stack script of the main stack from a sub stack. The sub stack finds the handler ok, as it should, but when the handler runs, i get an error that fields referenced in the handler cannot be found. I can get around this error if I "go to the stack" like:
Go stack "mainstack"
MainStackHandler
Go stack "substack"
but.. I shouldn't have to flip back and forth between 'front stacks' like that just to allow the stack script to find it's own local fields.
I have tried adding "start using stack mainStack" on "on open stack" for the sub stack, but this has no effect.
Any ideas?
Thanks.
I am calling a handler which is in the stack script of the main stack from a sub stack. The sub stack finds the handler ok, as it should, but when the handler runs, i get an error that fields referenced in the handler cannot be found. I can get around this error if I "go to the stack" like:
Go stack "mainstack"
MainStackHandler
Go stack "substack"
but.. I shouldn't have to flip back and forth between 'front stacks' like that just to allow the stack script to find it's own local fields.
I have tried adding "start using stack mainStack" on "on open stack" for the sub stack, but this has no effect.
Any ideas?
Thanks.
Re: message path trouble
Hi Greg,
you can add:
...
set the defaultstack to "the one with all the controls that could not be found"
put theVar into fld "the field in stack: the one with..."
### etc...
...
That should fix the problem.
Best
Klaus
you can add:
...
set the defaultstack to "the one with all the controls that could not be found"
put theVar into fld "the field in stack: the one with..."
### etc...
...
That should fix the problem.
Best
Klaus
-
- Posts: 349
- Joined: Tue Oct 28, 2008 1:23 am
- Contact:
Re: message path trouble
Hi Klaus:
I added "set the defaultstack", but the defaultstack was set correctly, and also adding this did not fix the problem. What did you mean by "put theVar into fld "the field in stack: the one with..." ?? if you meant that i should add "on stack mainstack" to each field reference in handlers in the main stack, this is what i was trying to avoid. I have hundreds of handlers.
ie:
From my substack:
do ThisCrazyHandler (which is a handler on main stack)
On Main stack
on ThisCrazyHandler
put field "this local field"
end thisCrazyHandler
Error: Cannot find field "this local field"
I can get around if i:
On Main stack
on ThisCrazyHandler
put field "this local field" on stack "main stack"
end thisCrazyHandler
But i dont think i should have to change all of my field references to point to "main stack"
-
- VIP Livecode Opensource Backer
- Posts: 9669
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: message path trouble
Hi.
What happens if you try an explicit experiment:
You should not have to; the mainStack handler ought to know the provenance of the calling handler. Just wondering if this works, and might give a clue.
Craig Newman
What happens if you try an explicit experiment:
Code: Select all
put field "this local field" of card "subStackCard"
Craig Newman
-
- Posts: 349
- Joined: Tue Oct 28, 2008 1:23 am
- Contact:
Re: message path trouble
That works. From substack, i can get the field contents only if i refer to the field stack name, or the fields card name or id.dunbarx wrote: ↑Fri Feb 09, 2018 7:21 pmHi.
What happens if you try an explicit experiment:You should not have to; the mainStack handler ought to know the provenance of the calling handler. Just wondering if this works, and might give a clue.Code: Select all
put field "this local field" of card "subStackCard"
Craig Newman
Re: message path trouble
Hi Greg,
ThisCrazyHandler
Best
Klaus
nope, that was just an example!adventuresofgreg wrote: ↑Fri Feb 09, 2018 7:07 pmHi Klaus:
I added "set the defaultstack", but the defaultstack was set correctly, and also adding this did not fix the problem. What did you mean by "put theVar into fld "the field in stack: the one with..." ?? if you meant that i should add "on stack mainstack" to each field reference in handlers in the main stack, this is what i was trying to avoid. I have hundreds of handlers.
no need to DO this, just ->adventuresofgreg wrote: ↑Fri Feb 09, 2018 7:07 pmFrom my substack:
do ThisCrazyHandler (which is a handler on main stack)
ThisCrazyHandler
I meant:adventuresofgreg wrote: ↑Fri Feb 09, 2018 7:07 pmOn Main stack
on ThisCrazyHandler
put field "this local field"
end thisCrazyHandler
Code: Select all
on ThisCrazyHandler
set the defaultstack to "main stack"
## if "main stack" is the one containing field "this local field"
put field "this local field"
end thisCrazyHandler
Klaus
-
- Posts: 349
- Joined: Tue Oct 28, 2008 1:23 am
- Contact:
Re: message path trouble
Hi Klaus. Adding “set the default stack..” to each and every handler in the main stack is only slightly easier than adding “... on stack mainstack” to each field reference.Klaus wrote: ↑Fri Feb 09, 2018 8:20 pmHi Greg,nope, that was just an example!adventuresofgreg wrote: ↑Fri Feb 09, 2018 7:07 pmHi Klaus:
I added "set the defaultstack", but the defaultstack was set correctly, and also adding this did not fix the problem. What did you mean by "put theVar into fld "the field in stack: the one with..." ?? if you meant that i should add "on stack mainstack" to each field reference in handlers in the main stack, this is what i was trying to avoid. I have hundreds of handlers.no need to DO this, just ->adventuresofgreg wrote: ↑Fri Feb 09, 2018 7:07 pmFrom my substack:
do ThisCrazyHandler (which is a handler on main stack)
ThisCrazyHandler
I meant:adventuresofgreg wrote: ↑Fri Feb 09, 2018 7:07 pmOn Main stack
on ThisCrazyHandler
put field "this local field"
end thisCrazyHandlerBestCode: Select all
on ThisCrazyHandler set the defaultstack to "main stack" ## if "main stack" is the one containing field "this local field" put field "this local field" end thisCrazyHandler
Klaus
There must be a way to force mainstack handlers to auto reference fields on the main stack if called from a sub stack. ??
Re: message path trouble
Sorry, Greg, not that I knew.adventuresofgreg wrote: ↑Fri Feb 09, 2018 9:35 pmThere must be a way to force mainstack handlers to auto reference fields on the main stack if called from a sub stack?
-
- Posts: 349
- Joined: Tue Oct 28, 2008 1:23 am
- Contact:
Re: message path trouble
Thanks Klaus I think part of my problem with this particular case, is that I do have other sub stacks that refer to main stack handlers wheee files reference works. I just cannot figure out what I’m doing differently in this case. I think I will need to experiment with some test stacks to see.Klaus wrote: ↑Fri Feb 09, 2018 10:31 pmSorry, Greg, not that I knew.adventuresofgreg wrote: ↑Fri Feb 09, 2018 9:35 pmThere must be a way to force mainstack handlers to auto reference fields on the main stack if called from a sub stack?
-
- Posts: 349
- Joined: Tue Oct 28, 2008 1:23 am
- Contact:
Re: message path trouble
FiGURED IT OUT!
put "connection,green" into thedets
send AllsystemsGood && thedets to stack "robottrader"
This will ensure that the handler "AllsystemsGood" references fields on the stack "robotTrader"
Simply
AllsystemsGood conection,red
also works, since that handler is on the main stack, but.. it will not reference fields in that handler that are on the main stack.
Greg
put "connection,green" into thedets
send AllsystemsGood && thedets to stack "robottrader"
This will ensure that the handler "AllsystemsGood" references fields on the stack "robotTrader"
Simply
AllsystemsGood conection,red
also works, since that handler is on the main stack, but.. it will not reference fields in that handler that are on the main stack.
Greg
Re: message path trouble
Hi Greg,
great you figured this out, would not have thought of that one.
Very clever solution!
But use QUOTES!
If not, it may bite you when you least expect it, besides the fact that you can save some typing:
Best
Klaus
great you figured this out, would not have thought of that one.
Very clever solution!
But use QUOTES!
If not, it may bite you when you least expect it, besides the fact that you can save some typing:
Code: Select all
...
## This will do:
send "AllsystemsGood connection,green" to stack "robottrader"
...
Klaus