comp.lang.ada
 help / color / mirror / Atom feed
* Problem w/ Win NT Apex or just me?
@ 1998-10-16  0:00 Roga Danar
  1998-10-16  0:00 ` Sune Falck
  1998-10-17  0:00 ` David C. Hoos, Sr.
  0 siblings, 2 replies; 9+ messages in thread
From: Roga Danar @ 1998-10-16  0:00 UTC (permalink / raw)


Hi,

  I have been attempting to write an Apex Ada95 program that will print
from WIN NT w/ using the WIN API, just as a test.

  The following code fails on each block, but I expected that.
  But I am confused why the pragma interface to a C program is not
working either.

  The program finishes but no printing happens.

  I am not sure what if anything I am doing incorrectly.  I am sure it
will be pointed out if I am.

  If someone could help me out it would be great.
  The 'C' code and Ada code follows:

********************  C  program ***************************

#include <stdio.h>
#include <stdlib.h>

main (void)

{

 puts ("Starting to print");

 system ("print disk_file.txt");

}


************* Ada standalone procedure ***************************

--
-- File Name: printer.2.ada
--

with Ada.Text_Io;
use Ada.Text_Io;

-- with Win_Show;

procedure Printer is

--    pragma Link_With ("pr.o");

    Lpt1 : constant String := "LPT1";
    Prn : constant String := "PRN";
    Net_Printer : constant String := "\\COMPAQ_5\LAB";
    Disk_File : constant String := "c:\Disk_File";

    File_Buf, File_Buf2, File_Buf3, Disk_Buf : File_Type;
--
--
    procedure Print;

     pragma Interface (C, Print);
     pragma Interface_Name (Print, "_main");

begin

    begin

        begin
            Open (File => Disk_Buf,
                  Mode => Out_File,
                  Name => Disk_File);

      Put_Line("Opening Disk File");

        exception
            when others =>
                Create (File => Disk_Buf,
                        Mode => Out_File,
                        Name => Disk_File);

                Put_Line ("creating file");

        end;

        Put_Line (Disk_Buf, "Testing Disk File");

  Close(Disk_Buf);

    exception
        when Mode_Error =>
            Put_Line ("Mode Error");
        when others =>
            Put_Line ("Disk File test failed");

    end;
----------------------------------------------------
---

    begin -- LPT Test

        if not Is_Open (File_Buf) then
            Open (File => File_Buf,
                  Mode => Out_File,
                  Name => Lpt1);
        end if;

        Put_Line (File_Buf, " Testing LPT1 ");
        New_Page (File_Buf);

        Close (File_Buf);

    exception
  when Name_Error =>
  Put_Line ("LPT1 Name Error");
        when Use_Error =>
            Put_Line ("LPT1 Use Error");
        when others =>
            Put_Line (" LPT1 failed ");
    end;


---------------------------------------------------------
---
    begin -- PRN Test

        Open (File => File_Buf2,
              Mode => Out_File,
              Name => Prn);

        Put_Line (File_Buf2, " Testing PRN ");
        New_Page (File_Buf2);
        Close (File_Buf2);
    exception
 when Name_Error =>
 Put_Line ("PRN Name Error");
        when Use_Error =>
            Put_Line ("PRN Use Error");
        when others =>
            Put_Line (" PRN failed ");
    end;

----------------------------------------------------------
---
    begin -- Net Printer

        Open (File => File_Buf3,
              Mode => Out_File,
              Name => Net_Printer);

        Put_Line (File_Buf3, " Testing Net Printer ");
        New_Page (File_Buf3);
        Close (File_Buf);
    exception
        when Mode_Error =>
            Put_Line ("Mode Error");
        when others =>
            Put_Line (" Net Printer test failed ");
    end;

---------------------------------------------------------

-- C printing
    Print;

exception
    when Use_Error =>
        Put_Line (" USE Error ");
    when others =>
        Put_Line (" Something BAD went wrong !!");

end Printer;









^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~1998-10-19  0:00 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-10-16  0:00 Problem w/ Win NT Apex or just me? Roga Danar
1998-10-16  0:00 ` Sune Falck
1998-10-16  0:00   ` Roga Danar
1998-10-16  0:00   ` Roga Danar
1998-10-18  0:00     ` Dmitriy Anisimkov
1998-10-17  0:00 ` David C. Hoos, Sr.
1998-10-17  0:00   ` Tom Moran
1998-10-18  0:00     ` David C. Hoos, Sr.
1998-10-19  0:00   ` Roga Danar

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