• Tutorials

  • Home
  • GPDL $CONTINUE Keyword



    Used in a looping structure to skip the remaining code in a loop and continue executing the loop structure. Example:



    $WHILE ( (character = NextCharacter(character)) != ““ )

    {

    $IF ( $Race(character) == “HUMAN“ )

    {

    numHuman =# numHuman +# 1;

    $CONTINUEl

    };

    numNonHuman =# numNonHuman +# 1;

    $CONTINUE;

    };



    Notice that we have a function ( NextCharacter) that loops through all the characters. We want to see how many are human. If the character is human we add one to 'numHuman' and continue the loop to the next character. If it is non-human then we do not execute the $CONTINUE and we add one to the variable 'numNonHuman'. The second '$CONTINUE' works. It continues the loop but there is no code after it in the loop to skip so it is redundant. There are perhaps better ways to write this loop but this one works and demonstrates the use of $CONTINUE.