HP 3000 Manuals

Migration Examples [ HP Pascal/XL Migration Guide ] MPE/iX 5.0 Documentation


HP Pascal/XL Migration Guide

Chapter 4  Migration Examples 

Program Migration 

The two programs that follow test the MPE file system with INTRINSIC file
access.  The first program is written in Pascal/V, whereas the second
program is written in HP Pascal/XL. The differences between the programs
are highlighted in gray.

     (* Pascal/V *)
     $STANDARD _LEVEL 'HP3000'$
     PROGRAM file_test (input, output); (*tests MPE file system w/INTRINSIC file
                                           access in Pascal/V*)

     TYPE

t_smallint = -32768..32767; 

       string_10 = string [10];

     VAR
       file_buffer:  string [80];
       f_file_num :  integer;
       f_file_num :  integer;
       from_file  :  string_10;
       to_file    :  string_10;
       start_time :  integer;
       finish_time:  integer;
       length     :  integer;

     FUNCTION proctime: integer; INTRINSIC;

FUNCTION fopen:  t_smallint; INTRINSIC;

FUNCTION fread:  t_smallint; INTRINSIC;

     PROCEDURE fclose;            INTRINSIC;

     PROCEDURE fwrite;            INTRINSIC;

     PROCEDURE quit (quit_var: integer);  INTRINSIC;

     PROCEDURE open_file;

     BEGIN
       f_file_num:=fopen (from_file,octal('5'),octal('4'),-80);
       IF ccode <> 2 THEN quit (1);
       t_file_num:= fopen (to_file,octal('5'),octal('4'),-80);
       IF ccode <> 2 THEN quit (2);
     END;

     PROCEDURE close_file;

     BEGIN
       fclose(f_file_num,1,0);
       IF ccode <> 2 THEN quit (5);
       fclose(t_file_num,1,0);
       IF ccode <> 2 THEN quit (6);
     END;

     BEGIN (*begin main program*)
       from_file:= 'fromfile '; to_file:= 'tofile ';
       open_file;
       start_time::=proctime;

     REPEAT
       length:=fread(f_file_num,file_buffer,-80);
       IF ccode = 2 THEN
         BEGIN
           fwrite(t_file_num,file_buffer,-80,0);
           IF ccode <> 2 THEN quit (4);
         END;
     Until ccode = 0;

     finish_time:= proctime;
     close_file;
     (*proctime is processor time (CPU)*)
     (*time is elapsed time (wall clock)*)
     WRITELN ('time elapsed in MPE file system for PASCAL ',
             (finish_time-start_time) DIV 1000:1);
     END.

     (* HP Pascal*)
     PROGRAM file_test (input, output); (*tests MPE file system w/INTRINSIC file
                                           access in Pascal/XL*)

     TYPE
       string_10 = string [10];

     VAR
       file_buffer:  string [80];
       f_file_num :  integer;
       f_file_num :  integer;
       from_file  :  string_10;
       to_file    :  string_10;
       start_time :  integer;
       finish_time:  integer;
       length     :  integer;

     FUNCTION proctime: integer; INTRINSIC;

FUNCTION fopen:  shortint; INTRINSIC;

FUNCTION fread:  shortint; INTRINSIC;

     PROCEDURE fclose;            INTRINSIC;

     PROCEDURE fwrite;            INTRINSIC;

     PROCEDURE quit (quit_var: integer);  INTRINSIC;

     PROCEDURE open_file;

     BEGIN
       f_file_num:=fopen (from_file,octal('5'),octal('4'),-80);
       IF ccode <> 2 THEN quit (1);
       t_file_num:= fopen (to_file,octal('5'),octal('4'),-80);
       IF ccode <> 2 THEN quit (2);
     END;

     PROCEDURE close_file;

     BEGIN
       fclose(f_file_num,1,0);
       IF ccode <> 2 THEN quit (5);
       fclose(t_file_num,1,0);
       IF ccode <> 2 THEN quit (6);
     END;

     BEGIN (*begin main program*)

       from_file:= 'fromfile '; to_file:= 'tofile ';
       open_file;
       start_time:= proctime;

     REPEAT
       length:= fread(f_file_num,file_buffer,-80);
       IF ccode = 2 THEN
         BEGIN
           fwrite(t_file_num,file_buffer,-80,0);
           IF ccode <> 2 THEN quit (4);
         END;
     Until ccode = 0;

     finish_time:= proctime;
     close_file;
     (*proctime is processor time (CPU)*)
     (*time is elapsed time (wall clock)*)
     WRITELN ('time elapsed in MPE file system for PASCAL',
             (finish_time-start_time) DIV 1000:1);
     END.


MPE/iX 5.0 Documentation