KnowBrainer Speech Recognition
Decrease font size
Increase font size
Topic Title: unexpected scripting error "expecting a var name"
Topic Summary: I have a variable name in an if statement but it still says it's expecting a variable name
Created On: 10/29/2020 11:29 AM
Status: Post and Reply
Linear : Threading : Single : Branch
 unexpected scripting error "expecting a var name"   - Twisted_Code - 10/29/2020 11:29 AM  
 unexpected scripting error   - R. Wilke - 10/29/2020 02:12 PM  
 unexpected scripting error   - PG LTU - 10/29/2020 03:18 PM  
 unexpected scripting error   - R. Wilke - 10/29/2020 03:29 PM  
 unexpected scripting error   - Mav - 10/30/2020 03:40 AM  
 unexpected scripting error "expecting a var name"   - monkey8 - 10/30/2020 10:36 AM  
 unexpected scripting error   - PG LTU - 10/30/2020 04:26 PM  
 unexpected scripting error   - monkey8 - 11/08/2020 09:09 AM  
Keyword
 10/29/2020 11:29 AM
User is offline View Users Profile Print this message

Author Icon
Twisted_Code
Power Member

Posts: 48
Joined: 04/01/2015

I'm trying to expand upon the built-in "new folder" command for Explorer, but I can't figure out why I'm getting a syntax error for this. It looks like I have a variable name but it still wants a variable name? Did I unwittingly break syntax elsewhere? My code so far (the apparent syntax error being on the line with the "Rich Text Document" string) is as follows:

'#Language "WWB.NET"
Imports System
Sub Main
Dim osVer As Version = Environment.OSVersion.Version
If osVer.Major = 6 And osVer.Minor = 2 Then
   If ListVar1 = "Rich Text Document" Then TTSPlayString "placeholder"
   If ListVar1 = "Text Document" Then TTSPlayString "placeholder"
Else
   SendKeys "%f"
   Wait 0.1
   SendKeys "w"
   Wait 0.1
   SendKeys "f"
End If
End Sub

see also, this screenshot

(by the way, your tool for inserting images into posts is broken. It adds an unnecessary [img] block around the URL of the <img> tag)



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

"Don't argue with people who write with digital ink and pay by the kilowatt-hour." ~ Martin Golding

"Sometimes it pays to stay in bed on Monday, rather than spending the rest of the week debugging Monday's code" ~ Dan Salomon

“Talk is cheap. Show me the code.” ~ Linus Torvalds

 10/29/2020 02:12 PM
User is offline View Users Profile Print this message

Author Icon
R. Wilke
Top-Tier Member

Posts: 7399
Joined: 03/04/2007

If it breaks at ListVar1, the problem is with the list most likely.

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



No need to buy if all you want to do is try ...

DragonCapture KB Download (Latest)
DragonCapture Homepage

 10/29/2020 03:18 PM
User is offline View Users Profile Print this message

Author Icon
PG LTU
Top-Tier Member

Posts: 2116
Joined: 03/21/2007

I don't know if KB is different, but in Dragon list names cannot have spaces in them. Try changing the list name to <new_file_types> (unless you already did but it doesn't show in the image) and let us know . . .

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




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.

 10/29/2020 03:29 PM
User is offline View Users Profile Print this message

Author Icon
R. Wilke
Top-Tier Member

Posts: 7399
Joined: 03/04/2007

Good point, PG, although the Commands Editor should already bark when entering it incorrectly, but who knows.


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



No need to buy if all you want to do is try ...

DragonCapture KB Download (Latest)
DragonCapture Homepage

 10/30/2020 03:40 AM
User is offline View Users Profile Print this message

Author Icon
Mav
Top-Tier Member

Posts: 268
Joined: 10/02/2008

I've tried a similar script with plain DPG 15.6 German and don't have any problem with it.

Spaces in list names don't pose a problem either, Dragon simply replaces them with underscores.

 

Could it be VB's idiotic syntax with inline if/then?

With an inline if I must not add an "end if" at the end of the line.

Have you tried writing your inline ifs as multiline blocks with "end if"?

 

hth,

mav

 10/30/2020 10:36 AM
User is offline View Users Profile Print this message

Author Icon
monkey8
Top-Tier Member

Posts: 3642
Joined: 01/14/2008

ListVar1 is a foreign concept to WWB.Net scripting and that's why it doesn't work. List variables are an extension to the WinWrap basic COM scripting engine which I added to KnowBrainer WinWrap Basic COM(the default) and which Dragon have added to advance scripting. Otherwise having spaces in list names with KB is not a problem.

 

We will endeavour to add list variables for WWB .net scripting in the next release of KnowBrainer. In the meantime if you want to use list variables then I suggest the following script with KB. You will obviously need to change the if statement for testing for Windows 10 to windows 8. To do that you will need to try os.Caption with Windows 8 to see what the exact text string is, sorry don't have access to Windows 8 to test.

 

Sub Main
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Set oss = objWMIService.ExecQuery ("Select * from Win32_OperatingSystem")

For Each os In oss
    opSystem = os.Caption
Next
If opSystem = "Microsoft Windows 10 Pro" Then
   If ListVar1 = "Rich Text Document" Then TTSPlayString "placeholder"
   If ListVar1 = "Text Document" Then TTSPlayString "placeholder"
Else
   SendKeys "%f"
   Wait 0.1
   SendKeys "w"
   Wait 0.1
   SendKeys "f"
End If
End Sub


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



 10/30/2020 04:26 PM
User is offline View Users Profile Print this message

Author Icon
PG LTU
Top-Tier Member

Posts: 2116
Joined: 03/21/2007

Well I missed the change from "WWB-COM" to "WWB.NET" where ListVar# isn't implemented. Perhaps try the generic approach with or rather generically using UtilityProvider.ContextValue(#) (which may need to be referenced or the Dragon object retrieved first). Meanwhile, there should be nothing wrong with those in-line ifs (unless again something to do with .Net ver) which are also shown in monkey8's helpful replacement approach.

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




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.

 11/08/2020 09:09 AM
User is offline View Users Profile Print this message

Author Icon
monkey8
Top-Tier Member

Posts: 3642
Joined: 01/14/2008

Context.UtilityProvider is not available via WWB .NET either and as above needs to be added as an extension



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

Statistics
31891 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 641 guests browsing this forum, which makes a total of 642 users using this forum.

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