KnowBrainer Speech Recognition
Decrease font size
Increase font size
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
Linear : Threading : Single : Branch
 script that opens multiple files   - Anandits - 05/22/2023 01:15 AM  
 script that opens multiple files   - missink - 05/22/2023 07:06 AM  
 script that opens multiple files   - Edgar - 05/22/2023 10:09 AM  
 script that opens multiple files   - Anandits - 05/22/2023 10:20 AM  
 script that opens multiple files   - Anandits - 05/22/2023 10:10 AM  
 script that opens multiple files   - Alan Cantor - 05/22/2023 10:18 AM  
 script that opens multiple files   - Edgar - 05/22/2023 10:20 AM  
 script that opens multiple files   - Anandits - 05/22/2023 10:39 AM  
 script that opens multiple files   - Edgar - 05/22/2023 03:22 PM  
 script that opens multiple files   - Anandits - 05/22/2023 10:32 AM  
 script that opens multiple files   - PG LTU - 05/22/2023 11:41 AM  
 script that opens multiple files   - Anandits - 05/22/2023 11:49 AM  
 script that opens multiple files   - Alan Cantor - 05/22/2023 12:26 PM  
 script that opens multiple files   - PG LTU - 05/22/2023 12:48 PM  
 script that opens multiple files   - Edgar - 05/22/2023 03:28 PM  
 script that opens multiple files   - Edgar - 05/22/2023 04:29 PM  
 script that opens multiple files   - Edgar - 05/22/2023 04:33 PM  
 script that opens multiple files   - kkkwj - 05/23/2023 03:44 AM  
 script that opens multiple files   - missink - 05/25/2023 12:40 AM  
Keyword
 05/22/2023 01:15 AM
User is offline View Users Profile Print this message

Author Icon
Anandits
Advanced Member

Posts: 188
Joined: 03/25/2019

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?


 05/22/2023 07:06 AM
User is offline View Users Profile Print this message

Author Icon
missink
Power Member

Posts: 62
Joined: 03/28/2015

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

 05/22/2023 10:09 AM
User is offline View Users Profile Print this message

Author Icon
Edgar
Top-Tier Member

Posts: 1405
Joined: 04/03/2009

Originally posted by: Anandits I have a command

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
2
3
All

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
DPI 15.3, 64-bit Windows 10 Pro, OpenOffice & Office 365, Norton Security, Shure X2U XLR to USB mic adapter with Audio Technica DB135 vocal mic & Shokz OpenComm UC version 1 wireless headset, Asus X299-Deluxe Prime, Intel Core i9-7940X (14 core, 4.3 GHz overclocked to 4.9 GHz), G.SKILL TridentZ Series 64GB (4 x 16GB) DDR4 3333 (PC4 26600) F4-3333C16Q-64GTZ, NVIDIA GIGABYTE GeForce GTX 1060 GV-N1060G1 GAMING-6GD REV 2.0 6GB graphics card with 3 1920x1080 monitors

 05/22/2023 10:20 AM
User is offline View Users Profile Print this message

Author Icon
Anandits
Advanced Member

Posts: 188
Joined: 03/25/2019

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)

 05/22/2023 10:10 AM
User is offline View Users Profile Print this message

Author Icon
Anandits
Advanced Member

Posts: 188
Joined: 03/25/2019

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).



 05/22/2023 10:18 AM
User is offline View Users Profile Print this message


Alan Cantor
Top-Tier Member

Posts: 4616
Joined: 12/08/2007

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
 05/22/2023 10:20 AM
User is offline View Users Profile Print this message

Author Icon
Edgar
Top-Tier Member

