comp.lang.ada
 help / color / mirror / Atom feed
* Ada Query...
@ 2000-03-26  0:00 Matt
  2000-03-26  0:00 ` Ken Garlington
                   ` (4 more replies)
  0 siblings, 5 replies; 15+ messages in thread
From: Matt @ 2000-03-26  0:00 UTC (permalink / raw)


Yo.
Having a bit of trouble with Ada95 at the moment.
What i want to know is- can you write a function that returns no result, or
is there another way to do it?
The program is basically a huge database, and the data is entered into an
array of records. The program loads a text file into the array, and then
presents a list of options (menu). One of the options is a to 'search'  the
database and display a screen of required information. What i want is to
simply call a function/ procedure to do this - but I don't want any result
returned. I don't want the search option to be included into the main
program, as it is huge. It works as a program in itself, but i want to call
it from other programs as either a function-like operation or by directly
calling the compiled/built ada .exe.
I am using GNAT ada95 on a windows98 machine.
Any suggestions?
Regards,
Matt.






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

* Re: Ada Query...
  2000-03-26  0:00 Ada Query Matt
  2000-03-26  0:00 ` Ken Garlington
  2000-03-26  0:00 ` Marin D. Condic
@ 2000-03-26  0:00 ` Robert Dewar
  2000-03-26  0:00   ` Matt
  2000-03-26  0:00 ` Pascal Obry
  2000-03-27  0:00 ` phodgpacker
  4 siblings, 1 reply; 15+ messages in thread
From: Robert Dewar @ 2000-03-26  0:00 UTC (permalink / raw)


In article <8bkv48$dcm$1@uranium.btinternet.com>,
  "Matt" <matt.brewster@btinternet.com> wrote:
> Yo.
> Having a bit of trouble with Ada95 at the moment.
> What i want to know is- can you write a function that returns
no result

This is so fundamental, that one has to ask what source
materials you are using. You need a reasonable Ada text book
if you are going to try to program in Ada 95, trying to do
it by rough approximation and reading examples is unlikely
to work. Absolutely any text book will introduce procedures
almost immediately, so that's why I ask the question.

Incidentally the idea of a "function returning no result" is
a bit like a car without a wheel, the notion of returning
a result is what makes a function a function!


Sent via Deja.com http://www.deja.com/
Before you buy.




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

* Re: Ada Query...
  2000-03-26  0:00 Ada Query Matt
@ 2000-03-26  0:00 ` Ken Garlington
  2000-03-27  0:00   ` Ted Dennison
  2000-03-26  0:00 ` Marin D. Condic
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 15+ messages in thread
From: Ken Garlington @ 2000-03-26  0:00 UTC (permalink / raw)


Hint: Notice the difference in these two sentences in your original post:

"can you write a function that returns no result"

"What i want is to simply call a function/ procedure to do this"

Check the Ada Language Reference Manual for details...

"Matt" <matt.brewster@btinternet.com> wrote in message
news:8bkv48$dcm$1@uranium.btinternet.com...
> Yo.
> Having a bit of trouble with Ada95 at the moment.
> What i want to know is- , or
> is there another way to do it?
> The program is basically a huge database, and the data is entered into an
> array of records. The program loads a text file into the array, and then
> presents a list of options (menu). One of the options is a to 'search'
the
> database and display a screen of required information. What i want is to
> simply call a function/ procedure to do this - but I don't want any result
> returned. I don't want the search option to be included into the main
> program, as it is huge. It works as a program in itself, but i want to
call
> it from other programs as either a function-like operation or by directly
> calling the compiled/built ada .exe.
> I am using GNAT ada95 on a windows98 machine.
> Any suggestions?
> Regards,
> Matt.
>
>






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

* Re: Ada Query...
  2000-03-26  0:00 ` Robert Dewar
