beautypg.com

Error handling, Error handling -12 – Sensaphone SCADA 3000 Users manual User Manual

Page 198

background image

16-12

SCADA 3000 User’s Manual

4)

for (x=0;x<60;x=x+1)

This line initializes the index variable (x) to zero, checks to see if it is less than 60, runs the next

line, and then increments x by one. This line creates a loop that runs the following line until x

reaches 60.
5)

total = total + numbers[x];

This line of the program is very important. It eliminates having sixty lines of programming to

get a total of all the minute readings. The x serves to automatically read in the next value for

each element in the array. For example:

The value of x is 6 (meaning it is minute 6, incremented in step

4).

The value of input 0 for minute 6 will be read into the array

and added to the total of the other 5 minutes.

The value of input 0 at minute 6 is 70.

Therefore: numbers[6] = 70

If the previous total was, say 351, then: total = 351 +

70

The new total is 421: total = 421

6)

When x reaches 60, the FOR loop is finished and the average is calculated.

average = total/60;

eRROR HANDLING

When a program is compiled it is scanned for language related errors. When an error is

encountered, the ERROR is displayed followed by the line number. The line number may not

be the exact line that contains the error. Sometimes an error is detected a line or two after the

actual mistake. If an error occurs while compiling, the compiler aborts. It is possible to pass

the compiler with no errors, but receive an error when the program is running. A run time

error occurs when the syntax of a built-in function is incorrect. When a run time error occurs,

the program will not run correctly.
Listed below are the possible compiling errors:

Description

Syntax

Semicolon expected

Unbalanced braces

Parentheses expected

While expected

Quote expected

Variable not found

Too many variables defined (limit is 1024)

Bracket expected

Compiled file too big

Reserved word declared as variable