Dave,
Use this for replace.
The old string is replace with new string.
strMsg = Replace(strMsg, str_Old, str_New)
Bruce
Sent: Sunday, August 21, 2011 9:30 AM
Subject: Re: Guess I am on the wrong Event?
Thanks, Chip!
You really got me going now. Seems I am closing in on something here with my
app.
I do have a couple more questions, for you app-techies.
First of all, is there a replacing command - in VBS? I.e, if I have the string:
The sun is shining today.
And I want to replace the word IS, with the words HAS BEEN - hence my string
would read:
The sun has been shining today.
Of course, I could have meddled with some MID-commands here, but just wondered
if there is an easier way. My memory tells me, I did read about a Replace
command somewhere, but can't find that documentation now; so hope for someone
of you to have better memory. If there is, please provide the full syntax for
the command.
My other question, is maybe somehow more tricky. If I find a character - by
using the InStr command - inside a string. Maybe that character is in the
middle of a word. I want to find the space character immediately before the
word. Let's have an example:
I have the string:
The rain is falling.
I want to find - and speak - the word that holds the character "n" in it; in
this case the first word would be RAIN.
I use the following commands:
S = "The rain is falling."
X = InStr( S, "n")
Now I found the first position of the character N. But is there a good way of
finding the beginning of that word "rain"? Only way I can come up with, is to
make some kind of a loop, testing each character to the left of the N, until I
hit an empty (space) character. Then add on 1, so as to land on the first
character of the word. Then, of course, if I want the full word, I would need
to do the same to the right of the N character. Finally, with my beginning and
ending positions set, to use the MID-command, to copy the word. Anyone else,
have an idea of an easy way to find the beginning of the word?
Thanks again,
----- Original Message -----
From: Chip Orange
To: [email protected]
Sent: Sunday, August 21, 2011 4:06 AM
Subject: RE: Guess I am on the wrong Event?
Hi David,
your idea is correct, but you've got the wrong event of the speech object.
There are actually 9 of these events, each one representing a different type of
processing which can be done on the string about to be spoken.
These events aren't documented well in my opinion (there's very little
explanation as to what exactly each one does). There's also little explanation
which explains that if you want to intercept speech and do processing on it,
you'll need to figure out which kind of processing you are doing (type being
compared to the type of processing represented by these 9 different events).
Since you are wanting to do something based on a single character which is
not alpha-numeric, you'll need to use the OnProcessCharacterDictionaries event,
in order to be able to see the string about to be spoken, before the
punctuation is replaced by text strings.
Just change events and I think it will work for you.
hth,
Chip
------------------------------------------------------------------------------
From: David [mailto:[email protected]]
Sent: Saturday, August 20, 2011 6:19 PM
To: [email protected]
Subject: Guess I am on the wrong Event?
Hi scripters,
I am trying to make an app that handles fractional numbers. That is, have it
speak the word "Fractional", when it reaches numbers like 1/4. Below is a snip
of my code. My thought was to connect to the Speech/OnSpeak event, and simply
check if there is a SLASH in the original string. But that seems not to work.
When things like 1/2, 2/3 or 3/4 occurs, it seems that the OnSpeak string is
broken into two seperate strings, by Window-Eyes. Not sure why GW would do such
a thing, but that seems to be the case. In other words, the 1/3, will be broken
into two strings: "1", and "3". This causes, far as I can see, Window-Eyes not
to ever 'see' the slash inbetween; hence my code never works.
Am I connecting to the wrong event? Is there a better approach to the matter?
---Snip of code---
ConnectEvent Speech, "OnSpeak", "MOnSpeak"
Function MOnSpeak( OriginalString )
If InStr(OriginalString, "4") Then OriginalString = "Fractional, " &
OriginalString
MOnSpeak = OriginalString
End Function 'MOnSpeak.
----End of snip----
Speak "Fractional, is running."