FrontScript message path confusion

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
trevix
Posts: 1081
Joined: Sat Feb 24, 2007 11:25 pm
Contact:

FrontScript message path confusion

Post by trevix » Sat Apr 18, 2020 1:21 pm

LC 9.6.0 Dp4
I am trying to find out why the message path in my stack (in the IDE) doesn't follow what I think it should.

As from the clear Fourth World explanation, this is the message path for FrontScripts:
https://www.fourthworld.com/embassy/art ... _path.html
mess_path2.gif
mess_path2.gif (8.82 KiB) Viewed 6403 times

Now, in my stack, I had to implement the schema of below. The "ReceiveSomething" command is triggered by an external and the front script receive it fine.
The problem is that the "DoThis" command does not reach the Behaviour script of card B. On the debugger the instruction line of "DoThis pValue" of the FrontScript does not report any error, but won't trigger the command of the Behaviour script.

Can please someone clarify me what am I doing wrong? Thanks
Attachments
Schermata 2020-04-18 alle 14.18.16.png
Trevix
OSX 14.6.1 xCode 15 LC 10 RC1 iOS 15> Android 7>

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10055
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: FrontScript message path confusion

Post by FourthWorld » Sat Apr 18, 2020 3:10 pm

trevix wrote:
Sat Apr 18, 2020 1:21 pm
The problem is that the "DoThis" command does not reach the Behaviour script of card B.
What does that mean? Does card B use a behavior script, or is there an attempt to use it as the behavior script for the object receiving the message?

If the latter, the remedy is simple enough: buttons and stacks can be used as containers for behavior scripts, but not other object types like cards.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

trevix
Posts: 1081
Joined: Sat Feb 24, 2007 11:25 pm
Contact:

Re: FrontScript message path confusion

Post by trevix » Sat Apr 18, 2020 4:06 pm

Hi
Card B use a behavior script: Button ID xxx of stack "Main Stack A"
Trevix
OSX 14.6.1 xCode 15 LC 10 RC1 iOS 15> Android 7>

trevix
Posts: 1081
Joined: Sat Feb 24, 2007 11:25 pm
Contact:

Re: FrontScript message path confusion

Post by trevix » Sat Apr 18, 2020 4:12 pm

So I guess the question is: can I, from a FrontScript, fire a message to a card, that has a behaviour, using the regular message path (without using send "...")?
Trevix
OSX 14.6.1 xCode 15 LC 10 RC1 iOS 15> Android 7>

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10055
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: FrontScript message path confusion

Post by FourthWorld » Sat Apr 18, 2020 7:19 pm

trevix wrote:
Sat Apr 18, 2020 4:12 pm
So I guess the question is: can I, from a FrontScript, fire a message to a card, that has a behaviour, using the regular message path (without using send "...")?
In that diagram card B is in a different stack from the one where the messages originate, so I'm not clear on how this is supposed to work.

Maybe for slowpokes like me you can start more simply: what do you want to do?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

SparkOut
Posts: 2949
Joined: Sun Sep 23, 2007 4:58 pm

Re: FrontScript message path confusion

Post by SparkOut » Sat Apr 18, 2020 7:23 pm

I think we need to see more of your code to understand what you are doing and what you have in mind compared to what is actually happening. I "think" the answer to your question is yes, but I don't know how you are using the message path to have put the handler in play. Ultimately "send" is not an undesirable if it's needed. But it's hard to tell whether it's needed with your setup.

[edit]As if the message path guru is a slowpoke, ha![/edit]

trevix
Posts: 1081
Joined: Sat Feb 24, 2007 11:25 pm
Contact:

Re: FrontScript message path confusion

Post by trevix » Sat Apr 18, 2020 8:07 pm

My App is to complex to be reduced to the point, so I've put together a test stack, that I hope will be self explaining.
Of course I could use "Send" or "Dispatch", but latency in my App is very important so I am trying to fasten thing as much as possible.
Attachments
MyMainStack.livecode.zip
(1.37 KiB) Downloaded 250 times
Trevix
OSX 14.6.1 xCode 15 LC 10 RC1 iOS 15> Android 7>

trevix
Posts: 1081
Joined: Sat Feb 24, 2007 11:25 pm
Contact:

Re: FrontScript message path confusion

Post by trevix » Sat Apr 18, 2020 8:12 pm

One more thing:
you have to imagine that the "ReceiveSomething" command, that has to be available all over the App, comes from a LC external (in my case a bluetooth external)
Trevix
OSX 14.6.1 xCode 15 LC 10 RC1 iOS 15> Android 7>

LCMark
Livecode Staff Member
Livecode Staff Member
Posts: 1232
Joined: Thu Apr 11, 2013 11:27 am

Re: FrontScript message path confusion

Post by LCMark » Sun Apr 19, 2020 8:41 am

@trevix: You have a frontscript which does:

Code: Select all

on ReceiveSomething
  doThis
end ReceiveSomething
Then doThis is implemented in a behavior which is attached to a button in another stack.

Unless the button with this behavior is the target of the 'ReceiveSomething' message, then 'DoThis' is not in the message path when the message fires - regardless of where it comes from (which is why your code doesn't work - but the 'send' form you have commented out does). FrontScripts sit at the front of the message path so they can intercept anything but they don't change what happens afterwards - that all depends on the target.

The target of the 'ReceiveSomething' message will depend on what is firing it - most LCB libraries will bind 'to something sensible'. For example the FLIC library (which I'm guessing is what are you using here) sends its messages to the object which called the 'initialize' method. So you don't necessarily need a frontscript - you just need to add a handler to that object's script which relays the message to where you want it to be handled.

trevix
Posts: 1081
Joined: Sat Feb 24, 2007 11:25 pm
Contact:

Re: FrontScript message path confusion

Post by trevix » Sun Apr 19, 2020 10:29 am

Ah! I guess I misunderstood the message path of FourthWorld schema: "FrontScript" > "Card"
The card referring to, is the card of the object whose script is put to the front.
As you said
FrontScript...can intercept anything but they don't change what happens afterwards
Thanks
Trevix
OSX 14.6.1 xCode 15 LC 10 RC1 iOS 15> Android 7>

Post Reply