comp.lang.ada
 help / color / mirror / Atom feed
* char  -> int
@ 1998-11-18  0:00 alex
  1998-11-18  0:00 ` Niklas Holsti
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: alex @ 1998-11-18  0:00 UTC (permalink / raw)


How do I cast char to an int using ada?




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

* Re: char  -> int
  1998-11-18  0:00 char -> int alex
  1998-11-18  0:00 ` Niklas Holsti
@ 1998-11-18  0:00 ` Pascal Obry
  1998-11-18  0:00 ` Juergen Pfeifer
  2 siblings, 0 replies; 6+ messages in thread
From: Pascal Obry @ 1998-11-18  0:00 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 304 bytes --]


alex a �crit dans le message <36527480.5A60@usa.net>...
>How do I cast char to an int using ada?

What is a char and what is an int :-) ??

Maybe you wanted to talk about Character and Integer, in
this case :

C : Character;
I : Integer;

C := Character'Val (I);
I := Character'Pos (C);

Pascal.






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

* Re: char  -> int
  1998-11-18  0:00 char -> int alex
@ 1998-11-18  0:00 ` Niklas Holsti
  1998-11-18  0:00 ` Pascal Obry
  1998-11-18  0:00 ` Juergen Pfeifer
  2 siblings, 0 replies; 6+ messages in thread
From: Niklas Holsti @ 1998-11-18  0:00 UTC (permalink / raw)


alex wrote:
> 
> How do I cast char to an int using ada?

This, and most of your later questions, are too short and
general to permit good and concise answers. Please, first read
an Ada book, or go through one of the Ada tutorials available on
the net, then try to solve your problem on your own, then if
you still have a problem, ask us again, but please include more
information on what your problem (= application) really is,
and (just in case it's relevant) which computer, operating
system, and compiler you are using.

Books, reference manuals and tutorials can be found
at http://www.adahome.com/.

I've listed your questions (well, all questions that are
now on my news server) below, and added some references
to the Ada 95 Language Reference Manual where the answers
can be found. Links to the LRM are at
http://www.adahome.com/Resources/References.html.

Note that the LRM is not an elementary or tutorial text,
so you may want to find the corresponding sections of an
Ada textbook instead.

> How do I cast char to an int using ada?

   LRM 3.5.5 (that's section 3.5.5), 'Pos and 'Val
   attributes. Check also LRM 3.5.2.

> How do I dail a number using phone device with ada?

   Depends on your computer, OS and modem. Probably you need
   to write some "AT" commands to a serial port; the way you
   do this varies across systems, but on some systems it's
   as simple as opening a text file with the name of the
   serial port (LRM A.10.2; Text_IO.Open) and writing a
   string (Text_IO.Put_Line).

> How do I page someone with ada  ?

   Same as above.

> How do I send email with ada?

   Depends on your OS and mail system. You probably need
   to start a mail agent as a subprocess and point it at
   your message. On UNIX/POSIX systems, a standard Ada
   binding of the necessary OS services exists; look for
   the "Florist" package on the net, or check your
   compiler documentation.

> How do I delete a node  using ada?

   As above (I interpret "node" to mean a file system node,
   e.g. a file). "Florist" contains the services for UNIX
   systems; MS-Windows bindings also exist (I believe the
   name is Win32Ada).

> How do i start a window application with ada

   Start it as a child process, using "Florist". If you want
   to write a window application in Ada, use a binding
   appropriate for your windowing system (CLAW and TASH are
   some of the nice, thick ones).

> how do i get the *69 number from phone device with ada to record
> numbers on callingfor a program

   I haven't the faintest idea what you mean, but probably
   you need to write some command to your modem and read
   its answer. Text_IO on the serial port is one way.

> How do I  get the eof from header  using ada ?

   What "header"? Look at LRM annexes A.6 through A.14 for
   input-output in Ada, including functions to detect end
   of file.

> How to i treat exception and redirect them inside the program ?

   LRM 11 (an entire chapter about exception handling!)

> How do I define a generic parameter that would let say in want to passe
> sometime a Natural and sometime a stirng

   LRM 12 (an entire chapter about generic units). It depends
   a little on what you want to use the parameter for.

> How do I change a bit inside byte using ada Like i'd do with assembler ?

   LRM 13, and specifically LRM 13.5, discusses bit-level data
   layouts. Check also the boolean operations for modular
   types, LRM 3.5.4 and specifically 3.5.4(31) (the "31" is the
   paragraph number).

> Hi I'd like to know how to position a pointer in a file

   LRM A.8.5, procedure Set_Index for a file of homogeneous
   records. LRM A.12 for stream files. "Florist" or other O/S
   bindings can of course also be used, but then you may have
   to read/write the file using services of that binding, for
   coherent buffering.

> Hi I'd like to define a variable size record but I have a compile error.
> 
> what can I do ?
>
> Ex; TYPE TAB   IS RECORD
>        Str :STRING(1..M);  
>        Char :CHARACRER;
>        END RECORD;

   Ok this question is specific enough to be answered
   briefly: make the size a discriminant of the record type.
   See LRM 3.7(33). In your example,

      TYPE TAB (M : Natural) IS RECORD

> How do I use a asm (assembleur) lib withusing ada?

   Declare the library routines in your Ada source with
   pragma Import. List the object code files for linking
   with pragma Linker_Options. Note that you must find
   out about parameter passing conventions specific for
   your compiler and assembler; check pragma Convention.
   All this stuff is in LRM B.1.


Hope the above helps you a bit. It would be more
interesting to answer your questions if you could
say a little about the context, such as what type
of application you are working on.




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

* Re: char  -> int
  1998-11-18  0:00 char -> int alex
  1998-11-18  0:00 ` Niklas Holsti
  1998-11-18  0:00 ` Pascal Obry
@ 1998-11-18  0:00 ` Juergen Pfeifer
  1998-11-22  0:00   ` Matthew Heaney
  1998-11-24  0:00   ` John McCabe
  2 siblings, 2 replies; 6+ messages in thread
