comp.lang.ada
 help / color / mirror / Atom feed
* Re: coercing an integer to a string
  1998-11-16  0:00 ` Tom Moran
@ 1998-11-16  0:00   ` John McCabe
  0 siblings, 0 replies; 11+ messages in thread
From: John McCabe @ 1998-11-16  0:00 UTC (permalink / raw)


tmoran@bix.com (Tom Moran) wrote:
>Look up the attributes 'Image and 'String

or even 'Image and 'Value :-) As you've shown below.

>S : String := Integer'Image(75);
>I : Integer := Integer'Value("23");

-- 
Best Regards
John McCabe
---------------------------------------------------------------------
Marconi Electronic Systems
Simulation & Training Division
=====================================================================
Not necessarily my company or service providers opinions.
=====================================================================






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

* Re: coercing an integer to a string
  1998-11-16  0:00 ` Chris Morgan
@ 1998-11-16  0:00   ` John McCabe
  1998-11-17  0:00     ` Chris Morgan
  0 siblings, 1 reply; 11+ messages in thread
From: John McCabe @ 1998-11-16  0:00 UTC (permalink / raw)


Chris Morgan <mihalis@ix.netcom.com> wrote:
>dummy@e.mail (Emmanuel M. D�carie) writes:

>Think about it a bit. Function 1 requires you to build up a string
>piece by piece. Can you work out how to decide how many 1000s, 100s,
>10s, units and so on the number contains? Then you would just need to
>work out how to join the characters together. 
>
>Similarly the 2nd function - work out what each character means in
>terms of numerical value and then add them together. It's not as hard
>as it seems.

It's even easier than it seems if you use the facilities of the language 
that Tom Moran has mentioned.


-- 
Best Regards
John McCabe
---------------------------------------------------------------------
Marconi Electronic Systems
Simulation & Training Division
=====================================================================
Not necessarily my company or service providers opinions.
=====================================================================






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

* coercing an integer to a string
@ 1998-11-16  0:00 Emmanuel M. D�carie
  1998-11-16  0:00 ` Tom Moran
  1998-11-16  0:00 ` Chris Morgan
  0 siblings, 2 replies; 11+ messages in thread
From: Emmanuel M. D�carie @ 1998-11-16  0:00 UTC (permalink / raw)


Hello, 

I need 2 functions.

Function 1 will take for input an integer and will return the number as a
string.

Function 2 will reverse this action, i.e. will take a string that contains
a integer and will return an integer.

Can anybody suggest me a way to do this, or point me to a faq.

I'm just starting with Ada, and I can find anything on this in "Ada 95
From the Beginning" and in "Ada 95 Problem Solving and Program Design.

Thanks.

-- 
Emmanuel
emm*cam.org  where * = @




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

* Re: coercing an integer to a string
  1998-11-16  0:00 coercing an integer to a string Emmanuel M. D�carie
@ 1998-11-16  0:00 ` Tom Moran
  1998-11-16  0:00   ` John McCabe
  1998-11-16  0:00 ` Chris Morgan
  1 sibling, 1 reply; 11+ messages in thread
From: Tom Moran @ 1998-11-16  0:00 UTC (permalink / raw)


Look up the attributes 'Image and 'String
S : String := Integer'Image(75);
I : Integer := Integer'Value("23");




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

* Re: coercing an integer to a string
  1998-11-16  0:00 coercing an integer to a string Emmanuel M. D�carie
  1998-11-16  0:00 ` Tom Moran
@ 1998-11-16  0:00 ` Chris Morgan
  1998-11-16  0:00   ` John McCabe
  1 sibling, 1 reply; 11+ messages in thread
From: Chris Morgan @ 1998-11-16  0:00 UTC (permalink / raw)


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

dummy@e.mail (Emmanuel M. D�carie) writes:

> Hello, 
> 
> I need 2 functions.
> 
> Function 1 will take for input an integer and will return the number as a
> string.
> 
> Function 2 will reverse this action, i.e. will take a string that contains
> a integer and will return an integer.
> 
> Can anybody suggest me a way to do this, or point me to a faq.
> 
> I'm just starting with Ada, and I can find anything on this in "Ada 95
> From the Beginning" and in "Ada 95 Problem Solving and Program Design.

Think about it a bit. Function 1 requires you to build up a string
piece by piece. Can you work out how to decide how many 1000s, 100s,
10s, units and so on the number contains? Then you would just need to
work out how to join the characters together. 

Similarly the 2nd function - work out what each character means in
terms of numerical value and then add them together. It's not as hard
as it seems.

Cheers,

Chris
p.s. there are some helpful functions in the back of the Ada Language
Reference Manual (findable on the web if you don't have it).
-- 
Chris Morgan <mihalis at ix.netcom.com> 
       Home Web Server -  http://mihalis.dyn.ml.org/index.html




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

* Re: coercing an integer to a string
  1998-11-17  0:00     ` Chris Morgan
