Skip to content
bergsma edited this page Sep 26, 2014 · 5 revisions

#next

###Rotate elements of a list, making the next element first in the list

Syntax

status = next variable ;

Arguments

  1. list variable

The list variable to rotate.

Return Value

str status
  • $ACKNOWLEDGE : The list has been rotated.

The STATUS variable is set to $ACKNOWLEDGE

  • %UNDEFINED : Cannot do next on 'variable'

The STATUS variable is set to %UNDEFINED

Warnings

  • %UNDEFINED : Cannot do next on 'variable'

Exceptions

  • %ARGUMENT: Invalid arguments. Usage: status = next variable ;

  • %IDENTIFIER: 'variable' argument is not a valid identifier, literal, or reference

Description

The elements of a list are stored internally as a circularly linked list. The next method rotates the elements of a list so that the next element moves up by one index. Thus, the next method is useful for iterating a list variable.

Examples

list L = {
  int a = 1,
  int b = 2,
  int c = 3
};
/* Iterate the elements of L */
n = count L ;
for (i = 0; i < n; i++ ) {
  puts { "Loop ",i } ;
  describe L ;
  next ( L );
}

Related Links

next

Clone this wiki locally