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,87a926dbf0cf8cb1,start X-Google-Attributes: gid103376,public From: Simon Bracken Subject: Re: newbie problem Date: 1998/12/04 Message-ID: <748rsl$2jv@gcsin3.geccs.gecm.com>#1/1 X-Deja-AN: 418632629 Content-Transfer-Encoding: 7bit References: <3667EE11.6E94BA0F@interact.net.au> Content-Type: text/plain; charset=us-ascii Organization: GEC Marconi Avionics ltd Rochester Mime-Version: 1.0 Newsgroups: comp.lang.ada Date: 1998-12-04T00:00:00+00:00 List-Id: Graeme Wallace wrote: >If I want to get user input for my program in the form of a string of >undefined length, how do I do so ? If I set the string length to, say: > >help_me_please : String(1..20); > >I seem to be stuck with a string exactly that size. What is the >variable assignment which allows the actual length of the user input to >determine the length of the string which the io system >(ada.text_io.)gets ? > >G Wallace > >Thankyou. >:-) > I'm a newbie too (with respect to the latest edition of Ada) here follows what I would suggest if you were using Ada83. I expect that one of the new (Ada95) string types may be more convenient but this should do the trick (with necessary addition of "ada.") The following is an abstract from a noddy application: it will allow the user to input a string of up to 80 characters. The result is then manipulated in the normal way. {it isn't perfect so if any other pedants are watching I know!} with Text_IO; procedure Example is subtype TEXT_STRING is STRING (1 .. 80); type VARYING is record Text : TEXT_STRING; Last : NATURAL; end record; Input_Record : VARYING; .. blah begin ... Text_IO.Get_Line (Input_Record.Text, Input_Record.Last); case Input_Record.Text (Input_Record.Text'First) is when 'P' => if List = null then List := new PAGE_ITEM; List.Address := Input_Record.Text (2 .. 5); Current_Page_Ptr := List; else ... end Example; Hope this helps a bit. I must aquaint myself with the new stuff. Cheers, Simon.