Go to the first, previous, next, last section, table of contents.

WITH Statement

WITH <id> "=" <expr> { "," <id> "=" <expr> ... } DO <stmts> END

The WITH statement binds identifiers <id> to the value of expressions <expr>. The expressions are evaluated once at the beginning of the statement, and the identifiers are defined only within the scope of the WITH statement. If <expr> is a variable or other writable designator, <id> becomes an alias for it, so modifying <id> modifies the variable it is bound to.

The following example prints the contents of a file "data.txt" on standard output.

WITH rd = IO.OpenRead("data.txt") DO
  WHILE NOT IO.EOF(rd) DO
    IO.Put(IO.GetLine(rd) & "\n");
  END; (* WHILE *)
  Rd.Close(rd);
END; (* WITH *)


Go to the first, previous, next, last section, table of contents.