@ 1998-11-17  0:00       ` John McCabe
  1998-11-18  0:00         ` Emmanuel M. D�carie
  0 siblings, 1 reply; 11+ messages in thread
From: John McCabe @ 1998-11-17  0:00 UTC (permalink / raw)


Chris Morgan <mihalis@ix.netcom.com> wrote:
>John McCabe <john@assen.demon.co.uk> writes:

>> It's even easier than it seems if you use the facilities of the
>> language that Tom Moran has mentioned.

>I gave two types of hints - algorithmic and "look in the
>book". Anything further seemed like doing other peoples homework!

Accepted. Sorry if I caused offence.

-- 
Best Regards
John McCabe
---------------------------------------------------------------------
Marconi Electronic Systems
Simulation & Training Division
=====================================================================
Not necessarily my company or service providers opinions.
=====================================================================






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

* Re: coercing an integer to a string
  1998-11-16  0:00   ` John McCabe
@ 1998-11-17  0:00     ` Chris Morgan
  1998-11-17  0:00       ` John McCabe
  0 siblings, 1 reply; 11+ messages in thread
From: Chris Morgan @ 1998-11-17  0:00 UTC (permalink / raw)


John McCabe <john@assen.demon.co.uk> writes:

> It's even easier than it seems if you use the facilities of the language 
> that Tom Moran has mentioned.

I gave two types of hints - algorithmic and "look in the
book". Anything further seemed like doing other peoples homework!

-- 
Chris Morgan <mihalis at ix.netcom.com> 
       Home Web Server -  http://mihalis.dyn.ml.org/index.html




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

* Re: coercing an integer to a string
  1998-11-17  0:00       ` John McCabe
@ 1998-11-18  0:00         ` Emmanuel M. D�carie
  1998-11-20  0:00           ` Dale Stanbrough
  1998-11-23  0:00           ` Chris Morgan
  0 siblings, 2 replies; 11+ messages in thread
From: Emmanuel M. D�carie @ 1998-11-18  0:00 UTC (permalink / raw)


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

In article (Dans l'article) <72s09u$8b5@gcsin3.geccs.gecm.com>, John
McCabe <john@assen.demon.co.uk> wrote (�crivait)�:

>Chris Morgan <mihalis@ix.netcom.com> wrote:
>>John McCabe <john@assen.demon.co.uk> writes:
>
>>> It's even easier than it seems if you use the facilities of the
>>> language that Tom Moran has mentioned.
>
>>I gave two types of hints - algorithmic and "look in the
>>book". Anything further seemed like doing other peoples homework!
>
>Accepted. Sorry if I caused offence.

I'm sorry, I think made my homework. As I said, I'm in the process of
learning Ada. I have look under "string", "coercing", "coercion" in both
index of the two books I have on Ada that I have quoted in the original
message. How could I find by myself starting from "coerce" that the answer
was in the attribute of the type ?

Some people where kind enough to give me the beginning of an answer like
the following that was truly informative.

Integer'Image ( 1.0 ) = " 1.0"
Integer'Value ("1.0") =   1.0

Also look at the toc of the REFMAN in its website incarnation. Do you
think that its easy to find in this toc "some helpful functions in the
back of the Ada Language Reference Manual (findable on the web if you
don't have it)". The toc even don't mention the word "function".

Core Language

1. General -- TOC 
2. Lexical Elements -- TOC 
3. Declarations and Types -- TOC 
4. Names and Expressions -- TOC 
5. Statements -- TOC 
6. Subprograms -- TOC 
7. Packages -- TOC 
8. Visibility Rules -- TOC 
9. Tasks and Synchronization -- TOC 
10. Program Structure and Compilation Issues -- TOC 
11. Exceptions -- TOC 
12. Generic Units -- TOC 
13. Representation Issues -- TOC 

Annexes

A. Predefined Language Environment -- TOC 
B. Interface to Other Languages -- TOC 
C. Systems Programming -- TOC 
D. Real-Time Systems -- TOC 
E. Distributed Systems -- TOC 
F. Information Systems -- TOC 
G. Numerics -- TOC 
H. Safety and Security -- TOC 
J. Obsolescent Features -- TOC 
K. Language-Defined Attributes 
L. Language-Defined Pragmas 
M. Implementation-Defined Characteristics 
N. Glossary 
P. Syntax Summary 


Maybe its obvious for some that the answer Chris Morgan gave me was
enough, but it was not for me. I'm coming from the scripting world (so I'm
a lazy "typer"), and when I answer a question from a newbie on a mailing
list, I always, either give a complete reference (page number, URL), or a
piece of code, or both. Think how far his answer was taking me away from a
simple and quick response. I really don't want to start a flame war on
this, I waited a couple of days before writing anything more on this
thread. I don't think that I will write more on it in the future.

Cheers

<http://www.cam.org/~emm/frontierNewbieToolbox.html>

-- 
Emmanuel
emm*cam.org  where * = @




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

* Re: coercing an integer to a string
  1998-11-18  0:00         ` Emmanuel M. D�carie
