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 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,a62337baf9692b50 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Nick Roberts Newsgroups: comp.lang.ada Subject: Re: Input a string Date: Thu, 27 Jan 2005 22:37:49 +0000 Message-ID: References: <35t138F4pufluU1@individual.net> Content-Type: text/plain; charset=us-ascii X-Trace: individual.net 0d9n8WLjZewLfdEVj8iKAgnjX2p86Qz07d5jfMgVPUJ7a7xHw= X-Orig-Path: not-for-mail User-Agent: Gemini/1.45d (Qt/3.3.2) (Windows-XP) Xref: g2news1.google.com comp.lang.ada:8030 Date: 2005-01-27T22:37:49+00:00 List-Id: Stefan Merwitz wrote: > I need to input a string from the user. For integers I use > Get(IntegerType). But unfortunately this doesn't seem to work for strings > ("unconstrained subtype not allowed"). How do I input a string and > futhermore how to return the first 30 letters if the string is longer than > 30 chars? I'll assume I'm not doing your homework for you :-) One simple soultion is: Description: String(1..30); -- constrained Desc_Length: Natural range 0..Description'Last; ... begin ... Get_Line(Description,Desc_Length); if Desc_Length = Description'Last then Skip_Line; end if; If the (remaining) text on the current line is less than 30 characters, the line will be read into Description(1..Desc_Length). If the text is longer than 30 characters, the first 30 will be put into Description, and the rest will be skipped, and Desc_Length will be set to 30. Either way, the file pointer will be moved to the beginning of the next line. (Untested.) Does this help you? There are certainly various other ways to do it. -- Nick Roberts