comp.lang.ada
 help / color / mirror / Atom feed
From: Mehdi Saada <00120260a@gmail.com>
Subject: Re: CONSTRAINT ERROR? access check failed
Date: Thu, 1 Mar 2018 04:44:44 -0800 (PST)
Date: 2018-03-01T04:44:44-08:00	[thread overview]
Message-ID: <41524447-5faf-4adf-876c-03b9befde23a@googlegroups.com> (raw)
In-Reply-To: <ffpql8F19tvU1@mid.individual.net>

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.

INNER : loop
declare
   NOM_FICHIER : String := Get_Line;
   INDICE      : NATURAL := 0;
   begin
	if Index_Non_Blank (NOM_FICHIER) /= 0
	then
	    if not Exists (NOM_FICHIER) then Put_Line ("N'existe pas. Recommencez."); end if;
	    OPEN (FILE_ENTREE, In_File, NOM_FICHIER);
	    Set_Input (FILE_ENTREE);
	    while not End_Of_File loop
		INDICE := INDICE + 10;
		INSERT_OR_REPLACE (INDICE, LET_ONLY_GRAPHIC_CHARACTERS(GET_LINE));
	    end loop;
        end if;
	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) ?

 function LET_ONLY_GRAPHIC_CHARACTERS
     (INPUT_STRING : in STRING) return STRING is
      use Ada.Strings.Maps.Constants,
	  Ada.Strings.Maps, Ada.Strings.Fixed, Ada.Strings;
      FIRST, I, COUNT, LAST : NATURal := INPUT_STRING'FIRST;
      OUTPUT_STRING         : STRING (INPUT_STRING'Range);

   begin
      loop
	 FIND_TOKEN (Source => INPUT_STRING (I .. INPUT_STRING'LAST),
	      Set    => Graphic_Set,
	      Test   => Inside ,
	      First  => First,
	      Last   => Last);
	 if Last in INPUT_STRING'Range and LAST /= 0 then
	    OUTPUT_STRING (I .. I + LAST - FIRST) := INPUT_STRING (FIRST .. LAST);
	    I := I + LAST - FIRST + 1;
	 else
	    exit; end if;
      end loop;
      PRAGMA Assert (Index (OUTPUT_STRING(OUTPUT_STRING'First .. 
			    (if I > OUTPUT_STRING'Length then OUTPUT_STRING'Last else I))
			      , GRAPHIC_SET, TEST => Outside) = 0, "CHARACTÈRES NON GRAPHIQUE ONT ECHAPPÉS !");
      return OUTPUT_STRING (OUTPUT_STRING'First .. (if I > OUTPUT_STRING'Length then OUTPUT_STRING'Last else I));
   end;


  reply	other threads:[~2018-03-01 12:44 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 [this message]
2018-03-01 13:45     ` Björn Lundin
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