![]() |
KnowBrainer Speech Recognition | ![]() |
Topic Title: script that opens multiple files Topic Summary: If ListVar1= "all files" Then AppBringUp... multiple files. Created On: 05/22/2023 01:15 AM Status: Post and Reply |
|
![]() |
![]() |
- Anandits | - 05/22/2023 01:15 AM |
![]() |
![]() |
- missink | - 05/22/2023 07:06 AM |
![]() |
![]() |
- Edgar | - 05/22/2023 10:09 AM |
![]() |
![]() |
- Anandits | - 05/22/2023 10:20 AM |
![]() |
![]() |
- Anandits | - 05/22/2023 10:10 AM |
![]() |
![]() |
- Alan Cantor | - 05/22/2023 10:18 AM |
![]() |
![]() |
- Edgar | - 05/22/2023 10:20 AM |
![]() |
![]() |
- Anandits | - 05/22/2023 10:39 AM |
![]() |
![]() |
- Edgar | - 05/22/2023 03:22 PM |
![]() |
![]() |
- Anandits | - 05/22/2023 10:32 AM |
![]() |
![]() |
- PG LTU | - 05/22/2023 11:41 AM |
![]() |
![]() |
- Anandits | - 05/22/2023 11:49 AM |
![]() |
![]() |
- Alan Cantor | - 05/22/2023 12:26 PM |
![]() |
![]() |
- PG LTU | - 05/22/2023 12:48 PM |
![]() |
![]() |
- Edgar | - 05/22/2023 03:28 PM |
![]() |
![]() |
- Edgar | - 05/22/2023 04:29 PM |
![]() |
![]() |
- Edgar | - 05/22/2023 04:33 PM |
![]() |
![]() |
- kkkwj | - 05/23/2023 03:44 AM |
![]() |
![]() |
- missink | - 05/25/2023 12:40 AM |
![]() |
|
I have a command that does something like saying 'open file <1-3>', And depending on the number I gave The particular file will open. But I also want to have, in the same command, the option 'open all three files'. Is it possible to have something like If ListVar1= "all files" Then AppBringUp... multiple files. I've tried
If ListVar1 = "all files" Then AppBringUp "(file 1)",AppBringUp "(file 2)",AppBringUp "(file 3)"
This is rejected by Dragon. If this is at all possible, how should the syntax of this line be?
|
|
|
|
![]() |
|
The following works on my computer, although I'm getting duplicate windows and I don't know why.
If 11 > 10 Then AppBringUp "C:\Dropbox\install\" AppBringUp "C:\Dropbox\code\Python\" AppBringUp "C:\Dropbox\backup\computer\Dragon\Vocabulary\" End If
This link about if statements may also be useful to you: https://learn.microsoft.com/en-us/office/vba/language/concepts/getting-started/using-ifthenelse-statements |
|
|
|
![]() |
|
It might help if we could see the entire script, including the list. Is this a DVC command or an Advanced Scripting command? You may certainly have a list that looks something like: 1 and code which looks something like:
Sub Main If ListVar1 = "1" Then AppBringUp "C:\1" If ListVar1 = "2" Then AppBringUp "C:\two" If ListVar1 = "3" Then AppBringUp "C:\THIRD" If ListVar1 = "All" Then AppBringUp "C:\1" AppBringUp "C:\two" AppBringUp "C:\THIRD" End If End Sub ------------------------- -Edgar |
|
|
|
![]() |
|
This is my script:
'#Language "WWB-COM" Option Explicit
Sub Main
If ListVar1= "script 1" Then AppBringUp "C:\Users\Anan\Documents\Audacity\script 1 Base Text.aup" If ListVar1= "script 3" Then AppBringUp "C:\Users\Anan\Documents\Audacity\script 3 Base Text.aup"' If ListVar1= "script 4" Then AppBringUp "C:\Users\Anan\Documents\Audacity\script 4 base text.aup" 'If ListVar1 = "all scripts" Then
End If AppBringUp "C:\Users\Anan\Documents\Audacity\script 4 base text.aup" AppBringUp "C:\Users\Anan\Documents\Audacity\script 3 base text.aup" AppBringUp "C:\Users\Anan\Documents\Audacity\script 1 base text.aup" End Sub
(the 'End If' gets added by dragon after typing 'enter' after the Then. If I remove it it won't save the script) |
|
|
|
![]() |
|
thank you, MIssink! I followed your example (Dragon added a line with 'End if' after the 'Then', and I also get duplicates! Very mysterious!
(thank you for the link). |
|
|
|
![]() |
|
The extra line might explain the duplicates. Do you still get duplicates if you slightly revise Edgar's script, to the following?
Sub Main If ListVar1 = "1" Then AppBringUp "C:\1" End If If ListVar1 = "2" Then AppBringUp "C:\two" End If If ListVar1 = "3" Then AppBringUp "C:\THIRD" End If If ListVar1 = "All" Then AppBringUp "C:\1" AppBringUp "C:\two" AppBringUp "C:\THIRD" End If End Sub |
|
|
|
![]() |
|
The Dragon added "End If" is/was optional (at least up to DPI 15.3) IF, and only if, there was only a single statement after the "Then" - it does not hurt anything to include it - it is just a bit of extra typing. As for "get duplicates" - I am not sure exactly what you mean. I am assuming that you are opening folders using Windows Explorer (or whatever it is now being called). In that case, you would need to have a single different window for each folder. Again, show us the code.
------------------------- -Edgar |
|
|
|
![]() |
|
Thank you, Edgar. What I mean by duplicates is that each of these files is (trying to) open twice. and this is a problem, because what I'm opening is Audacity projects, and this program gets a heart attack when the same project is opened twice. (I have 15.6) |
|
|
|
![]() |
|
what I'm opening is Audacity projects, and this program gets a heart attack when the same project is opened twice.
I worked for a number of years on the Audacity project – as a programmer, but mostly on the Documents team. I wrote an extremely sophisticated version of Audacity which is highly configurable; it is both public domain and open source and I would be happy to send you a copy if you would like to play with it. ------------------------- -Edgar |
|
|
|
![]() |
|
Thank you, Alan and Edgar. my revised script now looks like this:
'#Language "WWB-COM" Option Explicit Sub Main If ListVar1= "script 1" Then AppBringUp "C:\Users\Anan\Documents\Audacity\script 1 Base Text.aup" End If If ListVar1= "script 3" Then AppBringUp "C:\Users\Anan\Documents\Audacity\script 3 Base Text.aup"' End If If ListVar1= "script 4" Then AppBringUp "C:\Users\Anan\Documents\Audacity\script 4 base text.aup" End If If ListVar1 = "all scripts" Then AppBringUp "C:\Users\Anan\Documents\Audacity\script 4 base text.aup" AppBringUp "C:\Users\Anan\Documents\Audacity\script 3 base text.aup" AppBringUp "C:\Users\Anan\Documents\Audacity\script 1 base text.aup" End If End Sub And I still get duplicates. :-( |
|
|
|
![]() |
|
Case - Select: https://www.nuance.com/products/help/dragon/dragon-for-pc/scriptref/Content/vbs/select_case_statement.htm -------------------------
|
|
|
|
![]() |
|
Thank you, PG, for your help! pasting this gives me the 'please correct your syntax' error.
'#Language "WWB-COM" Option Explicit Sub Main Select Case ListVar1 Case "script 1" AppBringUp "C:\Users\Anan\Documents\Audacity\script 1 Base Text.aup" Case "script 3" AppBringUp "C:\Users\Anan\Documents\Audacity\script 3 Base Text.aup"' Case "script 4" AppBringUp "C:\Users\Anan\Documents\Audacity\script 4 base text.aup" Case "all scripts" AppBringUp "C:\Users\Anan\Documents\Audacity\script 4 base text.aup" Wait .2 AppBringUp "C:\Users\Anan\Documents\Audacity\script 3 base text.aup" Wait .2 AppBringUp "C:\Users\Anan\Documents\Audacity\script 1 base text.aup" Case Else MsgBox "Script not recognized." EndSelect End Sub And see if that does the dupes, too, . . .
|
|
|
|
![]() |
|
Philip's script appears to be OK. There's a single quote mark at the end of one line, but I don't think that will signal a syntax error as the single quote means the start of a comment.
Let's see your actual script! |
|
|
|
![]() |
|
For the
The typo was Nuance's in the example . . . -------------------------
|
|
|
|
![]() |
|
I agree with PG's usage of the Select/Case construction - easier to read! Now that I know that you are trying to open Audacity projects I will give it a go here (although I do not have mainstream Audacity installed).
------------------------- -Edgar |
|
|
|
![]() |
|
It turns out that PG was on the right track. Audacity has a funky mechanism for making itself “single launch”. I think that the big stumbling block was how long to wait before asking to open another Audacity project. I stumbled around with PG's initial 0.2 wait time getting the exact same duplication problem as the OP posted. '#Language "WWB-COM" Sub Main Select Case ListVar1 Case "1" AppBringUp "Z:\first.aup" Case "2" AppBringUp "Z:\second .aup" Case "3" AppBringUp "Z:\third.aup" Case "All" AppBringUp "D:\mine\win\UnicodeRelease\Audacity.exe", "Z:\first.aup" Wait 2 AppBringUp "Z:\second.aup" Wait 2 AppBringUp "Z:\third.aup" Exit All Case Else MsgBox "Script not recognized." End Select End Sub ------------------------- -Edgar |
|
|
|
![]() |
|
This works: Case "All" AppBringUp "Z:\first.aup" Wait 1 AppBringUp "Z:\second.aup" Wait 1 AppBringUp "Z:\third.aup" Exit All ------------------------- -Edgar |
|
|
|
![]() |
|
FWIW, Alan was correct to spot the leading ' on the script posted by Andantis:
Original script: Sub Main
If ListVar1= "script 1" Then AppBringUp "C:\Users\Anan\Documents\Audacity\script 1 Base Text.aup" If ListVar1= "script 3" Then AppBringUp "C:\Users\Anan\Documents\Audacity\script 3 Base Text.aup"' If ListVar1= "script 4" Then AppBringUp "C:\Users\Anan\Documents\Audacity\script 4 base text.aup" 'If ListVar1 = "all scripts" Then
End If AppBringUp "C:\Users\Anan\Documents\Audacity\script 4 base text.aup" AppBringUp "C:\Users\Anan\Documents\Audacity\script 3 base text.aup" AppBringUp "C:\Users\Anan\Documents\Audacity\script 1 base text.aup" End Sub
But it looks like this if you ignore the comment line:
Sub Main
If ListVar1= "script 1" Then AppBringUp "C:\Users\Anan\Documents\Audacity\script 1 Base Text.aup" If ListVar1= "script 3" Then AppBringUp "C:\Users\Anan\Documents\Audacity\script 3 Base Text.aup"' If ListVar1= "script 4" Then AppBringUp "C:\Users\Anan\Documents\Audacity\script 4 base text.aup" End If
AppBringUp "C:\Users\Anan\Documents\Audacity\script 4 base text.aup" AppBringUp "C:\Users\Anan\Documents\Audacity\script 3 base text.aup" AppBringUp "C:\Users\Anan\Documents\Audacity\script 1 base text.aup" End Sub
And so you can easily see that all three of the trailing App statements will run each time, even if you feed junk into the ListVar1 variable. Of course this comment problem does not apply to the other solutions posted later. Has the duplicate problem been solved yet? ------------------------- Win10/11/x64, AMD Ryzen 7 3700X/3950X, 64/128GB RAM, Dragon 15.3, SP 7 Standard, SpeechStart, Office 365, KB 2017, Dragon Capture, Samson Meteor USB Desk Mic, Amazon YUWAKAYI headset, Klim and JUKSTG earbuds with microphones, excellent Sareville Wireless Mono Headset, 3 BenQ 2560x1440 monitors, Microsoft Sculpt Keyboard and Logitech G502 awesome gaming mouse. |
|
|
|
![]() |
|
Yes, Wait solved the duplicate problem, at least for me. Though I only tested Wait 1 between each AppBringUp, and I was testing with folders, not Audacity files like the OP.
|
|
|
FuseTalk Standard Edition v4.0 - © 1999-2023 FuseTalk™ Inc. All rights reserved.