* my program
@ 2003-12-29 15:07 Kasia Krysiak
2003-12-29 18:16 ` Martin Krischik
2003-12-29 23:02 ` Martin Dowie
0 siblings, 2 replies; 3+ messages in thread
From: Kasia Krysiak @ 2003-12-29 15:07 UTC (permalink / raw)
I'm start to lern ada , and i have some problems...
this is my new program, and i have a question how to inicialize
Task1:Male(Id=>1); Task2:Male(Id=>2); task3:male(id=>3); (last 3 lines of
code in loop? becouse i should to have the number od male dymaic. I tryided
to do this in arry but i couldnt inlicjalize this id's sorry 4 my english
it isnt good I KNOW!!! - but I'm trying :)
task type Male(Id: integer);
task body Male is
procedure zadzwon is
Zmienna_Plikowa :File_Type;
begin
create(zmienna_plikowa,out_file, "id.txt");
end zadzwon;
procedure Wlasne_Sprawy is
begin
for counter in 1..10 loop
new_line;
Put(Item => "dupa ");
end loop;
end wlasne_sprawy;
begin
zadzwon;
Wlasne_Sprawy;
end Male;
Task1:Male(Id=>1);
Task2:Male(Id=>2);
task3:male(id=>3);
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: my program
2003-12-29 15:07 my program Kasia Krysiak
@ 2003-12-29 18:16 ` Martin Krischik
2003-12-29 23:02 ` Martin Dowie
1 sibling, 0 replies; 3+ messages in thread
From: Martin Krischik @ 2003-12-29 18:16 UTC (permalink / raw)
Kasia Krysiak wrote:
> I'm start to lern ada , and i have some problems...
> this is my new program, and i have a question how to inicialize
> Task1:Male(Id=>1); Task2:Male(Id=>2); task3:male(id=>3); (last 3 lines of
> code in loop? becouse i should to have the number od male dymaic. I
> tryided
Tasks types can be created dynamicly on the heap using new. You can also
have an array of access to a task type:
type Male_Access is access Male;
type Male_Array is array (Positive range <>) of Male_Access;
Tasks : Male_Array := (
new Male(Id=>1);
new Male(Id=>2);
new Male(id=>3);
Now you can have as many as you like.
With Regards
Martin
--
mailto://krischik@users.sourceforge.net
http://www.ada.krischik.com
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: my program
2003-12-29 15:07 my program Kasia Krysiak
2003-12-29 18:16 ` Martin Krischik
@ 2003-12-29 23:02 ` Martin Dowie
1 sibling, 0 replies; 3+ messages in thread
From: Martin Dowie @ 2003-12-29 23:02 UTC (permalink / raw)
"Kasia Krysiak" <kasiool@o2.pl> wrote in message
news:bspfvv$mpo$1@atlantis.news.tpi.pl...
> I'm start to lern ada , and i have some problems...
> this is my new program, and i have a question how to inicialize
> Task1:Male(Id=>1); Task2:Male(Id=>2); task3:male(id=>3); (last 3 lines of
> code in loop? becouse i should to have the number od male dymaic. I
tryided
> to do this in arry but i couldnt inlicjalize this id's sorry 4 my english
> it isnt good I KNOW!!! - but I'm trying :)
> task type Male(Id: integer);
[snip]
> Task1:Male(Id=>1);
>
> Task2:Male(Id=>2);
>
> task3:male(id=>3);
You can do this at elaboration:
package body Foo is
Task_Id : Natural := 0;
function Get_Id return Positive is
begin
Task_Id := Task_Id + 1;
return Task_Id;
end Get_Id;
task type Bar (Id : Natural := Get_Id);
task body Bar is ... end Bar;
Tasks : array (1 .. 3) of Bar;
end Foo;
The Lawyers can correct me if I'm wrong but elaboration is
performed sequentially and therefore the Id's are guaranteed
to be unique.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2003-12-29 23:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-12-29 15:07 my program Kasia Krysiak
2003-12-29 18:16 ` Martin Krischik
2003-12-29 23:02 ` Martin Dowie
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox