comp.lang.ada
 help / color / mirror / Atom feed
* How to put an integer into a char?
@ 1991-09-15 16:05 Mike Black
  0 siblings, 0 replies; 3+ messages in thread
From: Mike Black @ 1991-09-15 16:05 UTC (permalink / raw)


I recently took an Ada class and was trying to use a DOS call to
make the terminal beep on an input error.  However, I couldn't
find a (easy) way to put a CTRL-G (ASCII 7) into a CHARACTER object.
The ASCII package is apparently not defined for Alsys 4.3 on MS-DOS.
So, is there a way to do this folks?
Mike...
--
-------------------------------------------------------------------------------
: usenet: black@beno.CSS.GOV   :  land line: 407-494-5853  : I want a computer:
: real home: Melbourne, FL     :  home line: 407-242-8619  : that does it all!:
-------------------------------------------------------------------------------

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

* Re: How to put an integer into a char?
@ 1991-09-16  4:37 Michael Feldman
  0 siblings, 0 replies; 3+ messages in thread
From: Michael Feldman @ 1991-09-16  4:37 UTC (permalink / raw)


In article <49974@seismo.CSS.GOV> black@beno.CSS.GOV (Mike Black) writes:
>I recently took an Ada class and was trying to use a DOS call to
>make the terminal beep on an input error.  However, I couldn't
>find a (easy) way to put a CTRL-G (ASCII 7) into a CHARACTER object.

ASCII is a sub-package within PACKAGE Standard. I cannot imagine Alsys not
implementing it, as it is required. Try this code:

WITH Text_IO;
PROCEDURE Beep IS
  C: Character;
BEGIN
  C := ASCII.Bel;
  Text_IO.Put(C);
END Beep;

If you insist on working with the numerical values, try
  C := Character'Val(7);
instead of the other assignment. The values in Character are in ASCII collating
sequence, so the above will store in C the Character (ASCII) value in position 
7 of the type, i.e. the Bel character "ASCII 7".

Mike Feldman

-------------------------------------------------------------------------------
Michael B. Feldman
Visiting Professor 1991-92               Professor
Dept. of Comp. Sci. and Engrg.           Dept. of Elect. Engrg. and Comp. Sci.
University of Washington FR-35           The George Washington University
Seattle, WA 98105                        Washington, DC 20052
(206) 685-1376 (voice)                   (202) 994-5253 (voice)
(206) 543-2969 (fax)                     (202) 994-5296 (fax)
-------------------------------------------------------------------------------

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

* Re: How to put an integer into a char?
@ 1991-09-20 14:03 Bud Bach
  0 siblings, 0 replies; 3+ messages in thread
From: Bud Bach @ 1991-09-20 14:03 UTC (permalink / raw)


black@beno.CSS.GOV (Mike Black) writes:

>I recently took an Ada class and was trying to use a DOS call to
>make the terminal beep on an input error.  However, I couldn't
>find a (easy) way to put a CTRL-G (ASCII 7) into a CHARACTER object.
>The ASCII package is apparently not defined for Alsys 4.3 on MS-DOS.
>So, is there a way to do this folks?
>Mike...

Mike, I suspect that your problem may be that you are trying to "with"
package "ascii".  "Ascii" is defined within the scope of standard and may
not be explicitly withed.  Here is an example for you:

    with text_io;
    procedure beep is
      bell : constant character := ascii.bel;
    begin
      text_io.put (bell);
    end beep;

The less elegent way to do this would be:

    with text_io;
    procedure beep is
      bell : constant character := character'val(7);
                                   ----------------
    begin
      text_io.put (bell);
    end beep;

-- Bud
-- 
Bud Bach - Consultant				c/o Motorola
708 632-6611					Cellular Infrastructure Group
...!uunet!motcid!bachww or			1501 W. Shure Drive, MS-1235
bachww%motcid@uunet.uu.net			Arlington Heights, IL  60004

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

end of thread, other threads:[~1991-09-20 14:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1991-09-20 14:03 How to put an integer into a char? Bud Bach
  -- strict thread matches above, loose matches on Subject: below --
1991-09-16  4:37 Michael Feldman
1991-09-15 16:05 Mike Black

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