Random access database_(re)

Sun, 28 Sep 1997 10:01:53 +0200 (MEST)


According to Pismo:
> 
> I learned Pascal on VAX-Pascal (DEC VAX-VMS systems), and did allot 
> of programming with Turbo in the 3.x to 5.5 days. Now I have a 
> Linux system with GPC and want to write some database stuff using 
> random access. My recent return to Pascal leaves me wanting to know 
> how to do this with GPC compared to Turbo?

If you keep the whole database in memory, it's about the same as
in Turbo Pascal:  Use an array, an array of poiners, a linked list,
a tree, or whatever.  If your structure involves an array, GPC's
"array schema" (according to ISO Extended Pascal) could be of
interest for you:

    Type
      Foo ( n: Integer ) = array [ 1..n ] of Integer;
      FooPtr = ^Foo;

    Var
      f: FooPtr;
      i: Integer;

    ...

    New ( f, 42 );
    for i:= 1 to f^.n do
      f^ [ i ]:= i mod 137;
    Dispose ( f );

GPC does not have a 64k limit, so you don't need to worry about,
say, an array of pointers which is limited to 16380 pointers in
Turbo Pascal.

If you want to keep the data on disk, the following "dictionary" will
be useful for you:

    Turbo Pascal         GNU Pascal

    Assign           See, for instance, the BPcompat package in 
                     ftp://agnes.dida.physik.uni-essen.de/gnu-pascal/contrib
		     (The next beta will have a built-in `Assign'.)

    reset (read-only)    reset
    reset (read/write)   update
    rewrite              rewrite
    append               extend

    Seek                 SeekRead
                         SeekWrite
			 SeekUpdate

    close                close

Hope this helps,

    Peter

 Dipl.-Phys. Peter Gerwinski, Essen, Germany, free physicist and programmer
peter.gerwinski@uni-essen.de - http://home.pages.de/~peter.gerwinski/ [970201]
 maintainer GNU Pascal [970714] - http://home.pages.de/~gnu-pascal/ [970125]


Peter Gerwinski (peter@agnes.dida.physik.uni-essen.de)

HTML conversion by Lluís de Yzaguirre i Maura
Institut de Lingüística Aplicada - Universitat "Pompeu Fabra"
e-mail: de_yza@upf.es