comp.lang.ada
 help / color / mirror / Atom feed
From: "Björn Lundin" <b.f.lundin@gmail.com>
Subject: Re: CONSTRAINT ERROR? access check failed
Date: Thu, 1 Mar 2018 14:45:16 +0100
Date: 2018-03-01T14:45:16+01:00	[thread overview]
Message-ID: <p7905d$o64$1@dont-email.me> (raw)
In-Reply-To: <41524447-5faf-4adf-876c-03b9befde23a@googlegroups.com>

On 2018-03-01 13:44, Mehdi Saada wrote:
> Those are the two last things I would like you people to review. First, I can't get out of that loop, even with the exit INNER; after "Rentrez vos commandes". It starts it again.
> 

seems strange, since you do exit INNNER.
Are you sure that not something else is happening,
like all this is in a procedure that you call again?


> INNER : loop
...
> 	Put_Line ("Rentrer maintenant vos commandes"); exit INNER;
>     exception when others => Put_Line ("ERREUR");
>     end;
> end loop INNER;
> 
> Then, could you tell what you think of that subprogram that is meant to purge a STRING from non graphic characters (those that make the program crash) ?


 I'm likely gettting bashed for using unbounded string like this,
 but I'd do like this

function Let_Only_Graphic_Characters (Input_String : in String) return
String is
  use Ada.Strings.Unbounded;
  use Ada.Characters.Handling;
  Tmp : Unbounded_String;
begin
  for i in Input_String'range loop
    if Is_Graphic(Input_String(i)) then
      Append(Tmp, Input_String(i));
    end if;
  end loop;
  return To_String(Tmp);
end Let_Only_Graphic_Characters;

or with 'for of' loop

function Let_Only_Graphic_Characters (Input_String : in String) return
String is
  use Ada.Strings.Unbounded;
  use Ada.Characters.Handling;
  Tmp : Unbounded_String;
begin
  for C of Input_String loop
    if Is_Graphic(C) then
      Append(Tmp, C);
    end if;
  end loop;
  return To_String(Tmp);
end Let_Only_Graphic_Characters;



-- 
--
Björn

  reply	other threads:[~2018-03-01 13:45 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-01  0:27 CONSTRAINT ERROR? access check failed Mehdi Saada
2018-03-01  8:07 ` Niklas Holsti
2018-03-01 12:44   ` Mehdi Saada
2018-03-01 13:45     ` Björn Lundin [this message]
2018-03-01 14:06   ` Mehdi Saada
2018-03-01 14:31     ` Mehdi Saada
2018-03-01 14:38     ` Mehdi Saada
2018-03-01 15:53       ` Anh Vo
2018-03-01 17:24         ` Mehdi Saada
2018-03-01 18:34           ` Anh Vo
2018-03-01 17:26       ` Simon Wright
2018-03-01 17:47         ` Mehdi Saada
2018-03-01 17:56       ` Jeffrey R. Carter
2018-03-01  8:30 ` Simon Wright
2018-03-01 12:14   ` Mehdi Saada
2018-03-01 13:27     ` Simon Wright
2018-03-01 13:44       ` Mehdi Saada
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox