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.9 required=5.0 tests=BAYES_00,XPRIO autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,223570f8a5a85f0a,start X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit From: "John Clarke" Newsgroups: comp.lang.ada Subject: unbound array? Date: Mon, 26 Jul 2004 12:20:06 +1000 Organization: ABit X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1437 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 NNTP-Posting-Host: 220.244.246.44 X-Original-NNTP-Posting-Host: 220.244.246.44 Message-ID: <41046a70@dnews.tpgi.com.au> X-Trace: dnews.tpgi.com.au!tpg.com.au 1090808432 220.244.246.44 (26 Jul 2004 12:20:32 +1000) Path: g2news1.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!t-online.de!frankfurt1.telia.de!newsfeed.freenet.de!nntp.gblx.net!nntp3.phx1!dnews.tpgi.com.au!tpg.com.au!not-for-mail Xref: g2news1.google.com comp.lang.ada:2385 Date: 2004-07-26T12:20:06+10:00 List-Id: Hello! I was hoping someone could shed some light. I am writing an ADA program that reads a file and counts the number of words in the text file and stores the word length, of each word encountered, in an array. So for instance i have defined: size : integer := 100; type length_type is array (1..size) of integer; word_length : length_type; Now, if the text file is: "A rat was here." Hence, word_length(1) = 1, word_length(2) = 3, word_length(4) = 4 etc... The problem I am facing is that I don't know how many words I will encounter in the text file. I do not want to constrain size to 100 as I have above. I know I can use unconstrained array type, but this also doesn't solve the problem as an unconstrained array requires a predefined size assigned prior to assigning values to it. I know that size will never be greater than the number of characters in the text file. But it would be a little ridiculous assigning "size" = "number of characters in text file". How can this problem be solved? Any help would be great. Thanks Peter