Author Topic: how to write words and numbers ?  (Read 2476 times)

ALFADELTA

  • Newbie
  • *
  • Posts: 19
how to write words and numbers ?
« on: March 10, 2021, 12:44:16 PM »
hi

how to write to file  what i say exemple com1 125.025 nav2 108.050 Altitude 10000 feet heading 052 etc....

Code: [Select]
Set text [~fileContents] to [C:\texte.txt]
Set text [~textToInsert] to '{TXTSUBSTR:"{TXTREPLACEVAR:"{TXTNUM:"{CMD}"}'
Set integer [~textToInsert] value to the converted value of {TXTNUM:~textToInsert}
Quick Input, '{TXTNUM:~textToInsert}'
Write (overwrite), '{TXTSUBSTR:~fileContents:0:{EXP:{TXTPOS:"_":~fileContents:0}+1}}{TXT:~textToInsert}{TXTSUBSTR:~fileContents:{TXTPOS:"-":~fileContents:0}:}' to file 'C:\...

with this code if i say com2 132.075 i can write only 132.075 in file without letters

Code: [Select]
Set text [~fileContents] to [C:\texte.txt]
Set text [~textToInsert] to '{TXTALPHA:"{CMD}"}'
Set integer [~textToInsert] value to the converted value of {TXTALPHA:~textToInsert}
Quick Input, '{TXTALPHA:~textToInsert}'
Write (overwrite), '{TXTSUBSTR:~fileContents:0:{EXP:{TXTPOS:"_":~fileContents:0}+1}}{TXT:~textToInsert}{TXTSUBSTR:~fileContents:{TXTPOS:"-":~fileContents:0}:}' to file 'C:\...

with this code if i say com2 132.075 i can write only com in file without numerics & i have
 
Quote
this Integer token could not be converted : {TXTALPHA:~textToInsert}


i can use only one of this two codes

ALFADELTA

  • Newbie
  • *
  • Posts: 19
Re: how to write words and numbers ?
« Reply #1 on: March 10, 2021, 03:10:34 PM »
with this code it works but there are spaces between the numerics

Code: [Select]
Set text [~fileContents] to [C:\texte.txt]
Set text [~textToInsert] to '{CMD}'
Quick Input, '{{CMD}:~textToInsert}'
Write (overwrite), '{TXTSUBSTR:~fileContents:0:{EXP:{TXTPOS:"_":~fileContents:0}+1}}{TXT:~textToInsert}{TXTSUBSTR:~fileContents:{TXTPOS:"-":~fileContents:0}:}' to file 'C:\...

com3

ipc.writeSTR(0x3380, tab.."COM1_com3 125 . 075-")  <---- spaces between 125 & . & 075

nav1

ipc.writeSTR(0x3380, tab.."COM1_nav1 108 . 025-");   <---- spaces between 108 & . & 025

Gary

  • Administrator
  • Hero Member
  • *****
  • Posts: 2832
Re: how to write words and numbers ?
« Reply #2 on: March 10, 2021, 03:26:35 PM »
You might want to try writing the values for ~fileContents and ~textToInsert out to the log - that might be very telling.  You can post the values here.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: how to write words and numbers ?
« Reply #3 on: March 11, 2021, 12:33:49 AM »
Code: [Select]
Quick Input, '{{CMD}:~textToInsert}'Isn't going to work correctly, given that unless your spoken phrase used to trigger the command is a variation of the "TXT" series of tokens, and nothing else, that will not produce a valid token.

Probably worth mentioning for context that this command originated in this topic.


