KnowBrainer Speech Recognition
Decrease font size
Increase font size
Topic Title: Can a Dragon custom command take two numbers as input and perform a calculation?
Topic Summary:
Created On: 09/22/2021 04:58 PM
Status: Post and Reply
Linear : Threading : Single : Branch
 09/22/2021 04:58 PM
User is offline View Users Profile Print this message

Author Icon
souffle
New Member

Posts: 17
Joined: 04/06/2013

Hello,

tl;dr: if I say two numbers in a custom command, can Dragon subtract one from the other then then use the result for subsequent steps?

Context:

I write code for a job currently use Dragon to navigate between code lines by speaking the line numbers: e.g. I'll say "run line 128", and internally a custom command will perform {control + g}, then {128}, then {control + enter} - which is my code editor's keyboard shortcuts for running line 128.

But what I would love to be able to do is run a block of code by saying "run lines 128 to 138". Doing this on my keyboard would require the above keyboard shortcuts, then highlighting the next 9 lines by holding down {shift} and pressing {down} nine times, before finally pressing {control + enter}.

The key thing I don't know how to do here is getting Dragon to press {down} 9x - as this would require Dragon to be able to calculate the difference between 138 and 128.

Is there any way to do this?

Thanks for the help!

 

 09/22/2021 05:41 PM
User is offline View Users Profile Print this message


Alan Cantor
Top-Tier Member

Posts: 4183
Joined: 12/08/2007

This sounds do-able. The code might look something like this untested example. I'm assuming the lines are 1 to 300, and you have created the list:

1
2
3
...
300

Run Lines <1-300> to <1-300>

Sub Main
Dim x, y, z As String
Dim xn, yn, zn as Integer

Let x = Listvar1
Let y = Listvar2

Let xn = CInt(x)
Let yn = CInt(y)

Let zn = yn - xn
Let z = CStr(zn)

SendDragonKeys "{Ctrl+g}"
SendKeys xn, True

SendDragonKeys "+{down " & z & "}"
SendDragonKeys "{Ctrl+Enter}"

End Sub
 09/23/2021 04:06 PM
User is offline View Users Profile Print this message

Author Icon
souffle
New Member

Posts: 17
Joined: 04/06/2013

Brilliant, that works with a minor modification to the "+{down " & z & "}" line. This will massively help my workflow, thank you very much!
 09/23/2021 05:42 PM
User is offline View Users Profile Print this message


Alan Cantor
Top-Tier Member

Posts: 4183
Joined: 12/08/2007

I'm surprised it mostly worked. The commands I write for myself almost always contain bugs that are fiendishly difficult to sort out!

You might want to rename the command slightly. The word "to" might cause mischief. For example, "Run Lines 200 to 210" could be understood as "Run Lines 202 to 10." This may not be an issue if you always say "two hundred and two" and never "two hundred two." But to me, there's a problem here, waiting to happen.

Maybe substitute "through" for "to??"



 09/23/2021 05:53 PM
User is offline View Users Profile Print this message

Author Icon
souffle
New Member

Posts: 17
Joined: 04/06/2013

Hi Alan, yes I came across the "to" issue already and updated to something else. Thank you again!
Statistics
32177 users are registered to the KnowBrainer Speech Recognition forum.
There are currently 0 users logged in.
The most users ever online was 12124 on 09/09/2020 at 04:59 AM.
There are currently 298 guests browsing this forum, which makes a total of 298 users using this forum.

FuseTalk Standard Edition v4.0 - © 1999-2021 FuseTalk™ Inc. All rights reserved.