Tim,

Try doing an Exit Function after setting GetNowTime to "No project open." If I recall, VBScript doesn't immediately exit the routine when you "return" by setting the function name equal to a value unless you specifically tell it to.

In addition, be sure to turn of your error handling if it's not needed anymore, before you exit, and after the ending if, like this:

On Error Resume Next
Set myClips = ActiveMDIChild.Clips(1)
If Err.Number > 0 Then
        GetNowTime = "No project open"
        On Error Goto 0
        Exit Function
Else
        blah
End If
On Error Goto 0

Aaron

Tim Burgess wrote:
Hi,

I'm getting to grips with run-time errors in my effort to port the Jaws
scripts for Sonar to Window Eyes, but I'm baffled as to what is happening in
the code I've listed below.  If an MDIChild window exists, then all is well
and I get the results I expect, but the function returns an empty string
when an error is encountered (i.e. when no MDIChild window is present).
This seems to indicate that the condition (If Err.Number > 0 Then) is
operating correctly, so why isn't the assignment working (GetNowTime = "No
project open")?
Function GetNowTime
        Dim myClips
        Dim clipObj

GetNowTime = ""
        
        'Get all the clips for the active window
On Error Resume Next
Set myClips = ActiveMDIChild.Clips(1)
If Err.Number > 0 Then GetNowTime = "No project open"
Else
        For Each clipObj In myClips
                If TypeName(clipObj) <> "Empty" Then
                        If clipObj.Type = ctText Then
                                Dim firstChar : firstChar =
Asc(Left(clipObj.Text, 1))
                                If firstChar > 47 And firstChar < 58 Then '
Make sure it's a digit
                                        If clipObj.FontStyle = fsBold And
clipObj.FontSize > 24 Then ' Make sure it's big bold text
                                                GetNowTime = clipObj.Text
                                        End If
                                End If
                        End If
                End If
        Next
End If
End Function

Best wishes.

Tim Burgess
Raised Bar Ltd
PO Box 4442
Atherstone
Warwickshire
CV9 9AT

Phone:  +44 (0)1827 719822
Email:  [EMAIL PROTECTED]
Web:  http://www.raisedbar.net

Don't forget to vote for improved access to music and music technology at

http://www.raisedbar.net/petition.htm

--
To insure that you receive proper support, please include all past
correspondence (where applicable), and any relevant information
pertinent to your situation when submitting a problem report to the GW
Micro Technical Support Team.

Aaron Smith
GW Micro
Phone: 260/489-3671
Fax: 260/489-2608
WWW: http://www.gwmicro.com
FTP: ftp://ftp.gwmicro.com
Technical Support & Web Development

Reply via email to