comp.lang.ada
 help / color / mirror / Atom feed
* Data Structures
@ 2002-05-21 20:35 ProLogic
  2002-05-22  0:37 ` Jeffrey Creem
  0 siblings, 1 reply; 6+ messages in thread
From: ProLogic @ 2002-05-21 20:35 UTC (permalink / raw)


I'm trying to create a data structure then a dynamic array to that
structure.

package Nick is

 NickName: String := "";
 Hops:   Integer := 0;
 SignOn:  Integer := 0;
 Identd:  String := "";
 Address:  String := "";
 Host:   String := "";
 Unused:  Integer := 0;
 Name:   String := "";

 VWAddress: String := "";

 Modes:  String := "";

 --Channels: array(positive range <>) of String := "";

 procedure setNickName(NickName: in String);

end Nick;

Could someone help me with the comment code there too please? I need a
dynamic array of Strings

In data.ads I have the following, which doesn't work...

 Nicks: array (positive range <>) of Nick;

Thanks for your help...





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

* Re: Data Structures
  2002-05-21 20:35 Data Structures ProLogic
@ 2002-05-22  0:37 ` Jeffrey Creem
  2002-05-22 11:30   ` Marc A. Criley
  0 siblings, 1 reply; 6+ messages in thread
From: Jeffrey Creem @ 2002-05-22  0:37 UTC (permalink / raw)


Someone probably told you that an Ada package is/can be related to a C++
class and they
were not entirely wrong however they are not as close as you appear to want
them to be.

You can not have an array of a package..You are far enough away from a
solution here that
you really need to read your textbook before starting.


"ProLogic" <ProLogic@prologitech.ods.org> wrote in message
news:3ceaafcd@news.comindico.com.au...
> I'm trying to create a data structure then a dynamic array to that
> structure.
>
> package Nick is
>
>  NickName: String := "";
>  Hops:   Integer := 0;
>  SignOn:  Integer := 0;
>  Identd:  String := "";
>  Address:  String := "";
>  Host:   String := "";
>  Unused:  Integer := 0;
>  Name:   String := "";
>
>  VWAddress: String := "";
>
>  Modes:  String := "";
>
>  --Channels: array(positive range <>) of String := "";
>
>  procedure setNickName(NickName: in String);
>
> end Nick;
>
> Could someone help me with the comment code there too please? I need a
> dynamic array of Strings
>
> In data.ads I have the following, which doesn't work...
>
>  Nicks: array (positive range <>) of Nick;
>
> Thanks for your help...
>
>





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

* Re: Data Structures
  2002-05-22  0:37 ` Jeffrey Creem
@ 2002-05-22 11:30   ` Marc A. Criley
  2002-05-22 14:16     ` Marin David Condic
  0 siblings, 1 reply; 6+ messages in thread
From: Marc A. Criley @ 2002-05-22 11:30 UTC (permalink / raw)


Jeffrey Creem wrote:
> 
> Someone probably told you that an Ada package is/can be related to a C++
> class and they
> were not entirely wrong however they are not as close as you appear to want
> them to be.
> 
> You can not have an array of a package..You are far enough away from a
> solution here that
> you really need to read your textbook before starting.
> 
> "ProLogic" <ProLogic@prologitech.ods.org> wrote in message
> news:3ceaafcd@news.comindico.com.au...
> > I'm trying to create a data structure then a dynamic array to that
> > structure.
> >
> > package Nick is
> >
> >  NickName: String := "";
> >  Hops:   Integer := 0;
> >  SignOn:  Integer := 0;
> >  Identd:  String := "";
> >  Address:  String := "";
> >  Host:   String := "";
> >  Unused:  Integer := 0;
> >  Name:   String := "";
> >
> >  VWAddress: String := "";
> >
> >  Modes:  String := "";
> >
> >  --Channels: array(positive range <>) of String := "";
> >
> >  procedure setNickName(NickName: in String);
> >
> > end Nick;
> >
> > Could someone help me with the comment code there too please? I need a
> > dynamic array of Strings
> >
> > In data.ads I have the following, which doesn't work...
> >
> >  Nicks: array (positive range <>) of Nick;
> >
> > Thanks for your help...
> >
> >

All those strings variables that you initialized to "" aren't going to
behave the way you think they're going to behave either.  Once you start
trying to set them to various values, you're going to start getting
Constraint_Errors.

Do what the man says:  Read the textbook.

Marc A. Criley
Consultant
Quadrus Corporation
www.quadruscorp.com



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

* Re: Data Structures
  2002-05-22 11:30   ` Marc A. Criley
@ 2002-05-22 14:16     ` Marin David Condic
  0 siblings, 0 replies; 6+ messages in thread
From: Marin David Condic @ 2002-05-22 14:16 UTC (permalink / raw)


I am reminded of how my lovely bride occasionally trys to speak Spanish in
English - things come out backwards with amusing results sometimes. We often
see the same thing here with respect to skilled C/C++ programmers trying to
write C/C++ code with Ada syntax. It just doesn't work. Its one of those
cases where if you really want to learn Ada, the best approach is to bite
the bullet and sit down with the textbook and work through it from front to
back. Since there are several books/tutorials available on-line at no cost,
the only investment is one's time. Given the amount of flailing about that
typically happens, I'd suspect that the up-front investment of time would
pay off quickly. Sort of in the philosophy of Ada - catch the bugs early in
the process... :-)

MDC
--
Marin David Condic
Senior Software Engineer
Pace Micro Technology Americas    www.pacemicro.com
Enabling the digital revolution
e-Mail:    marin.condic@pacemicro.com


"Marc A. Criley" <mcqada95@earthlink.net> wrote in message
news:3CEB819C.CC3AC467@earthlink.net...
>
> All those strings variables that you initialized to "" aren't going to
> behave the way you think they're going to behave either.  Once you start
> trying to set them to various values, you're going to start getting
> Constraint_Errors.
>
> Do what the man says:  Read the textbook.
>






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

* Data structures
@ 2002-07-26 10:30 Igor Gilitschenski
  2002-07-29 13:46 ` Florian Weimer
  0 siblings, 1 reply; 6+ messages in thread
From: Igor Gilitschenski @ 2002-07-26 10:30 UTC (permalink / raw)


Hi,

I was looking for a tool, which is able to convert C data structures
(from *.h files) into Ada data structures, but I wasn't successfull yet.
Do you know where to find one or isn't there such a tool.

Igor
-- 
Igor Gilitschenski               Gilitschenski@CERT.Uni-Stuttgart.DE
RUS-CERT Universitaet Stuttgart  Tel:+49 711 685-5973
Allmandring 30a, 70550 Stuttgart http://cert.uni-stuttgart.de/



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

* Re: Data structures
  2002-07-26 10:30 Data structures Igor Gilitschenski
@ 2002-07-29 13:46 ` Florian Weimer
  0 siblings, 0 replies; 6+ messages in thread
From: Florian Weimer @ 2002-07-29 13:46 UTC (permalink / raw)


Igor Gilitschenski <Gilitschenski@CERT.Uni-Stuttgart.DE> writes:

> I was looking for a tool, which is able to convert C data structures
> (from *.h files) into Ada data structures, but I wasn't successfull yet.
> Do you know where to find one or isn't there such a tool.

There's a tool called c2ada which might do what you want (it can't
most GCC extensions you'll find in typical GNU libc header files,
unfortunately).

Personally, I avoid importing structures from C.  If I have to pass
data structures between C and Ada code, I use special get/set
subprograms (written in C or in Ada, depending on the language used
for the data structure).  In my experience this approach is more
portable and less error-prone, but of course, it introduces a slight
overhead.

-- 
Florian Weimer 	                  Weimer@CERT.Uni-Stuttgart.DE
University of Stuttgart           http://CERT.Uni-Stuttgart.DE/people/fw/
RUS-CERT                          fax +49-711-685-5898



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

end of thread, other threads:[~2002-07-29 13:46 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-07-26 10:30 Data structures Igor Gilitschenski
2002-07-29 13:46 ` Florian Weimer
  -- strict thread matches above, loose matches on Subject: below --
2002-05-21 20:35 Data Structures ProLogic
2002-05-22  0:37 ` Jeffrey Creem
2002-05-22 11:30   ` Marc A. Criley
2002-05-22 14:16     ` Marin David Condic

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