Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AVEVA™ InTouch HMI

Force the end of a loop

  • Last UpdatedJul 23, 2024
  • 1 minute read

You can exit a loop at any time by calling the following statement:

EXIT FOR;

This statement causes script execution to continue at the statement immediately following the loop NEXT statement.

Example

The following code fragment uses a loop to insert a large number of dummy records into a database table. If there is an error inserting a record, the loop is aborted to prevent creating more errors.

FOR Counter = 1 TO 1000

ResultCode = SQLInsert(ConnectionID, "BatchDetails", "BindList1");

IF ResultCode <> 0 THEN

LogMessage("Error creating records! Aborting...");

EXIT FOR;

ENDIF;

NEXT;

Related Links
TitleResults for “How to create a CRG?”Also Available in