Errors in UFT functional library

Created following function in shared library, and I'm sure the formatting is correct, there're no empty spaces after each line
'The following function checks whether a date string (dataStr)
'has characters representing MM/DD/YYYY
Function check_data_validity(dateStr)
Dim firstSlashPos, secondSlashPos, mmPart, ddPart, yyyyPart
firstSlashPos = inStr(dateStr , "/")
secondSlashPos = inStrRev(dateStr, "/")
If (firstSlashPos <> 3 or secondSlashPos <> 6) 
Then reporter.ReportEvent micFail, "Format check failed""Date string is missing at least one slash (/)."
check_data_validity = False
Exit Function
End If
mmPart = mid(dateStr, 12)
ddPart = mid(dateStr, firstSlashPos 12)
yyyyPart = mid(dateStr, secondSlashPos  1 , 4)
If mmPart > 12
Then reporter.ReportEvent micFail, "Format Check""The month value is invalid. It exceeds 12."
check_data_validity = False
Exit Function
End If
If ddPart > 31
Then reporter.ReportEvent micFail, "Format Check""The date value is invalid. It exceeds 31."
check_data_validity = False
Exit Function
End If
If yyyyPart < 2000
Then reporter.ReportEvent micFail, "Format Check""The year value is invalid. (Prior to 2000)"
check_data_validity = False
Exit function
End If
check_data_validity = True
End Function

Following errors displayed in UFT

Error 8 Expected end of statement CheckDateFunction C:\Unified Functional Testing\TutorialFunctionalLibraries Mercury Tours
Error 13 Expected 'Then' CheckDateFunction C:\Unified Functional Testing\TutorialFunctionalLibraries Mercury Tours Error
14 Expected statement CheckDateFunction C:\Unified Functional Testing\TutorialFunctionalLibraries Mercury Tours
Error 17 Expected 'End Sub' or'End Function' or 'End Property' CheckDateFunction C:\Unified Functional Testing\TutorialFunctionalLibraries Mercury Tours
Error 18 Expected 'Then' CheckDateFunction C:\Unified Functional Testing\TutorialFunctionalLibraries Mercury Tours
Error 19 Expected statement CheckDateFunction C:\Unified Functional Testing\TutorialFunctionalLibraries Mercury Tours

And few more similar. Please help!!!

Parents
  • wrote:

    If (firstSlashPos <> 3 or secondSlashPos <> 6) 
    Then reporter.ReportEvent micFail, "Format check failed""Date string is missing at least one slash (/)."


    I noticed that you have the If condition split in 2 lines in this function. It errors out because of this.

    Either move the Then part to the line above or use an underscore '_' as below, if you want to split mutiple lines for clarity.

    If (firstSlashPos <> 3 or secondSlashPos <> 6)  Then 
    reporter.ReportEvent micFail, "Format check failed", "Date string is missing at least one slash (/)."
    End If
    
    Or
    
    If (firstSlashPos <> 3 or secondSlashPos <> 6) _
    Then reporter.ReportEvent micFail, "Format check failed", "Date string is missing at least one slash (/)."
    End If
Reply
  • wrote:

    If (firstSlashPos <> 3 or secondSlashPos <> 6) 
    Then reporter.ReportEvent micFail, "Format check failed""Date string is missing at least one slash (/)."


    I noticed that you have the If condition split in 2 lines in this function. It errors out because of this.

    Either move the Then part to the line above or use an underscore '_' as below, if you want to split mutiple lines for clarity.

    If (firstSlashPos <> 3 or secondSlashPos <> 6)  Then 
    reporter.ReportEvent micFail, "Format check failed", "Date string is missing at least one slash (/)."
    End If
    
    Or
    
    If (firstSlashPos <> 3 or secondSlashPos <> 6) _
    Then reporter.ReportEvent micFail, "Format check failed", "Date string is missing at least one slash (/)."
    End If
Children
No Data