VMS Help  —  PASCAL  Declaration Section, Module Finalization
  The TO END DO section allows you to specify a  statement,  in  a
  module,  to be executed after the executable section of the main
  program.

  Syntax:

     TO END DO statement;

  The 'statement' is a VSI Pascal statement.

  The TO END DO section can  only  appear  in  modules,  can  only
  appear  once in a module, and must appear as the last section in
  the declaration section (if appearing together, the TO BEGIN  DO
  section  must  precede  the  TO END DO section at the end of the
  declaration section).

  Example:

  MODULE File_Output;

  VAR
     Out_File : TEXT;
     t        : TIMESTAMP;

  PROCEDURE Test(...); {Executable section...}

  TO BEGIN DO
     OPEN( Out_File, 'foo.dat' );
     END;

  TO END DO
     BEGIN
     GETTIMESTAMP( t );
     WRITELN( 'foo.dat closed at', TIME( t ) );
     CLOSE( Out_File );
     END;
  END.

  This TO END DO section contains statements that print  the  file
  name and closing time.
Close Help