VMS Help
PASCAL, Statements, WITH

 *Conan The Librarian (sorry for the slow response - running on an old VAX)

  The  WITH  statement  provides  an  abbreviated   notation   for
  references  to  the fields of a record variable or to the formal
  discriminants of a discriminated schema type.

  Syntax:

     WITH {record-variable | schema-variable},... DO
        statement

  The 'record-variable' is the name of the record  variable  being
  referenced.

  The 'schema-variable' is the name of the schema  variable  being
  referenced  whose  type  is  a  discriminated schema type.  This
  underlying type of the schema can be a record.

  The 'statement' is any Compaq Pascal statement.

  The WITH statement allows you to refer to the fields of a record
  or  to  an formal discriminant of a schema by their names alone,
  rather    than     by     the     record.field-identifier     or
  schema-variable.formal-discriminant syntax.  In effect, the WITH
  statement  opens  the  scope  so  that   references   to   field
  identifiers  or  to  formal discriminants alone are unambiguous.
  When you access a variable using a WITH statement, the reference
  syntax lasts only throughout the execution of the statement.

  If you are specifying nested records, their variable names  must
  appear in the order in which they were nested in the record type
  definition.  If you are working with record and schema variables
  that  are  not  nested,  you  can  specify variable names in any
  order.  If you specify record or schema  variables  whose  field
  names  or formal discriminants conflict with one another, Compaq
  Pascal uses the last record or schema in the comma list.

  1 - Examples

  Example:

     WITH Cat, Dog DO
        Bills := Bills + Cat_vet + Dog_vet;

  where 'Cat' and 'Dog' are records and 'Cat_vet' is  a  field  of
  'Cat' and 'Dog_vet' is a field of 'Dog'.

  Example:

     VAR
        x : STRING( 10 );
        y : STRING( 15 );

     WITH x, y DO
        WRITELN( CAPACITY );

  Compaq Pascal uses the last schema variable specified,  y.   The
  WRITELN statement prints y.CAPACITY.
  Close     HLB-list     TLB-list     Help  

[legal] [privacy] [GNU] [policy] [netiquette] [sponsors] [FAQ]
Tweet
Polarhome, production since 1999.
Member of Polarhome portal.