message path trouble

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: heatherlaine, Klaus, FourthWorld, robinmiller, kevinmiller

Post Reply
adventuresofgreg
Posts: 304
Joined: Tue Oct 28, 2008 1:23 am
Contact:

message path trouble

Post by adventuresofgreg » Fri Feb 09, 2018 6:25 pm

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.

Klaus
Posts: 9991
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: message path trouble

Post by Klaus » Fri Feb 09, 2018 6:56 pm

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

adventuresofgreg
Posts: 304
Joined: Tue Oct 28, 2008 1:23 am
Contact:

Re: message path trouble

Post by adventuresofgreg » Fri Feb 09, 2018 7:07 pm

Klaus wrote:
Fri Feb 09, 2018 6:56 pm
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
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"

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 5326
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: message path trouble

Post by dunbarx » Fri Feb 09, 2018 7:21 pm

Hi.

What happens if you try an explicit experiment:

Code: Select all

 put field "this local field" of card "subStackCard"
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

adventuresofgreg
Posts: 304
Joined: Tue Oct 28, 2008 1:23 am
Contact:

Re: message path trouble

Post by adventuresofgreg » Fri Feb 09, 2018 7:26 pm

dunbarx wrote:
Fri Feb 09, 2018 7:21 pm
Hi.

What happens if you try an explicit experiment:

Code: Select all

 put field "this local field" of card "subStackCard"
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
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.

Klaus
Posts: 9991
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: message path trouble

Post by Klaus » Fri Feb 09, 2018 8:20 pm

Hi Greg,
adventuresofgreg wrote:
Fri Feb 09, 2018 7:07 pm
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.
nope, that was just an example! 8)
adventuresofgreg wrote:
Fri Feb 09, 2018 7:07 pm
From my substack:
do ThisCrazyHandler (which is a handler on main stack)
no need to DO this, just ->
ThisCrazyHandler

adventuresofgreg wrote:
Fri Feb 09, 2018 7:07 pm
On Main stack
on ThisCrazyHandler
put field "this local field"
end thisCrazyHandler
I meant:

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
Best

Klaus

adventuresofgreg
Posts: 304
Joined: Tue Oct 28, 2008 1:23 am
Contact:

Re: message path trouble

Post by adventuresofgreg » Fri Feb 09, 2018 9:35 pm

Klaus wrote:
Fri Feb 09, 2018 8:20 pm
Hi Greg,
adventuresofgreg wrote:
Fri Feb 09, 2018 7:07 pm
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.
nope, that was just an example! 8)
adventuresofgreg wrote:
Fri Feb 09, 2018 7:07 pm
From my substack:
do ThisCrazyHandler (which is a handler on main stack)
no need to DO this, just ->
ThisCrazyHandler

adventuresofgreg wrote:
Fri Feb 09, 2018 7:07 pm
On Main stack
on ThisCrazyHandler
put field "this local field"
end thisCrazyHandler
I meant:

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
Best

Klaus
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.

There must be a way to force mainstack handlers to auto reference fields on the main stack if called from a sub stack. ??

Klaus
Posts: 9991
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: message path trouble

Post by Klaus » Fri Feb 09, 2018 10:31 pm

adventuresofgreg wrote:
Fri Feb 09, 2018 9:35 pm
There must be a way to force mainstack handlers to auto reference fields on the main stack if called from a sub stack?
Sorry, Greg, not that I knew.

adventuresofgreg
Posts: 304
Joined: Tue Oct 28, 2008 1:23 am
Contact:

Re: message path trouble

Post by adventuresofgreg » Fri Feb 09, 2018 11:26 pm

Klaus wrote:
Fri Feb 09, 2018 10:31 pm
adventuresofgreg wrote:
Fri Feb 09, 2018 9:35 pm
There must be a way to force mainstack handlers to auto reference fields on the main stack if called from a sub stack?
Sorry, Greg, not that I knew.
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.

adventuresofgreg
Posts: 304
Joined: Tue Oct 28, 2008 1:23 am
Contact:

Re: message path trouble

Post by adventuresofgreg » Sat Feb 10, 2018 12:07 am

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

Klaus
Posts: 9991
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: message path trouble

Post by Klaus » Sat Feb 10, 2018 12:14 pm

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:

Code: Select all

...
## This will do:
send "AllsystemsGood connection,green" to stack "robottrader"
...
Best

Klaus

Post Reply

Return to “Talking LiveCode”