comp.lang.ada
 help / color / mirror / Atom feed
From: Jerry van Dijk <jvandyk@attglobal.net>
Subject: Re: Ada Procedures Required for GNAT 3.10p (for DOS) Port
Date: 17 Jul 2003 02:03:14 +0200
Date: 2003-07-17T02:03:14+02:00	[thread overview]
Message-ID: <m2lluy2f5p.fsf@attglobal.net> (raw)
In-Reply-To: b3b4e2d7.0307160653.691c5ca3@posting.google.com


To complete Gautiers response:

> I am trying to write an Ada procedure that can rename a file, given
> the old filename and new filename as strings.

A perhaps better way is to use the embedded C DOS library. For example:

--  Example of Rename under DOS. UNTESTED !!!

with System;  --  needed for Rename !!!
with Ada.Text_IO;

procedure Check is

   --  RENAME
   --
   --  Renames file using the embedded DOS C library.
   --
   --  If New_Name exists it is deleted!
   --  Wildcards are not allowed.
   --
   --  Returns False if rename fails

   function Rename (Old_Name, New_Name : String) return Boolean;

   function Rename (Old_Name, New_Name : String) return Boolean is
      C_Old : String := Old_Name & ASCII.NUL;
      C_New : String := New_Name & ASCII.NUL;
      function Clib_Rename
        (Old_Name, New_Name : System.Address) return Integer;
      pragma Import (C, Clib_Rename, "_rename");
   begin
      return Clib_Rename (C_Old'Address, C_New'Address) = 0;
   end Rename;

begin
   if Rename ("oops", "glob") = True then
      Ada.Text_IO.Put_Line ("Success");
   else
      Ada.Text_IO.Put_Line ("Failure");
   end if;
end Check;

Untested as I do not have DOS handy right now.

We could help more if you gave the specification/documentation of the
original function.

> I am trying to write an Ada procedure that can write to/read from
> address locations.

That is more difficult to answer. As Gautier noted it depends on what memory
you want to access. Remember that your GNAT program will be 32-bit protected
mode code instead of 16-bit realmode code. Not only is memory protected, it is
also using virtual memory adresses instead of the physical addresses that DOS
uses. Yes, it can be accessed by using DPMI magic, but the way to do it
depends on what memory needs to be accessed: video memory (character or
graphical), bios, dos, program, IO card, etc.

Hope this helps, email if you need more help.

-- 
--  Jerry van Dijk   | email: jvandyk@attglobal.net
--  Leiden, Holland  | web:   users.ncrvnet.nl/gmvdijk



  parent reply	other threads:[~2003-07-17  0:03 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-07-16 14:53 Ada Procedures Required for GNAT 3.10p (for DOS) Port Debs Wisbey
2003-07-16 20:14 ` Gautier Write-only
2003-07-17  0:03 ` Jerry van Dijk [this message]
2003-07-17  1:45 ` Jeffrey Carter
2003-07-17 13:25   ` Frank J. Lhota
2003-07-17  2:03 ` Randy Brukardt
replies disabled

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