@ 2000-03-26  0:00   ` Matt
  2000-03-26  0:00     ` tmoran
                       ` (3 more replies)
  0 siblings, 4 replies; 15+ messages in thread
From: Matt @ 2000-03-26  0:00 UTC (permalink / raw)


I am not using any book at the moment...I can't find it!

I don't want the procedure at the top of the main program, mainly because
it's huge and I don't want the program to be too congested, and also other
people in the team may wish to use it in their section of code. So to put a
finer point on it, I want this code outside the 'main' program, that can be
accessed by the 'main' program and other functions etc. I can write a
package including this source code, but (?) does a package have to consist
of functions? Can the package spec and body contain procedures, just like as
if I wrote the code at the top of the main program? (Because i want to call
it this way). There is already a package in the 'main' program (PROCEDURE
Load IS etc ect..), and I implement it by simply calling the phrase Load;
anywhere in my program. I want the same sort of thing from this 'search'
part of the code, to call it using a phrase like Search; anywhere in the
source code. The trouble is, unlike the Load procedure, i want the
definition and body of this sub-program elsewhere, and want to call it in my
program and a few others. Can this be done?
Regards,
Matt.


Robert Dewar <robert_dewar@my-deja.com> wrote in message
news:8bl19p$381$1@nnrp1.deja.com...
> In article <8bkv48$dcm$1@uranium.btinternet.com>,
>   "Matt" <matt.brewster@btinternet.com> wrote:
> > Yo.
> > Having a bit of trouble with Ada95 at the moment.
> > What i want to know is- can you write a function that returns
> no result
>
> This is so fundamental, that one has to ask what source
> materials you are using. You need a reasonable Ada text book
> if you are going to try to program in Ada 95, trying to do
> it by rough approximation and reading examples is unlikely
> to work. Absolutely any text book will introduce procedures
> almost immediately, so that's why I ask the question.
>
> Incidentally the idea of a "function returning no result" is
> a bit like a car without a wheel, the notion of returning
> a result is what makes a function a function!
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.






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

* Re: Ada Query...
  2000-03-26  0:00   ` Matt
  2000-03-26  0:00     ` tmoran
@ 2000-03-26  0:00     ` Robert Dewar
  2000-03-26  0:00     ` Lab. - konto NDG-48
  2000-03-26  0:00     ` Preben Randhol
  3 siblings, 0 replies; 15+ messages in thread
From: Robert Dewar @ 2000-03-26  0:00 UTC (permalink / raw)


In article <8blgui$d46$1@plutonium.btinternet.com>,
  "Matt" <matt.brewster@btinternet.com> wrote:
> Can this be done?
> Regards,
> Matt.

Yes, this can all be done and is very basic stuff. As I said
earlier, trying to program in a new language without reading
basic stuff is likely to be frustrating. Since you have internet
access, I would suggest going to www.adapower.com and tracking
down one of several online tutorials in Ada 95 that you will
find very helpful.


Sent via Deja.com http://www.deja.com/
Before you buy.




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

* Re: Ada Query...
  2000-03-26  0:00   ` Matt
@ 2000-03-26  0:00     ` tmoran
  2000-03-26  0:00     ` Robert Dewar
                       ` (2 subsequent siblings)
  3 siblings, 0 replies; 15+ messages in thread
From: tmoran @ 2000-03-26  0:00 UTC (permalink / raw)


>finer point on it, I want this code outside the 'main' program, that can be
>...
>package including this source code, but (?) does a package have to consist
>of functions? Can the package spec and body contain procedures, just like as
  A package can, and usually does, have one or more functions or
procedures.
  package Search is
    procedure Find;
    procedure Find_Special(Special : in String);
    function Found_Count return Natural;
    etc, whatever
  end Search;
  package body Search is
    procedure Find is
    begin .... end Find;
    etc
  end Search;

  with Search;
  procedure Main is
  begin
    Search.Find;
    etc

>I am not using any book at the moment...I can't find it!
  You could also learn brain surgery without book or teacher
by experimenting and asking newsgroup questions.  That too
would be messy and slow.




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

* Re: Ada Query...
  2000-03-26  0:00 Ada Query Matt
  2000-03-26  0:00 ` Ken Garlington
@ 2000-03-26  0:00 ` Marin D. Condic
  2000-03-26  0:00 ` Robert Dewar
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 15+ messages in thread
From: Marin D. Condic @ 2000-03-26  0:00 UTC (permalink / raw)


Matt wrote:
> 
> Yo.
> Having a bit of trouble with Ada95 at the moment.
> What i want to know is- can you write a function that returns no result, or
> is there another way to do it?

I'll bet good money that you are a C/C++ programmer, right? In Ada, a
"function that returns no result" is called a "procedure".

procedure Call_Me (X : in out Integer; Y : out Float; Z : in String) ;

.....


Call_Me (A, B, "Sample String") ;

.....

If you want some short examples of beginner level programs in Ada, you
might take a look at the Ada Programming page on my web site (see
below). I have a whole slew of little "hello world" sorts of programs
that illustrate different Ada features which I used in conjunction with
teaching and in-house class. (Some are kind of specific to jet engine
software :-) Look at the Gnat_Examples.chop link.

As you gain some experience with Ada, you will find plenty of examples
of more advanced techniques on the Adapower page (see my links page).
You will also find some examples of some domain-specific code on my Ada
page as well. (Statistics, client/server, sockets, etc.)

MDC
-- 
=============================================================
Marin David Condic   - Quadrus Corporation -   1.800.555.3393
1015-116 Atlantic Boulevard, Atlantic Beach, FL 32233
http://www.quadruscorp.com/
m c o n d i c @ q u a d r u s c o r p . c o m

***PLEASE REMOVE THE "-NOSPAM" PART OF MY RETURN ADDRESS***

Visit my web site at:  http://www.mcondic.com/

"Because that's where they keep the money."
    --  Willie Sutton when asked why he robbed banks. 
=============================================================




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

* Re: Ada Query...
  2000-03-26  0:00 Ada Query Matt
                   ` (2 preceding siblings ...)
  2000-03-26  0:00 ` Robert Dewar
@ 2000-03-26  0:00 ` Pascal Obry
  2000-03-27  0:00 ` phodgpacker
  4 siblings, 0 replies; 15+ messages in thread
From: Pascal Obry @ 2000-03-26  0:00 UTC (permalink / raw)


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


Matt a �crit dans le message <8bkv48$dcm$1@uranium.btinternet.com>...
>Yo.
>Having a bit of trouble with Ada95 at the moment.
>What i want to know is- can you write a function that returns no result, or
>is there another way to do it?

Yes with a procedure !

>The program is basically a huge database, and the data is entered into an
>array of records. The program loads a text file into the array, and then
>presents a list of options (menu).

How this can a "huge database" as everything is in memory :)

>One of the options is a to 'search'  the
>database and display a screen of required information. What i want is to
>simply call a function/ procedure to do this - but I don't want any result
>returned. I don't want the search option to be included into the main
>program, as it is huge. It works as a program in itself, but i want to call
>it from other programs as either a function-like operation or by directly
>calling the compiled/built ada .exe.

Not clear to me what you want to do here...

>I am using GNAT ada95 on a windows98 machine.

Good choice. Well for GNAT at least :)

>Any suggestions?

The problem you face does not looks like an Ada one to me but it is
more a design problem... Try to have a clear idea of what you want
to do...

Pascal.

--|------------------------------------------------------
--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--|         http://perso.wanadoo.fr/pascal.obry
--|
--| "The best way to travel is by means of imagination"







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

* Re: Ada Query...
  2000-03-26  0:00   ` Matt
                       ` (2 preceding siblings ...)
  2000-03-26  0:00     ` Lab. - konto NDG-48
@ 2000-03-26  0:00     ` Preben Randhol
  3 siblings, 0 replies; 15+ messages in thread
From: Preben Randhol @ 2000-03-26  0:00 UTC (permalink / raw)


On Sun, 26 Mar 2000 18:22:57 +0100, Matt wrote:
>I am not using any book at the moment...I can't find it!

Then send out a search party ;-) and in the mean time read 

http://goanna.cs.rmit.edu.au/~dale/ada/aln.html

and

http://adahome.com/Tutorials/Lovelace/master.htm

-- 
Preben Randhol -- [randhol@pvv.org] -- <http://www.pvv.org/~randhol/>
         "Det eneste trygge stedet i verden er inne i en fortelling."
                                                      -- Athol Fugard




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

* Re: Ada Query...
  2000-03-26  0:00   ` Matt
  2000-03-26  0:00     ` tmoran
  2000-03-26  0:00     ` Robert Dewar
@ 2000-03-26  0:00     ` Lab. - konto NDG-48
  2000-03-26  0:00     ` Preben Randhol
  3 siblings, 0 replies; 15+ messages in thread
