Author Topic: Check to see if command is already running  (Read 8699 times)

Woofington

  • Jr. Member
  • **
  • Posts: 54
Check to see if command is already running
« on: May 30, 2016, 03:47:00 PM »
So I know I can stop another command from executing within a command, but I want to ensure the command I am calling, was not called previously as there is some pauses in the command so it could be double invoked.  However using the "stop executing command" on itself means it will never actually perform any if it is running, I instead want to cancel the first invocation of the command but keep the second one running.  Any ideas how to achieve this?

Rhaedas

  • Jr. Member
  • **
  • Posts: 72
Re: Check to see if command is already running
« Reply #1 on: May 30, 2016, 04:08:49 PM »
Take your current command in question and rename it as a subroutine. Then use the command name that starts the operation first kill any of the subroutine name running, then call it.

As an example, here's a part of my routine for engaging warp. I only wanted one instance of a scanner reset run at a time.

Code: [Select]
Kill command, 'reset scanner'
Execute command, 'reset scanner'

This way the kill doesn't kill itself, like you mention, just that part that you want.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4785
  • RTFM
Re: Check to see if command is already running
« Reply #2 on: May 30, 2016, 04:20:42 PM »
Take your current command in question and rename it as a subroutine.
That's better than what I was going to suggest, which was to have the command check whether it was running, and if so to call another command to kill the first command and restart it.

Nice one.

Woofington

  • Jr. Member
  • **
  • Posts: 54
Re: Check to see if command is already running
« Reply #3 on: May 30, 2016, 05:58:11 PM »
Thank you, I have a follow up question.



question, is there an easy way to make a command that is run anytime a phrase is recognized other than injecting it into each and every command?
« Last Edit: May 30, 2016, 06:20:25 PM by Woofington »

Rhaedas

  • Jr. Member
  • **
  • Posts: 72
Re: Check to see if command is already running
« Reply #4 on: May 30, 2016, 07:53:01 PM »
Under editing commands, there's a checkbox beside the profile name at the top. That's your profile options. Click on it, and in those options there's one to always execute a certain command when any phrase is recognized.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4785
  • RTFM
Re: Check to see if command is already running
« Reply #5 on: May 30, 2016, 08:17:25 PM »
there's one to always execute a certain command when any phrase is recognized.

That's for dictation phrases only. There have been requests to have an option that works with commands, but it has not been implemented(yet?) as far as I'm aware.

So no, there is no easy way, currently.

Belay that. There is a way without adding something to every command, however it is something of a kludge:
Code: [Select]
Set Text [LastCMD] to ''
Start Loop While : [{PROFILE}] Equals '{PROFILE}'
    Begin Text Compare : [{LASTSPOKENCMD}] Does Not Equal '{CMD}'
        Begin Text Compare : [{LASTSPOKENCMD}] Does Not Equal [LastCMD]
            Set Text [LastCMD] to '{LASTSPOKENCMD}'
            Write '[Purple] Trig'd' to log
        End Condition
    End Condition
End Loop

Now, this has drawbacks, as you'd expect. Majorly, it will only work if the command spoken after another command is different. Additionally, because it's a loop within a command, it will stop running when you open the command list.
« Last Edit: May 30, 2016, 08:54:24 PM by Pfeil »

Rhaedas

  • Jr. Member
  • **
  • Posts: 72
Re: Check to see if command is already running
« Reply #6 on: May 30, 2016, 08:53:54 PM »
My mistake, I don't use any of those on that screen, just thought that's what it would do. If it's just dictation being recognized, as good as Windows is with that, that command would rarely get triggered. :)