Author Topic: Passing command from the text file?  (Read 1094 times)

rodrigomisterm

  • Newbie
  • *
  • Posts: 8
Passing command from the text file?
« on: February 26, 2023, 05:40:59 PM »
Is there a way for example to send a comand  from the textfile?


Like...

When the last line is finished, send something like that

Text1
Text2
TExt3
{comand:play_song_1} or any other valor command...?


Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Passing command from the text file?
« Reply #1 on: February 26, 2023, 08:48:00 PM »
What "textfile" are you referring to? What would a line being "finished" mean?

rodrigomisterm

  • Newbie
  • *
  • Posts: 8
Re: Passing command from the text file?
« Reply #2 on: February 27, 2023, 05:08:17 AM »
I'm using voiceattack for flight simulator checklist.

So, when the voiceattack finishes the txt file(read last line), I want to send a comand via the text to the voiceattack;


Like..
Text1
Text2
TExt3
{comand:play_song_1} or any other valor command...?

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Passing command from the text file?
« Reply #3 on: February 27, 2023, 08:41:08 AM »
How are you reading this text file?

rodrigomisterm

  • Newbie
  • *
  • Posts: 8
Re: Passing command from the text file?
« Reply #4 on: February 27, 2023, 10:13:19 AM »
Hello.. Like this... Using the commands options.. See attatchments. please

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Passing command from the text file?
« Reply #5 on: February 27, 2023, 11:33:11 AM »
What you're mentioning is theoretically possible, though if you specifically want to use curly braces you'd need to either retrieve the contents of the text file directly so the token parser doesn't remove them, or escape them.

You'd then need to implement a parser that can check each line for that sequence of characters, execute the specified command, and then make sure no output is passed along to the rest of the command for reading aloud.


If the intent is specifically to execute another command when the end of the text file is reached, a more feasible option could be to modify the command, which presumably already has special handling for reaching the end of the file, to execute a command whenever the end of the file has been reached.

What are the full contents of the command? Right-click the action list, choose "Copy All as Text" from the context menu, then paste here into a code block (click the # button)

rodrigomisterm

  • Newbie
  • *
  • Posts: 8
Re: Passing command from the text file?
« Reply #6 on: February 27, 2023, 06:24:19 PM »
Code: [Select]
MODIFY PATH AND FILE BELOW FOR YOUR CHECKLIST
Set text [~textfile] to [D:\Google Drive\FS2020\Voiceattack\Dynamic-Virtual-Co-Pilot-v2.9\Checklists\Completo.txt]
-------------------------------------------
Set integer [~line] value to 1
Set integer [~targetline] value to the value of [~line]
Inline C# Function: Get line
Start Indefinite Loop
    Say, '{TXT:~lineOutput}'
    Set integer [~line] to [~line] plus 1
    Wait for spoken response: 'Check;Exit Checklist;repeat'
    Marker: LOOP
    Begin Text Compare : [resp] Equals 'check'
        Set integer [~targetline] value to the value of [~line]
        Inline C# Function: Get line
        Begin Text Compare : [~lineOutput] Equals 'checklist complete'
            Say, '{TXT:~lineOutput}'
            Pause 3 seconds
            Stop VoiceAttack command processing
        Else
            Say, '{TXT:~lineOutput}'
        End Condition
    Else If Text Compare : [resp] Equals 'Exit Checklist'
        Play sound, 'internal:Thomb'
        Pause 1 second
        Stop VoiceAttack command processing
    Else If Text Compare : [resp] Equals 'repeat'
        Set integer [~line] to [~line] minus 1
        Say, '{TXT:~lineOutput}'
    End Condition
    Marker: CONTINUE
    Wait for spoken response: 'Check;Exit Checklist;repeat'
    Begin Text Compare : [resp] Has Not Been Set
        Say, 'Do you want to exit checklist?'
        Wait for spoken response: 'no;yes'
        Begin Text Compare : [~question] Equals 'yes'
            Play sound, 'internal:Thomb'
            Pause 3 seconds
            Stop VoiceAttack command processing
        Else If Text Compare : [~question] Equals 'no'
            Jump to Marker: CONTINUE
        End Condition
    End Condition
    Set integer [~line] to [~line] plus 1
    Jump to Marker: LOOP
End Loop

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Passing command from the text file?
« Reply #7 on: February 27, 2023, 07:07:43 PM »
Within that command, you have this section:
Code: [Select]
Begin Text Compare : [~lineOutput] Equals 'checklist complete'
Say, '{TXT:~lineOutput}'
Pause 3 seconds
Stop VoiceAttack command processing

That is what you'd want to modify by adding an "Execute Another Command" action, E.G. just below the pause action

I will note that the author of the command may have chosen a sub-optimal action to stop the command, as they've using the "Make VoiceAttack Stop Processing All Commands" action, which will as the name suggests stop any and all running commands, rather than the "Exit Command" action, which will only stop the instance of the command it's used in.