As Gary mentioned, the contents of the file you're writing to, and the command phrase you're using, are very relevant here; if you're just writing a single line or sequence of lines, where the original contents don't matter (I.E. everything with the exception of what you're writing is always the same, and not set by other commands), it would be much simpler to just write all of that as well (replacing the contents of the file entirely).

ALFADELTA

  • Newbie
  • *
  • Posts: 19
Re: how to write words and numbers ?
« Reply #4 on: March 11, 2021, 11:13:21 AM »
Quote
As Gary mentioned, the contents of the file you're writing to, and the command phrase you're using, are very relevant here; if you're just writing a single line or sequence of lines, where the original contents don't matter (I.E. everything with the exception of what you're writing is always the same, and not set by other commands), it would be much simpler to just write all of that as well (replacing the contents of the file entirely).

what I understood can i rewrite the line by changing only the contenon between "_ -"

ipc.writeSTR(0x3380, tab.."COM1_com3 125 . 075-")

how can i do that ?

Quote
Set text [~fileContents] to [H:\fsx\Modules\2.lua]
Set text [~textToInsert] to '{CMD}'
Quick Input, '{{CMD}:~textToInsert}'
Say, '{CMD}'

there is another problem with this Command I do not use any key while this Command works I noticed that shortcuts are activated via their respective shortcut example the radio panel shift+2 the top panel shift+5 the gps shift+3

what is strange if I say Altitude 5000 it is the top panel shift+5 and if I say Altitude 5000 again it is the top panel shift+5 disappears


if I say Altitude 2000 it's the radio panel shift+2 then if I say Altitude 2000 again it's the radio panel shift+2 disappears

ps : shift+2 the 2 is not the numeric keypad 

« Last Edit: March 11, 2021, 12:18:28 PM by ALFADELTA »

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: how to write words and numbers ?
« Reply #5 on: March 11, 2021, 12:54:35 PM »
Again, as both Gary and I have now asked: What are the actual full contents of the file you're reading from/writing to?


As to keys being pressed, that is literally what the "Quick Input" action is for. If you don't want keys to be pressed, remove the action.
It attempts to type out text as you would, so if you set it up to type "2", and your keyboard layout required Shift-2 to produce that character, the "Quick Input" action will press those keys.

ALFADELTA

  • Newbie
  • *
  • Posts: 19
Re: how to write words and numbers ?
« Reply #6 on: March 11, 2021, 01:02:34 PM »
Again, as both Gary and I have now asked: What are the actual full contents of the file you're reading from/writing to?

full contents of the file

ipc.writeSTR(0x3380, tab.."COM1_-");             -- display delected radio on green bar com1

is there an alternative to "Quick Input"

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: how to write words and numbers ?
« Reply #7 on: March 11, 2021, 01:20:23 PM »
full contents of the file

ipc.writeSTR(0x3380, tab.."COM1_-");             -- display delected radio on green bar com1
As mentioned, if all that's in the file is that single line, it's a whole lot simpler to just write that out combined with the input from your command (which is what would happen anyway after reading the contents of the file).

E.G. if the "When I say" contents of your command are something like "set [com1;com2;com3;nav1;nav2] to [120..130].[075:20..199,5]", the action could look like
Code: [Select]
Write (overwrite), 'ipc.writeSTR(0x3380, tab.."COM1_{CMDSEGMENT:1} {CMDSEGMENT:3}.{CMDSEGMENT:5}-");             -- display selected radio on green bar com1' to file 'H:\fs...

The comment (I.E. everything after "--") won't be required for the functioning of that snippet, so you could choose to leave that off.


is there an alternative to "Quick Input"
An alternative that does what?
If you're just trying to check the contents of a variable, you can use the "Write a Value to the Event Log" action, which outputs text to the log on VoiceAttack's main window.

ALFADELTA

  • Newbie
  • *
  • Posts: 19
Re: how to write words and numbers ?
« Reply #8 on: March 11, 2021, 03:20:30 PM »
ok thanks

ALFADELTA

  • Newbie
  • *
  • Posts: 19
Re: how to write words and numbers ?
« Reply #9 on: March 12, 2021, 01:36:56 PM »
is there a solution to use num pad keyboard with Quick Input

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: how to write words and numbers ?
« Reply #10 on: March 12, 2021, 01:40:03 PM »
As noted in the documentation, you can use special key indicators for keys that aren't represented by a typed character. The numpad keys would be "[NUM0]" to "[NUM9]".