BREAK

Contents


Break is used to quit one or more loops.

 

Syntax

   Break [ exp_ent ]

Parameters

Element

Description

Restrictions

exp_ent

Integer expression whose value gives the number of nested loops from which to escape.

exp_ent >= 0
exp_ent < existing number of nestings.

 

Examples

   # Extract from a process including labels CALCUL and SUITE.
  # The loop continues as long as the variable FIN returns the value false.
  # It will be interrupted by a value returned by the sub-programme CALCUL.   
  Repeat
      Call CALCUL([V]RESULTAT)
     Break ( [V]RESULTAT = [V]OK ) :# If [V]RESULTAT=[V]OK: Break :Endif
      Gosub SUITE
    Until [V]FIN   
# Search for an element in a scaled variable. The loop is interrupted if the value is found.   
   Integer  MATRICE(2,3)
    For I=0 To dim([V]MATRICE,1) - 1
           For J=0 To dim([V]MATRICE,2) - 1
                   If [V]MATRICE = VALEUR
                      [V]TROUVE = [V]VRAI
                      Break 2
                   Endif
           Next J
    Next I

 

Description and comments

The instruction Break is used in For, While and Repeat loops when execution is to be interrupted on fulfilment of a
condition. Write
Break for simple loops. If there are several nested loops, specify the number of levels from which to quit. Note that this is the same as writing Break or Break 1, and the instruction Break 0 does nothing.

 

Associated errors

Error

Description

ERDOM (50)

exp_ent has a negative value, or one greater than the number of loop nestings.

ERMODE (10)

exp_ent is not a numerical expression.

 

Associated key words

WHILE - REPEAT - FOR


CONTENTS


Copyright © Sage 1999 - 2007