From: Juergen Pfeifer @ 1998-11-18  0:00 UTC (permalink / raw)


alex wrote:
> 
> How do I cast char to an int using ada?
I guess your next question on this newsgroup
will be something like

"How do I type characters on a keyboard with
Ada"?

Go and buy one of the excellent Ada books;-)




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

* Re: char  -> int
  1998-11-18  0:00 ` Juergen Pfeifer
@ 1998-11-22  0:00   ` Matthew Heaney
  1998-11-24  0:00   ` John McCabe
  1 sibling, 0 replies; 6+ messages in thread
From: Matthew Heaney @ 1998-11-22  0:00 UTC (permalink / raw)


In article <72vgp5$u9g$1@news02.btx.dtag.de>, Juergen.Pfeifer@t-online.de
(Juergen Pfeifer) wrote:

>alex wrote:
>> 
>> How do I cast char to an int using ada?

Use the attribute Character'Pos, as in:

  I : Integer := Character'Pos ('m');

Of course, you can always use Unchecked_Conversion:

  function To_Int is 
    new Unchecked_Conversion (Character, Interfaces.Integer_8);

  I : Integer_8 := To_Int ('m');




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

* Re: char  -> int
  1998-11-18  0:00 ` Juergen Pfeifer
  1998-11-22  0:00   ` Matthew Heaney
@ 1998-11-24  0:00   ` John McCabe
  1 sibling, 0 replies; 6+ messages in thread
From: John McCabe @ 1998-11-24  0:00 UTC (permalink / raw)


Juergen.Pfeifer@t-online.de (Juergen Pfeifer) wrote:
>alex wrote:
>> 
>> How do I cast char to an int using ada?


>Go and buy one of the excellent Ada books;-)

Or even RTFM

-- 
Best Regards
John McCabe
---------------------------------------------------------------------






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

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

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-11-18  0:00 char -> int alex
1998-11-18  0:00 ` Niklas Holsti
1998-11-18  0:00 ` Pascal Obry
1998-11-18  0:00 ` Juergen Pfeifer
1998-11-22  0:00   ` Matthew Heaney
1998-11-24  0:00   ` John McCabe

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