comp.lang.ada
 help / color / mirror / Atom feed
* Re: VAX Ada sequential IO and Direct IO - (nf)
       [not found] <114127553@jade.UUCP>
@ 1987-04-22 10:15 ` systeam
  0 siblings, 0 replies; only message in thread
From: systeam @ 1987-04-22 10:15 UTC (permalink / raw)



If you have problems with Ada Sequential IO and Direct IO
you may use our validated Ada Compiler version 1.6A for VAX/VMS.

As the following example shows it has no problems with these Ada features.

For obvious reasons a use_error would be raised if you would try to create
a "real" direct file of type dir_io.file_type.
But if you use an index-sequential file to implement this direct file then
no problem arises. You can get an index-sequential file when using a form
parameter in the create operation.

We also played with Tony Alden's "even if I restrict the range of 'a' ..." 
remark for the Direct IO case (cf. cdir_f).

My address:

   Dr. Peter Dencker
   SYSTEAM KG Dr. Winterstein
   Am Rueppurer Schloss 7
   D 7500 Karlsruhe 51
   West Germany

   UUCP-mail:  systeam@gmdka


Ada Example:
------------

WITH text_io; USE  text_io;
WITH sequential_io;
WITH direct_io;

PROCEDURE unconstr_io IS

   TYPE foo(a : integer) IS
      RECORD
         f1 : string (1..a);
      END RECORD;

   item3 : foo (3) := (a => 3, f1 => "abc");
   item4 : foo (4) := (a => 4, f1 => "1234");

   SUBTYPE int IS integer RANGE 1 .. 150;

   TYPE cfoo(a : int) IS  -- discriminant with restricted subtype
      RECORD
         f1 : string (1..a);
      END RECORD;

   citem3 : cfoo (3) := (a => 3, f1 => "abc");
   citem4 : cfoo (4) := (a => 4, f1 => "1234");
           
   PACKAGE seq_io IS NEW sequential_io (foo);
   seq_f : seq_io.file_type;

   PACKAGE dir_io IS NEW direct_io (foo);
   dir_f : dir_io.file_type;

   PACKAGE cdir_io IS NEW direct_io (cfoo);
   cdir_f : cdir_io.file_type;
BEGIN
-----------------------------------------------------------------
   put_line ("Sequential_io test:");
   seq_io.create (seq_f, name => "unconstr_io.seq");
   seq_io.write (seq_f, item3);
   seq_io.write (seq_f, item4);
   seq_io.close (seq_f);

   item3 := (3, "   ");
   item4 := (4, "    ");

   seq_io.open (seq_f, seq_io.in_file, "unconstr_io.seq");
   seq_io.read (seq_f, item3);
   seq_io.read (seq_f, item4);
   seq_io.close (seq_f);

   put_line (integer'image(item3.a) & ", " & item3.f1);
   put_line (integer'image(item4.a) & ", " & item4.f1);
-----------------------------------------------------------------
   put_line ("Direct_io test:");
   dir_io.create 
      (dir_f, name => "unconstr_io.drc",
              form => "ORGANIZATION => INDEXED, RECORD_FORMAT => VARIABLE");
   FOR i IN 1 .. 10
   LOOP dir_io.write (dir_f, item4);
        dir_io.write (dir_f, item3);
   END LOOP;
   put_line ("current size of " & dir_io.name (dir_f) & " is "
             & dir_io.count'image (dir_io.size (dir_f)));
   dir_io.close (dir_f);

   item3 := (3, "   ");
   item4 := (4, "    ");

   dir_io.open (dir_f, dir_io.in_file, "unconstr_io.drc");
   put_line ("current index is " & dir_io.count'image (dir_io.index(dir_f)));
   dir_io.read (dir_f, item4);
   put_line ("current index is " & dir_io.count'image (dir_io.index(dir_f)));
   put_line (integer'image(item4.a) & ", " & item4.f1);
   dir_io.read (dir_f, item3);
   put_line ("current index is " & dir_io.count'image (dir_io.index(dir_f)));
   put_line (integer'image(item3.a) & ", " & item3.f1);

   item3 := (3, "   ");
   item4 := (4, "    ");

   dir_io.read (dir_f, item3, from => 18);
   put_line ("current index is " & dir_io.count'image (dir_io.index(dir_f)));
   put_line (integer'image(item3.a) & ", " & item3.f1);
   dir_io.read (dir_f, item4, from => 15);
   put_line ("current index is " & dir_io.count'image (dir_io.index(dir_f)));
   put_line (integer'image(item4.a) & ", " & item4.f1);
   dir_io.close (dir_f);
-----------------------------------------------------------------
   put_line ("Restricted direct_io test:");
   cdir_io.create (cdir_f, name => "unconstr_io.cdr");
   FOR i IN 1 .. 10
   LOOP cdir_io.write (cdir_f, citem4);
        cdir_io.write (cdir_f, citem3);
   END LOOP;
   put_line ("current size of " & cdir_io.name (cdir_f) & " is "
             & cdir_io.count'image (cdir_io.size (cdir_f)));
   cdir_io.close (cdir_f);

   citem3 := (3, "   ");
   citem4 := (4, "    ");

   cdir_io.open (cdir_f, cdir_io.in_file, "unconstr_io.cdr");
   put_line ("current index is " & cdir_io.count'image (cdir_io.index(cdir_f)));
   cdir_io.read (cdir_f, citem4);
   put_line ("current index is " & cdir_io.count'image (cdir_io.index(cdir_f)));
   put_line (int'image(citem4.a) & ", " & citem4.f1);
   cdir_io.read (cdir_f, citem3);
   put_line ("current index is " & cdir_io.count'image (cdir_io.index(cdir_f)));
   put_line (int'image(citem3.a) & ", " & citem3.f1);

   citem3 := (3, "   ");
   citem4 := (4, "    ");

   cdir_io.read (cdir_f, citem3, from => 18);
   put_line ("current index is " & cdir_io.count'image (cdir_io.index(cdir_f)));
   put_line (int'image(citem3.a) & ", " & citem3.f1);
   cdir_io.read (cdir_f, citem4, from => 15);
   put_line ("current index is " & cdir_io.count'image (cdir_io.index(cdir_f)));
   put_line (int'image(citem4.a) & ", " & citem4.f1);
   cdir_io.close (cdir_f);
END;

Compilation Log:
----------------

KARLSRUHE ADA SYSTEM  -  VAX/VMS version by    S Y S T E A M 
          Installation Date:  2-MAR-1987
compiling  BIG0:[PD.ADATEST.SRC]UNCONSTR_IO.ADA;14
in library BIG0:[PD.ADATEST.ADALIB]
KARLSRUHE ADA SYSTEM  -  COMPILER              VERSION  1.6A
KARLSRUHE ADA COMPILER - SYNTAX
KARLSRUHE ADA COMPILER - LIBREAD
KARLSRUHE ADA COMPILER - SEMANTIC
KARLSRUHE ADA COMPILER - EXPAND
KARLSRUHE ADA COMPILER - TRANSFORM
KARLSRUHE ADA COMPILER - OPTIMIZE
KARLSRUHE ADA COMPILER - CODEGEN
KARLSRUHE ADA COMPILER - LIBWRITE
KARLSRUHE ADA COMPILER - LISTING
PROCEDURE  UNCONSTR_IO,   Library Index   46
*** No Errors during Compilation ***
CPU Time used :    30.6  Seconds

Execution Log:
--------------

Sequential_io test:
 3, abc
 4, 1234
Direct_io test:
current size of BIG0:[PD.ADATEST]UNCONSTR_IO.DRC;9 is  20
current index is  1
current index is  2
 4, 1234
current index is  3
 3, abc
current index is  19
 3, abc
current index is  16
 4, 1234
Restricted direct_io test:
current size of BIG0:[PD.ADATEST]UNCONSTR_IO.CDR;2 is  20
current index is  1
current index is  2
 4, 1234
current index is  3
 3, abc
current index is  19
 3, abc
current index is  16
 4, 1234

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1987-04-22 10:15 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <114127553@jade.UUCP>
1987-04-22 10:15 ` VAX Ada sequential IO and Direct IO - (nf) systeam

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox