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 X-Google-Thread: 103376,b00e2fb2fb2dee17 X-Google-Attributes: gid103376,public From: gisle@gribb.ii.uib.no (Gisle S�lensminde) Subject: Re: "Dynamic" object Date: 2000/03/08 Message-ID: #1/1 X-Deja-AN: 594643194 Content-Transfer-Encoding: 8bit References: Organization: University of Bergen, Norway Content-Type: text/plain; charset=iso-8859-1 Mime-Version: 1.0 Newsgroups: comp.lang.ada Date: 2000-03-08T00:00:00+00:00 List-Id: Preben Randhol wrote: >On 6 Mar 2000 17:58:55 +0100, Gisle S�lensminde wrote: >>Preben Randhol wrote: >> >>>I'm wondering how to do the following in Ada 95. >>> >>>I want to have a small program as a frontend to a database. Thus the >>>program needs to read the definition of the db and then generate the >>>proper GUI for this. This I think I know how to to, but the problem is >>>how do I define a type that contains the different fields so that I can >>>put it in a linked list? >>> >>>Example: >>> >>>Field 1: First_Name (string of size 30) >>>Field 2: Sirname (string of size 40) >>>Field 3: Age (integer of size 3) >>>... >>>Field n: Address (string of size 80) >>> >>>Any hints much appreciated. >> >> >>I have some problem understanding what problem is. To get a more precise >>answer (at least from me), you should give more details of your problem. > > >Ok think about it more in the way of making a GUI interface to PostgreSQL where >you can set up the fields as you like in your database. > >So you can make one database which is an address book containing only the >fields Name and Address or you can make a database to organize the books that >you own, etc... > >So the program cannot statically (at compile-time) know which fields are >present in the database you want to open. It seems like you realy want to use some tuple construct, which is available in several functional languages. In Procedural/OO languages like Ada, C++ and Pascal there are no such thing. You must know at compile time which fields a record have. If you want to return a table entry without a priori knowlegde of it's contents, you must use a list of hetrogenous objects, or some similar data structure. Typically you will make a tagged supertype (probably controlled) for a general field type, and make subtypes for the different field types. This will be much along the lines of the second soultion in my last posting, but with lists of fields instead of lists of table entries (possibly lists of lists of fields). -- Gisle S�lensminde ( gisle@ii.uib.no ) ln -s /dev/null ~/.netscape/cookies