This blog post provides some basic information for beginners to find and fix a simple syntax error in TestComplete 4.
One of the most common scripting errors is to leave a quote off of a string or forget to use quotes altogether. Let's take a new project, add a missing quote error and then we'll find and fix it:
- Start TestComplete 4 and click File on the Menu bar then select New and click New Project.
- Click OK in the Create New Project dialog, then select Finish in the Project Wizard.
- Double-click Unit1 in the Project Explorer to load it in the Code Editor.
- Replace
' Enter your code here.
with Log.Message(Syntax Error).
The script body should now look like this listing:
TestComplete automatically detects common syntax errors as you type. This new line has missing quotes, TestComplete 4 detects the error and displays a red error icon in the Code Editor's gutter next to the line. To view the error description, place the mouse over the red error icon.
Code Editor
The error description displays:
At “Sub Main)
Log.Message(Syntax Error”
error 100: SYNTAX ERROR while processing “Error”.
It's normal for compilers, or in this case the editor, to be confused when they find a missing opening or closing character. One important hint is the At “Sub Main) and Log.Message(Syntax Error” lines of the error code. This lets you know that the "" characters are missing from the script line.
To fix the syntax error enter the "" characters into the Log.Message(Syntax Error)
script line. The script line now reads Log.Message("Syntax Error")
and the error mark in the gutter is now gone.
You can find more help with syntax errors in the TestComplete 4 Checking Syntax help file topic. You can access it by the help file's table of contents (Using TestCompleteScriptingCode EditorChecking Syntax).