Posts: 1405
Joined: 04/03/2009

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
DPI 15.3, 64-bit Windows 10 Pro, OpenOffice & Office 365, Norton Security, Shure X2U XLR to USB mic adapter with Audio Technica DB135 vocal mic & Shokz OpenComm UC version 1 wireless headset, Asus X299-Deluxe Prime, Intel Core i9-7940X (14 core, 4.3 GHz overclocked to 4.9 GHz), G.SKILL TridentZ Series 64GB (4 x 16GB) DDR4 3333 (PC4 26600) F4-3333C16Q-64GTZ, NVIDIA GIGABYTE GeForce GTX 1060 GV-N1060G1 GAMING-6GD REV 2.0 6GB graphics card with 3 1920x1080 monitors

 05/22/2023 10:39 AM
User is offline View Users Profile Print this message

Author Icon
Anandits
Advanced Member

Posts: 188
Joined: 03/25/2019

Originally posted by: Edgar 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.

 

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)

 05/22/2023 03:22 PM
User is offline View Users Profile Print this message

Author Icon
Edgar
Top-Tier Member

Posts: 1405
Joined: 04/03/2009

Originally posted by: Anandits 

 

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.

I still don't understand how your script is opening duplicates. Are you saying that your script, in attempting to run multiple copies of Audacity, causes Audacity to have problems? It has been a number of years now since I left the Audacity project behind so I have no idea what the current code base does. However, I do recall that one of the major changes that I made for my version was to improve upon Audacity’s limited ability to handle importing multiple files.

Again, please show us your entire script…



-------------------------

-Edgar
DPI 15.3, 64-bit Windows 10 Pro, OpenOffice & Office 365, Norton Security, Shure X2U XLR to USB mic adapter with Audio Technica DB135 vocal mic & Shokz OpenComm UC version 1 wireless headset, Asus X299-Deluxe Prime, Intel Core i9-7940X (14 core, 4.3 GHz overclocked to 4.9 GHz), G.SKILL TridentZ Series 64GB (4 x 16GB) DDR4 3333 (PC4 26600) F4-3333C16Q-64GTZ, NVIDIA GIGABYTE GeForce GTX 1060 GV-N1060G1 GAMING-6GD REV 2.0 6GB graphics card with 3 1920x1080 monitors

 05/22/2023 10:32 AM
User is offline View Users Profile Print this message

Author Icon
Anandits
Advanced Member