@ 1998-11-20  0:00           ` Dale Stanbrough
  1998-11-23  0:00             ` Robert I. Eachus
  1998-11-23  0:00           ` Chris Morgan
  1 sibling, 1 reply; 11+ messages in thread
From: Dale Stanbrough @ 1998-11-20  0:00 UTC (permalink / raw)


" piece of code, or both. Think how far his answer was taking me away from a
  simple and quick response. I really don't want to start a flame war on
  this, I waited a couple of days before writing anything more on this
  thread. I don't think that I will write more on it in the future."


Well i tried emailing you an answer (written with full code) but your stupid
email address was invalid.

I just noticed a *tiny* message at the bottom of your posting, which is
somewhat less than obvious, on how to change your email address to a
correct one.

If you want to avoid spam, but want people to respond to you, then at least
put obvious notes at the bottom of your posts.

Dale




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

* Re: coercing an integer to a string
  1998-11-20  0:00           ` Dale Stanbrough
@ 1998-11-23  0:00             ` Robert I. Eachus
  0 siblings, 0 replies; 11+ messages in thread
From: Robert I. Eachus @ 1998-11-23  0:00 UTC (permalink / raw)


In article <dale-2011981302430001@dale.ppp.cs.rmit.edu.au> dale@cs.rmit.edu.au (Dale Stanbrough) writes:

 > Well i tried emailing you an answer (written with full code) but your stupid
 > email address was invalid.

 > I just noticed a *tiny* message at the bottom of your posting, which is
 > somewhat less than obvious, on how to change your email address to a
 > correct one.

 > If you want to avoid spam, but want people to respond to you, then at least
 > put obvious notes at the bottom of your posts.

   This probably should go into the FAQ.  Actually I would suggest
setting up a separate e-mail account to get the "real" replies, then
deleting it. However, not everyone has the luxury of doing that.
--

					Robert I. Eachus

with Standard_Disclaimer;
use  Standard_Disclaimer;
function Message (Text: in Clever_Ideas) return Better_Ideas is...




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

* Re: coercing an integer to a string
  1998-11-18  0:00         ` Emmanuel M. D�carie
  1998-11-20  0:00           ` Dale Stanbrough
@ 1998-11-23  0:00           ` Chris Morgan
  1 sibling, 0 replies; 11+ messages in thread
From: Chris Morgan @ 1998-11-23  0:00 UTC (permalink / raw)


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

dummy@e.mail (Emmanuel M. D�carie) writes:

> Maybe its obvious for some that the answer Chris Morgan gave me was
> enough, but it was not for me. I'm coming from the scripting world (so I'm
> a lazy "typer"), and when I answer a question from a newbie on a mailing
> list, I always, either give a complete reference (page number, URL), or a
> piece of code, or both. Think how far his answer was taking me away from a
> simple and quick response. I really don't want to start a flame war on
> this, I waited a couple of days before writing anything more on this
> thread. I don't think that I will write more on it in the future.

I knew exactly what I was doing.

Please accept that we all want to be helpful on any Ada topic, but
that also we have seen people arrive in this group year after year
asking detailed questions which have straightforward answers in the
freely available documentation. Many readers simply don't respond at
all - it's not out of laziness or lack of interest, it's because
they've concluded that any quick answer takes away the whole point of
these homework exercises (if that's what yours is, I forget now).

If I had given you the correct answer it would have helped you in the
very short term, however it would not have started you down the road
of relying on the reference manual. You need to know how to find your
way around this document if you are serious about Ada, you will
rapidly tire all the Ada experts on this group (and me also ;) if you
expect a (page number, URL) for anything that isn't immediately
obvious. 

Chris
-- 
Chris Morgan <mihalis at ix.netcom.com> 
       Home Web Server -  http://mihalis.dyn.ml.org/index.html
       email me for numeric URL if ml.org is down




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

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

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-11-16  0:00 coercing an integer to a string Emmanuel M. D�carie
1998-11-16  0:00 ` Tom Moran
1998-11-16  0:00   ` John McCabe
1998-11-16  0:00 ` Chris Morgan
1998-11-16  0:00   ` John McCabe
1998-11-17  0:00     ` Chris Morgan
1998-11-17  0:00       ` John McCabe
1998-11-18  0:00         ` Emmanuel M. D�carie
1998-11-20  0:00           ` Dale Stanbrough
1998-11-23  0:00             ` Robert I. Eachus
1998-11-23  0:00           ` Chris Morgan

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