From: Lab. - konto NDG-48 @ 2000-03-26  0:00 UTC (permalink / raw)
  To: Matt

On Sun, 26 Mar 2000, Matt wrote:

> I am not using any book at the moment...I can't find it!
Good luck then :-)


> package including this source code, but (?) does a package have to consist
> of functions? Can the package spec and body contain procedures, just like as
> if I wrote the code at the top of the main program? (Because i want to call
> it this way). There is already a package in the 'main' program (PROCEDURE

Yes you can have both procedures and functions in a package.

I am not sure I fully understood your question though...

Tim  
--who would recomend you to atleast have a small refrense book/website
about ada





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

* Re: Ada Query...
  2000-03-26  0:00 ` Ken Garlington
@ 2000-03-27  0:00   ` Ted Dennison
  0 siblings, 0 replies; 15+ messages in thread
From: Ted Dennison @ 2000-03-27  0:00 UTC (permalink / raw)


In article <SOnD4.15244$624.1353718@news.flash.net>,
"Ken Garlington" <Ken.Garlington@computer.org> wrote:
> Hint: Notice the difference in these two sentences in your original
post:
>
> "can you write a function that returns no result"
>
> "What i want is to simply call a function/ procedure to do this"
>
> Check the Ada Language Reference Manual for details...

:-)
I really have to pity Matt here. I picture someone who is sitting in the
pilots' chair of a 747 asking where the "accelerator pedal" is, and
being told to look it up in the operator manuals.

I think Matt's best bet is going to be to get out of the cockpit and
learn how the plane works before he gets back in. Otherwise, there's
gonna be one hell of a crash.

--
T.E.D.
http://www.telepath.com/~dennison/Ted/TED.html


Sent via Deja.com http://www.deja.com/
Before you buy.




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

* Re: Ada Query...
  2000-03-26  0:00 Ada Query Matt
                   ` (3 preceding siblings ...)
  2000-03-26  0:00 ` Pascal Obry
@ 2000-03-27  0:00 ` phodgpacker
  2000-03-27  0:00   ` Ken Garlington
  2000-03-27  0:00   ` Robert Dewar
  4 siblings, 2 replies; 15+ messages in thread
From: phodgpacker @ 2000-03-27  0:00 UTC (permalink / raw)


Wow, notice that all of the people went out of their way to NOT
answer your question, and to point out how you are, in their
opinions, a bozo.  The simple answer is "Yes, a procedure will
perform actions and not return a value (unless you use an 'out'
or and 'in out' parameter'.

You see, these people seem to think they are Ada gods, and that
you entire existence, not to mention you question, is beneath
them. If they have never tried to learn something on the fly,
well then they are just wimps.

Let just say to all that replied to Matt's post, you are dicks.
You could have just answered they question, but you felt it
necessary to jump all over him.  I hope you didn't scare him into
abandoning Ada.  This group is a means of sharing and gaining
information, not chastising those with lesser abilities.

Feel free to flame me, I don't use this account.  I pretty much
expect if DeWare, if his head hasn't exploded from rage yet.

* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!





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

* Re: Ada Query...
  2000-03-27  0:00 ` phodgpacker
@ 2000-03-27  0:00   ` Ken Garlington
  2000-03-27  0:00     ` Marin D. Condic
  2000-03-27  0:00   ` Robert Dewar
  1 sibling, 1 reply; 15+ messages in thread
From: Ken Garlington @ 2000-03-27  0:00 UTC (permalink / raw)


"phodgpacker" <phodgepackerNOphSPAM@excite.com.invalid> wrote in message
news:1523f737.24269b2c@usw-ex0102-015.remarq.com...

> Wow, notice that all of the people went out of their way to NOT
> answer your question, and to point out how you are, in their
> opinions, a bozo.

I don't think I used the term "bozo" or any equivalent in my posts. (Perhaps
I'm not a person?)

When questions of this type are asked, it's often from a student learning
the language. When the answer is readily available from the standard texts,
it can be argued that it is better to give the student at most a hint,
rather than just answering the question directly. This encourages the
student to learn how to use the reference material, rather than just getting
the answer without any effort. In the long run, the former is more
beneficial to the student.

> Let just say to all that replied to Matt's post, you are dicks.

Doesn't your message qualify as a reply to Matt's post? :)






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

* Re: Ada Query...
  2000-03-27  0:00 ` phodgpacker
  2000-03-27  0:00   ` Ken Garlington
@ 2000-03-27  0:00   ` Robert Dewar
  1 sibling, 0 replies; 15+ messages in thread
