Sign in to follow this  
Followers 0
WhOOt

Help - How can I

7 posts in this topic

#1 ·  Posted (edited)

I found out! :o

Now I just need to find out, how I can stop the script;

while 1
        $i = $i + 1
    _TalkOBJ($besked1[$i], 3)
    if @error then exitloop
        
wend

The if @error then exitloop doesn't work, I guess because it isn't stated as an error?

Edited by WhOOt

Share this post


Link to post
Share on other sites



What is _TalkOBJ?

Does its documentation detail that it set @error?

Need more details to help.


“Give a man a script; you have helped him for today. Teach a man to script; and you will not have to hear him whine for help.”AutoIt4UE - Custom AutoIt toolbar and wordfile for UltraEdit/UEStudio users.AutoIt Graphical Debugger - A graphical debugger for AutoIt.SimMetrics COM Wrapper - Calculate string similarity.

Share this post


Link to post
Share on other sites

What is _TalkOBJ?

Does its documentation detail that it set @error?

Need more details to help.

Yea, sorry :o

Func _TalkOBJ($s_text, $s_voice = 3)
    Local $o_speech = ObjCreate ("SAPI.SpVoice")
        Select
            Case $s_voice == 1
                $o_speech.Voice = $o_speech.GetVoices("Name=Microsoft Mary", "Language=409").Item(0)
            Case $s_voice == 2
                $o_speech.Voice = $o_speech.GetVoices("Name=Microsoft Mike", "Language=409").Item(0)
            Case $s_voice == 3
                $o_speech.Voice = $o_speech.GetVoices("Name=Microsoft Sam", "Language=409").Item(0)
                $o_speech.rate = 3
        EndSelect
    $o_speech.Speak ($s_text)
    $o_speech = ""
EndFunc ;==>_TalkOBJ

Share this post


Link to post
Share on other sites

For one thing, you should add error detection after the creation of the object. Refer to the help file under the ObjCreate function for detials.

Under what condition do you actually want to end?

As for trying to catch a COM object error, you script will end. This is detailed in the help file: "An AutoIt script will immediately stop execution when it detects a COM error. This is the default and also the safest setting. In this case you have to take measures in your script to prevent the error from happening.".

Ideally, you should not wait for an error to occur, you should use any features available with the object to determine when you are done. As I don't know the object you are using, I would suggest searching the forums for other scripts using the same object. I think I remember seeing some.


“Give a man a script; you have helped him for today. Teach a man to script; and you will not have to hear him whine for help.”AutoIt4UE - Custom AutoIt toolbar and wordfile for UltraEdit/UEStudio users.AutoIt Graphical Debugger - A graphical debugger for AutoIt.SimMetrics COM Wrapper - Calculate string similarity.

Share this post


Link to post
Share on other sites

Yea :o

But what I wanna find an error for is;

$besked = clipget()
    $besked1 = stringreplace($besked, "?", ".")
    $besked2 = stringreplace($besked1, "!", ".")
    $besked3 = stringreplace($besked2, ",", ".")
    $besked4 = stringsplit($besked3, "." )


while 1
        $i = $i + 1
    _TalkOBJ($besked4[$i], 3)
    if @error then exitloop
        
wend

I wanna check, if $besked4[] is extended --> if there are 4 words split by the stringsplit then it shouldn't go on, trying to read 5 and 6

This is the error I get

==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: 
_TalkOBJ($besked4[$i], 3)

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Yea :o

But what I wanna find an error for is;

$besked = clipget()
    $besked1 = stringreplace($besked, "?", ".")
    $besked2 = stringreplace($besked1, "!", ".")
    $besked3 = stringreplace($besked2, ",", ".")
    $besked4 = stringsplit($besked3, "." )
while 1
        $i = $i + 1
    _TalkOBJ($besked4[$i], 3)
    if @error then exitloop
        
wend

I wanna check, if $besked4[] is extended --> if there are 4 words split by the stringsplit then it shouldn't go on, trying to read 5 and 6

This is the error I get

==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: 
_TalkOBJ($besked4[$i], 3)
If I understand you right, you want this:

$besked = clipget()
    $besked1 = stringreplace($besked, "?", ".")
    $besked2 = stringreplace($besked1, "!", ".")
    $besked3 = stringreplace($besked2, ",", ".")
    $besked4 = stringsplit($besked3, "." )


For $iIndex = 0 To UBound($besked4) - 1
    _TalkOBJ($besked4[$iIndex], 3)
Next

Better to not generate an error, than to try and catch one.

Edited by Stumpii

“Give a man a script; you have helped him for today. Teach a man to script; and you will not have to hear him whine for help.”AutoIt4UE - Custom AutoIt toolbar and wordfile for UltraEdit/UEStudio users.AutoIt Graphical Debugger - A graphical debugger for AutoIt.SimMetrics COM Wrapper - Calculate string similarity.

Share this post


Link to post
Share on other sites

If I understand you right, you want this:

$besked = clipget()
    $besked1 = stringreplace($besked, "?", ".")
    $besked2 = stringreplace($besked1, "!", ".")
    $besked3 = stringreplace($besked2, ",", ".")
    $besked4 = stringsplit($besked3, "." )
For $iIndex = 0 To UBound($besked4) - 1
    _TalkOBJ($besked4[$iIndex], 3)
Next

Better to not generate an error, than to try and catch one.

Thanks alot mate! this is just what I'm looking for!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0