MODULE index; (*--------------------------------------------------------- File name: index.pm Author: MM Date: 5/18/05 Problem: This program creates a chain(our current configuration) and identifies each item in the chain with it's position (Index). Example of Execution: C:\>p3 index C:\>a Line is: 1 2 3 4 5 6 7 8 ... 1024 Cycles: 1 ID. *) (*---------------------------------------------------------- CONFIGURATION ----------------------------------------------------------*) CONST MAXCELLS=1024; (* MAXCELLS cells in one line *) CONFIGURATION chain[0..(MAXCELLS - 1)]; CONNECTION left: chain [i] -> chain[(i-1) MOD MAXCELLS]; right: chain[i] -> chain[(i+1) MOD MAXCELLS]; (*---------------------------------------------------------- VARIABLES -----------------------------------------------------------*) VAR L: chain OF INTEGER; (* Line always "L#" *) (*-------------------------------------------------------- MAIN -----------------------------------------------------------*) BEGIN L := ID( chain ); (* Index is ID *) (*printing*) WriteString( " Line is: "); WriteLn; WriteInt( L , 2); (* 2 stands for blank space between items *) END index.