Input a string (again)

From: Stefan Merwitz (thebiggestfan2002_at_yahoo.de)
Date: 01/29/05


Date: Sat, 29 Jan 2005 09:55:02 +0100

Hello everybody,

I'm nearly at despairing. After I'm now able to input a string (30
chars), I need to cancel the loop in the following source, when the user
enters an empty line:

     function InputString return string is
         sString: String(1..30); -- constrained
         iString_Length: Natural range 0..sString'Last;
     begin
         Skip_Line;
         Get_Line(sString, iString_Length);
         if iString_Length = sString'Last then
             Skip_Line;
         end if;
         return sString;
     end;

     bContinue: boolean := true;
     begin
         while bContinue loop
             sHobbyStr := InputString;
             if Trim(To_Unbounded_String(sHobbyStr), Both) = "" then
                 bContinue := false;
             else
                 Put(sHobbyStr);
             end if;
         end loop;
     end;

But unfortunately, neither
     Trim(To_Unbounded_String(sHobbyStr), Both) = ""
nor
     sHobbyStr = " " (30 empty chars)
work.

All I want is to cancel that loop when nothing is entered, help!

Could you please help me,

Stefan



Relevant Pages

  • Re: Inputbox maybe?
    ... typing "Cancel" (or the correct password) to exit the loop. ... Dim strResult as String ... The second choice will be cancel which will return back to the ...
    (microsoft.public.access.formscoding)
  • Re: regex
    ... A string is an array of char. ... I believe the fastedst way would be to loop ... through the chars in the string, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: what is wrong with this code?
    ... read with fgetc or fgets as string, and convert every two characters to integer. ... You can use loop to convert 2 chars each, but you need to know when to exit ...
    (microsoft.public.vc.language)
  • String length
    ... now my question is to find the length of any String manualy we will ... a loop and this with order Owhere n is the number of chars in the ... now is theres a way to find the length of any String with ...
    (microsoft.public.dotnet.languages.csharp)
  • extension_pack
    ... It is used to set upper loop -- limits for non-deterministic values thus avoiding the use of access -- types and enabling the functions to be used for synthesizeable code. ... DivisorVal: integer) return std_logic_vector; function "/"(DividendVal: string; DivisorVal: integer) return std_logic_vector; ... for loopVar in 0 to slvVal'length/4-1 loop ... end loop; if then return not resultVar; -- "width mismatch" errors here are due to improper sizing of the vector that this function is assigned to else return resultVar; -- "width mismatch" errors here are due to improper sizing of the vector that this function is assigned to end if; ...
    (comp.lang.vhdl)