Author Topic: Repeat last command  (Read 4949 times)

Nico1854

  • Guest
Repeat last command
« on: August 11, 2016, 02:00:25 PM »
I'm actually building a checklist and would like to be able to ask VA to repeat last command in two cases. Actually, in my checklist, each question sets a new text variable to pass to the next one.

Example :

VA Question 1 : Please check Battery switch (set Text var Checklist to Battery)
My answer : checked
VA Question 2 : (if Checklist = Battery) Check Ground connections (set Text var Checklist to GndConnect)
My answer : checked.....


First case, I did not understand the question so I would like the question to be asked again after saying :"repeat".
Second case, If I don't answer to the question, past lets say 10 seconds, I would like the question to be asked again

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Repeat last command
« Reply #1 on: August 11, 2016, 02:51:19 PM »
I put together a checklist system in an early version of VoiceAttack, though I used a numeric index.

If you're starting from scratch, you'll want to use "Else If", rather than individual compare blocks. That feature simply didn't exist at the time.


Startup Checklist
Code: [Select]
Say, 'Startup check-list.'  (and wait until it completes)
Set small int (condition) [StartupChecklistItem] value to 1
Execute command, 'Set;Check'

Going back to it now, I realise there's no protection against starting another checklist while one is already in progress, so you'll want something like this:
Code: [Select]
Begin Text Compare : [{EXP:{SMALL:StartupChecklistItem} = 0 And {SMALL:ShutdownChecklistItem} = 0}] Equals '1'
    Say, 'Startup check-list.'  (and wait until it completes)
    Set small int (condition) [StartupChecklistItem] value to 1
    Execute command, 'Set;Check'
Else
    Say, 'Checklist in progress'  (and wait until it completes)
End Condition

Checklist - Startup (Voice Disabled)
Code: [Select]
Begin Small Integer Compare : [StartupChecklistItem] Equals 1
    Say, 'DC Circuit Breakers in'
    Set small int (condition) [StartupChecklistItem] value to 2
End Condition - Exit when condition met
Begin Small Integer Compare : [StartupChecklistItem] Equals 2
    Say, 'Dome light and position lights as required, anti-collision light on'
    Set small int (condition) [StartupChecklistItem] value to 3
End Condition - Exit when condition met
Some scrolling later...
Code: [Select]
Begin Small Integer Compare : [StartupChecklistItem] Equals 47
    Say, 'Startup checklist complete'
    Set small int (condition) [StartupChecklistItem] value to 0
End Condition - Exit when condition met


Set;Check
Code: [Select]
Begin Small Integer Compare : [StartupChecklistItem] Does Not Equal 0
    Execute command, 'Checklist - Startup'
End Condition - Exit when condition met
Begin Small Integer Compare : [ShutdownChecklistItem] Does Not Equal 0
    Execute command, 'Checklist - Shutdown'
End Condition - Exit when condition met
Say, 'No checklist in progress'


Go back;Say again
Code: [Select]
Begin Small Integer Compare : [StartupChecklistItem] Does Not Equal 0
    Set small int (condition) [StartupChecklistItem] value as decremented by 1
    Execute command, 'Set;Check' (and wait until it completes)
End Condition - Exit when condition met
Begin Small Integer Compare : [ShutdownChecklistItem] Does Not Equal 0
    Set small int (condition) [ShutdownChecklistItem] value as decremented by 1
    Execute command, 'Set;Check'
End Condition - Exit when condition met
Say, 'No checklist in progress'

With a numeric index, going back is very simple. You could also skip ahead over certain sections by setting the index to the number after it.


Cancel checklist;Abort checklist;reset checklist
Code: [Select]
Set small int (condition) [StartupChecklistItem] value to 0
Set small int (condition) [ShutdownChecklistItem] value to 0
Say, 'Checklist reset' or 'Checklist aborted' or 'Checklist reset'




As a more direct answer, if you're using text you can store the previous value of your "Checklist" text value, as in:
Code: [Select]
Set Text [ChecklistPrev] to [Checklist]
Set Text [Checklist] to 'Battery'

repeat
Code: [Select]
Set Text [Checklist] to [ChecklistPrev]


For the 10 second timer, you can use an external command, which would do little more than
Code: [Select]
Pause 10 seconds
Set Text [Checklist] to [ChecklistPrev]

The advantage of doing it with a command is terminating the timer easily at will:
checked
Code: [Select]
Kill command, '10 Second repeat'
« Last Edit: August 11, 2016, 05:38:43 PM by Pfeil »

Nico1854

  • Guest
Re: Repeat last command
« Reply #2 on: August 12, 2016, 05:55:25 AM »
Waouh,

Thank you very much for such a detailed answer. I now need to try these things and see how they work.