From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,7807efa8b787c793 X-Google-Attributes: gid103376,public From: Stephen Leake Subject: Re: help on task types Date: 1999/03/03 Message-ID: #1/1 X-Deja-AN: 450917425 References: <36DD8EBF.EAA@rmcs.cranfield.ac.uk> Organization: NASA Goddard Space Flight Center -- Greenbelt, Maryland USA Newsgroups: comp.lang.ada Date: 1999-03-03T00:00:00+00:00 List-Id: coxaw writes: > If I declare a task type that reads input from a file and prints to > screen > > Then instantiate 3 copies of this type > > can i tell each one to read from a different file ? > > and how is it done ? > > ie > > task type reader_type is > blah > blah > blah > end reader; > > read1:reader_type; > read2:reader_type; > > but read1 is to read from inFile1 > and read2 from inFile2 One way is to use a discriminant: task type reader_type (File_Name : access String) is ... end reader_type; File_Name_1 : aliased constant String := "inFile1"; read1 : reader_type (File_Name_1'access); Discriminants must be scalars, so you can't put a string there directly. Another way is to pass the file name to the task via an Initialize entry: task type reader_type is entry Initialize (File_Name : in String); end reader_type; This requires the user to call Initialize, which is usually a pain. But you can pass more complex stuff that way, than with a discriminant. -- Stephe