![]() |
KnowBrainer Speech Recognition | ![]() |
Topic Title: Camel Case Topic Summary: A simple, open-ended version Created On: 05/27/2023 03:29 PM Status: Post and Reply |
|
![]() |
![]() |
- Edgar | - 05/27/2023 03:29 PM |
![]() |
![]() |
- awomanonwheels | - 05/31/2023 11:07 AM |
![]() |
![]() |
- awomanonwheels | - 05/31/2023 12:22 PM |
![]() |
![]() |
- Edgar | - 05/31/2023 02:17 PM |
![]() |
![]() |
- Edgar | - 05/31/2023 02:28 PM |
![]() |
![]() |
- awomanonwheels | - 05/31/2023 03:19 PM |
![]() |
![]() |
- Alan Cantor | - 05/31/2023 02:12 PM |
![]() |
![]() |
- awomanonwheels | - 05/31/2023 03:23 PM |
![]() |
![]() |
- Edgar | - 05/31/2023 05:25 PM |
![]() |
![]() |
- awomanonwheels | - 05/31/2023 06:16 PM |
![]() |
|
awomanonwheels said, in a private message… “Hello Edgar, a few years ago you answered a query of mine regarding using a command to camel case two words, with the first word lowercase and the second word capitalized…” Asking about extending this and making it open-ended; then suggested that my reply might be better on the open forum, so… 1) trim all leading and trailing white spaces 2) [the error checking part] handle inappropriate characters* 3) split what is left into an array of individual words 4) force the first letter of the first word to be lowercase 5) force the first letter of all the rest of the words to be uppercase 6) combined all the resulting words together into a single word with no white space '#Language "WWB-COM" Option Explicit Sub Main Dim words() As String' dimension a string array Dim dictation As String Dim k As Integer Dim result As String ' dictation = CleanUpAllErrors (ListVar1) dictation = ListVar1' error checking turns out to be quite complicated words=Split(dictation, " ")' splits ListVar1 based on the space between words ' contrary to most basic arrays, words is zero-based words(0) = LCase(Left(words(0),1)) & Mid(words(0),2)' force the first word to lowercase its first letter For k = 1 To UBound(words)' start at 1 so we ignore the first word words(k) = UCase(Left(words(k),1)) & Mid(words(k),2)' force all the other words to uppercase their first letters Next For k = 0 To UBound(words)' start at 0 so we get all the words result = result & words(k) Next MsgBox result End Sub ------------------------- -Edgar |
|
|
|
![]() |
|
Good morning Edgar,
Thank you so much!!! I have been looking for this since the day I got your reply! Unfortunately I was looking in the wrong areas. I finally thought to do an advanced search for your name. And lo and behold here you are! I cannot wait to implement this code. And I will continue studying Visual Basic so that I can learn how to write this kind of code to help increase my utilization of Dragon. Thank you, again! Maritza |
|
|
|
![]() |
|
click okay click okay Good morning Edgar, I just copied and pasted your code into a new command and I got an "array out of bounds error" at line 15. Did my copy and paste go awry? How can I fix that?
I named my command "Zotz Words" and uttered the command "Zotz Words whiskey tango foxtrot"
|
|
|
|
![]() |
|
Did you name the command: Zotz Words <dictation> so that it has the open-ended dictation ListVar1? '#Language "WWB-COM"
which is said to be “optional”? What version of Dragon are you running? ------------------------- -Edgar |
|
|
|
![]() |
|
And, of course, once you get it working in the MessageBox, you will need to decide how you want to get the result into the target application. Next comes the decision of how you want to actually move the text: SendKeys result, 1 or possibly use SendDragonKeys or SendSystemKeys (it all depends on the target application which works best but SendKeys seems to be generally reliable for most target applications). Clipboard (result) Wait 0.3' for most computers some delay is ' mandatory here but the amount varies considerably SendKeys "^v", 1' if this is not the last line of your script you will need an additional: Wait 0.3' optional ------------------------- -Edgar |
|
|
|
![]() |
|
I am an idiot. I forgot to include <dictation> in the name editor. As soon as I added that the message box popped right up. (The compounded words were beautiful to see) |
|
|
|
![]() |
|
Hi Maritza,
Not sure why Edgar's excellent script isn't working for you. I made my own version based on his, and it does seem to work. My command is called Camel <dictation> Option Explicit Sub Main Dim words() As String ' Dimension a string array Dim dictation, result As String Dim NumberOfWords, k As Integer dictation = LCase(ListVar1) ' Lowercase the whole string words = Split(dictation, " ") ' Split the string based on the space between words NumberOfWords = UBound(words) ' Calculate number of words in the string ' Contrary to most basic arrays, words() is zero-based ' Nothing to do with words(0). It's already lowercase ' Uppercase the rest, starting at words(1) For k = 1 To NumberOfWords words(k) = UCase(Left(words(k),1)) & Mid(words(k),2) ' Uppercase the first letter of other words Next ' Construct the camel-cased result For k = 0 To NumberOfWords result = result & words(k) Next MsgBox result End Sub |
|
|
|
![]() |
|
Hi Alan, |
|
|
|
![]() |
|
It looks like we are off to a good start here now. Notepad++ can be made to be reasonably Dragon-friendly (you will probably need to edit one of your INI files – there was a thread which included the details for this posted in the last couple of days). ------------------------- -Edgar |
|
|
|
![]() |
|
Thank you, Edgar! I will check my local library and see if they have anything in their e-book collection that can help me out.
I have already made adjustments to Notepad++'s INI file so that it would recognize the command "next variable" when there are open and close brackets on the page. Thank you again! Warm regards, Maritza |
|
|
FuseTalk Standard Edition v4.0 - © 1999-2023 FuseTalk™ Inc. All rights reserved.