Posts: 188
Joined: 03/25/2019

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. :-(
 05/22/2023 11:41 AM
User is offline View Users Profile Print this message

Author Icon
PG LTU
Top-Tier Member

Posts: 2272
Joined: 03/21/2007

Case - Select: https://www.nuance.com/products/help/dragon/dragon-for-pc/scriptref/Content/vbs/select_case_statement.htm

'#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."
   End Select
End Sub


And see if that does the dupes, too, . . .



-------------------------




PG





Remember folks, my comments and this forum are for entertainment value only, please, no wagering or other reliance on the contents herein.  I permit no commercial use of my ideas (whether expressions or embodiments) without my written consent.



 05/22/2023 11:49 AM
User is offline View Users Profile Print this message

Author Icon
Anandits
Advanced Member

Posts: 188
Joined: 03/25/2019

Thank you, PG, for your help! 

pasting this gives me the 'please correct your syntax' error. 

 

 

Originally posted by: PG LTU Case - Select: https://www.nuance.com/products/help/dragon/dragon-for-pc/scriptref/Content/vbs/select_case_statement.htm '#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, . . .

 

 05/22/2023 12:26 PM
User is offline View Users Profile Print this message


Alan Cantor
Top-Tier Member

Posts: 4616
Joined: 12/08/2007

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!
 05/22/2023 12:48 PM
User is offline View Users Profile Print this message

Author Icon
PG LTU
Top-Tier Member

Posts: 2272
Joined: 03/21/2007

For the endselect add a space between End and Select

 

The typo was Nuance's in the example . . .



-------------------------




PG





Remember folks, my comments and this forum are for entertainment value only, please, no wagering or other reliance on the contents herein.  I permit no commercial use of my ideas (whether expressions or embodiments) without my written consent.



 05/22/2023 03:28 PM
User is offline View Users Profile Print this message

Author Icon
Edgar
Top-Tier Member

Posts: 1405
Joined: 04/03/2009

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
DPI 15.3, 64-bit Windows 10 Pro, OpenOffice & Office 365, Norton Security, Shure X2U XLR to USB mic adapter with Audio Technica DB135 vocal mic & Shokz OpenComm UC version 1 wireless headset, Asus X299-Deluxe Prime, Intel Core i9-7940X (14 core, 4.3 GHz overclocked to 4.9 GHz), G.SKILL TridentZ Series 64GB (4 x 16GB) DDR4 3333 (PC4 26600) F4-3333C16Q-64GTZ, NVIDIA GIGABYTE GeForce GTX 1060 GV-N1060G1 GAMING-6GD REV 2.0 6GB graphics card with 3 1920x1080 monitors

 05/22/2023 04:29 PM
User is offline View Users Profile Print this message

Author Icon
Edgar
Top-Tier Member

Posts: 1405
Joined: 04/03/2009

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.

I tried also using ShellExecute with the same results. I tried passing multiple Audacity projects at once but, while Audacity handles multiple audio files, it will not handle multiple projects as commandline arguments. I even tried calling the fully qualified executable with a single project (you may see the remnants of that as the first statement of the “All” Case) multiple times.

The 2 second wait time might be extreme – it will vary and might even need to be longer on slower computers.

'#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
DPI 15.3, 64-bit Windows 10 Pro, OpenOffice & Office 365, Norton Security, Shure X2U XLR to USB mic adapter with Audio Technica DB135 vocal mic & Shokz OpenComm UC version 1 wireless headset, Asus X299-Deluxe Prime, Intel Core i9-7940X (14 core, 4.3 GHz overclocked to 4.9 GHz), G.SKILL TridentZ Series 64GB (4 x 16GB) DDR4 3333 (PC4 26600) F4-3333C16Q-64GTZ, NVIDIA GIGABYTE GeForce GTX 1060 GV-N1060G1 GAMING-6GD REV 2.0 6GB graphics card with 3 1920x1080 monitors

 05/22/2023 04:33 PM
User is offline View Users Profile Print this message

Author Icon
Edgar
Top-Tier Member

Posts: 1405
Joined: 04/03/2009

This works:

      Case "All"
         AppBringUp "Z:\first.aup"
         Wait 1
         AppBringUp "Z:\second.aup"
         Wait 1
         AppBringUp "Z:\third.aup"
         Exit All


-------------------------

-Edgar
DPI 15.3, 64-bit Windows 10 Pro, OpenOffice & Office 365, Norton Security, Shure X2U XLR to USB mic adapter with Audio Technica DB135 vocal mic & Shokz OpenComm UC version 1 wireless headset, Asus X299-Deluxe Prime, Intel Core i9-7940X (14 core, 4.3 GHz overclocked to 4.9 GHz), G.SKILL TridentZ Series 64GB (4 x 16GB) DDR4 3333 (PC4 26600) F4-3333C16Q-64GTZ, NVIDIA GIGABYTE GeForce GTX 1060 GV-N1060G1 GAMING-6GD REV 2.0 6GB graphics card with 3 1920x1080 monitors

 05/23/2023 03:44 AM
User is offline View Users Profile Print this message

Author Icon
kkkwj
Top-Tier Member

Posts: 1137
Joined: 11/05/2015

FWIW, Alan was correct to spot the leading ' on the script posted by Andantis:
'If ListVar1 = "all scripts" Then

It's a BIG problem, because then the following EndIf closes the third if and runs the trailing three AppBringUps.

 

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.



 05/25/2023 12:40 AM
User is offline View Users Profile Print this message

Author Icon
missink
Power Member

Posts: 62
Joined: 03/28/2015

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.
KnowBrainer Speech Recognition » Dragon Speech Recognition » script that opens multiple files

Statistics
32617 users are registered to the KnowBrainer Speech Recognition forum.
There are currently 1 users logged in.
The most users ever online was 12124 on 09/09/2020 at 04:59 AM.
There are currently 114 guests browsing this forum, which makes a total of 115 users using this forum.

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