From: Robert Dewar @ 2000-03-27  0:00 UTC (permalink / raw)


In article <1523f737.24269b2c@usw-ex0102-015.remarq.com>,
  phodgpacker <phodgepackerNOphSPAM@excite.com.invalid> wrote:

> Let just say to all that replied to Matt's post, you are
> dicks. You could have just answered they question, but you
> felt it necessary to jump all over him.

Well we could have just answered the question, but that would
have been unfare to him, just as it is unfare to a student to
do their homework for them.

The critical thing here is not for Matt to learn that what he
wants is a procedure, but rather to learn how to figure that
out for himself.

The analogy of the pilot in the 747 cockpit asking where the
accelerator lives is a very nice one, it captures not only the
lack of knowledge, but also the wrong frame of thinking that
came with the original message.

Trying to write C code in Ada by asking statement by statement
what the Ada equivalent for the C is may result in a sort of
working Ada program if the program is short, but it will not
result in an acceptable Ada program, or in the programmer having
learned anything about Ada.

One must assume that the point of Matt writing anything in Ada
is to learn how Ada works (one certainly can assume that he is
not part of some programming team writing nuclear reactor
codes). Given that, it is really a good discipline not to take
the easy way out and just answer the question in the small, but
rather to use the opportunity to help teach.

Remember that Matt's objective here is not to write a "function
that does not return a value", but rather to learn how to write
Ada.


Sent via Deja.com http://www.deja.com/
Before you buy.




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

* Re: Ada Query...
  2000-03-27  0:00   ` Ken Garlington
@ 2000-03-27  0:00     ` Marin D. Condic
  0 siblings, 0 replies; 15+ messages in thread
From: Marin D. Condic @ 2000-03-27  0:00 UTC (permalink / raw)


Ken Garlington wrote:
> 
> "phodgpacker" <phodgepackerNOphSPAM@excite.com.invalid> wrote in message
> news:1523f737.24269b2c@usw-ex0102-015.remarq.com...
> 
> > Let just say to all that replied to Matt's post, you are dicks.
> 
> Doesn't your message qualify as a reply to Matt's post? :)

Gee. I thought that I provided a reasonably civilized answer to the
original question. But I suppose that someone who would voluntarily hang
upon himself the moniker: "phodgpacker" is just looking for trouble. Mr.
"phodgpacker" could have easily provided his own answer in less time
than it took to flame the rest of the crowd. Most of us do try to
provide useful answers for the newbies since it helps promote the
language, but recommending a text book or on-line tutorial isn't a bad
idea either.

If you're going to be an <expletive> then I guess you might as well be a
big one, eh? :-)

MDC
-- 
=============================================================
Marin David Condic   - Quadrus Corporation -   1.800.555.3393
1015-116 Atlantic Boulevard, Atlantic Beach, FL 32233
http://www.quadruscorp.com/
m c o n d i c @ q u a d r u s c o r p . c o m

***PLEASE REMOVE THE "-NOSPAM" PART OF MY RETURN ADDRESS***

Visit my web site at:  http://www.mcondic.com/

"Because that's where they keep the money."
    --  Willie Sutton when asked why he robbed banks. 
=============================================================




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

end of thread, other threads:[~2000-03-27  0:00 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-03-26  0:00 Ada Query Matt
2000-03-26  0:00 ` Ken Garlington
2000-03-27  0:00   ` Ted Dennison
2000-03-26  0:00 ` Marin D. Condic
2000-03-26  0:00 ` Robert Dewar
2000-03-26  0:00   ` Matt
2000-03-26  0:00     ` tmoran
2000-03-26  0:00     ` Robert Dewar
2000-03-26  0:00     ` Lab. - konto NDG-48
2000-03-26  0:00     ` Preben Randhol
2000-03-26  0:00 ` Pascal Obry
2000-03-27  0:00 ` phodgpacker
2000-03-27  0:00   ` Ken Garlington
2000-03-27  0:00     ` Marin D. Condic
2000-03-27  0:00   ` Robert Dewar

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