Welcome to Keen Software House Forums! Log in or Sign up to interact with the KSH community.
  1. You are currently browsing our forum as a guest. Create your own forum account to access all forum functionality.

[Suggestion] Identify which other block applied a Programmable Block's "Run" action

Discussion in 'Programming Questions and Suggestions' started by Sirhan Blixt, Jan 13, 2015.

Thread Status:
This last post in this thread was made more than 31 days old.
  1. Sirhan Blixt Apprentice Engineer

    Messages:
    449
    This was touched in on a suggestion thread about self-identifying the programming block, but I figured that it needed its own topic. I have also spotted other threads which suggest something similar, but were not posted here.

    http://forums.keenswh.com/post/determinate-block-that-triggered-a-script-7248399
    http://forums.keenswh.com/post/interface-console-concept-7240311
    ... okay, I know there was another thread also, but I can't find it now.

    PROBLEM: it is not possible to determine how a Programmable Block got triggered. There are plenty of use cases where we would want the code to behave differently based on which other block applied the Programmable Block's "Run" method.

    SOLUTION: provide a reference to the "calling" block either through another built-in variable or as a parameter for the Run() method itself.

    Code:
    IMyTerminalBlock referrer;
    
    or

    Code:
    Main(IMyTerminalBlock referrer) { }
    
     
    Last edited by a moderator: Jan 14, 2015
  2. mze9412 Junior Engineer

    Messages:
    791
    You would need the whole chain, not just one referrer. It could be a button which triggers a timer which triggers the program. But also a sensor could trigger the timer. So your referrer is the timer, but what triggered the timer? But that would lead to problems with loops (timer triggers program, program triggers timer, timer triggers program, etc.). I think the reason we do not have this is because we just run actions and actions do not care who or what triggered them.
     
  3. Sirhan Blixt Apprentice Engineer

    Messages:
    449
    What you suggest is not a requirement, nor does your disaster scenario require this feature. Might as well say that what I suggest is not possible because peanut butter.

    I appreciate suggestions and constructive criticism. I am less enthusiastic about vague handwaving and random birdwalks in the service of incinerating straw effigies.

    I admit that getting an ordered collection or enumeration of IMyTerminalBlocks instead of just the one that triggered the Programmable Block is an interesting notion, but I think it's too much complication for what one is expected to get out of it. Which is why I didn't suggest that.
     
    Last edited by a moderator: Jan 14, 2015
Thread Status:
This last post in this thread was made more than 31 days old.