I probably should have figured this out sooner but when you call a function using Perform, the mainline code does not wait for completion of the called procedure.
What’s the best workaround? Setting a flag for a timer?
I ran into a condition where the mainline wouldn’t complete when a timer was used which required use of a second Perform call from the secondary function.
Well the easiest way is to have a translator that call perform.
Then the perform translator does its work and triggers a timer as an outgoing action. Within the rules of this translator you can set a global variable with the return value if you want to return something.
The final tranlator is triggered by the timer that can then read the return value (global variable) and do what it needs from there.
Steve Caldwell
Bome Customer Care
Also available for paid consulting services: bome@sniz.biz
What I ended up doing was splitting the calling translator into 2 parts at the point of the call to the subroutine. I then did a Perform as the output to call the second portion serially.
This could really be best solved by adding returns to procedure calls so the calling procedure would wait implicitly for the called procedure to execute and return a value.
Is there work ongoing for an updated version that would include expanded features? Or is this a dead language?
Hi Bill,
the ‘language’ is very alive, but we are careful what to add. We aim for infinite compatibility in the future, so anything we add will stay forever. Also, we need to make sure that the whole processing engine still performs in real time without adding too much overhead.
Having said that, all outgoing actions have a determined behavior. Some execute synchronously, and others are async. So we don’t see Perform as a procedure call, more of a ‘trigger this translator’ thing. Although it can be used in a similar way as a procedure call, it will not wait. We have an idea how to extend MT Pro with a way to wait in the Rules section, but also that would mean that the rest of the rules, and the corresponding outgoing action, would be executed asynchronously. It is important that the incoming event can be processed without delay by all translators.
I hope that makes sense!
I think both your and Steve’s solution will work fine (even if they seem clumsier than to having a Perform+wait option). Note that still some outgoing actions will execute asynchronously (like keystrokes). But each outgoing type will always be executed in the correct order.