BotonMenu
BotonIndice

Visita : conoce3000.com
Paypal : https://www.paypal.com/donate/?hosted_button_id=XY8TZ3MGN64GE

PASCAL CON FREE PASCAL

PASCAL CON FREE PASCAL

PASCAL CON FREE PASCAL


13. LISTAS Y COLECCIONES.
13.4. EXCEPCIONES EN LISTAS Y COLECCIONES.
13. LISTAS Y COLECCIONES.
13.4. EXCEPCIONES EN LISTAS Y COLECCIONES.
13. LISTAS Y COLECCIONES.
13.4. EXCEPCIONES EN LISTAS Y COLECCIONES.

SIGUIENTE

SIGUIENTE

SIGUIENTE


‒ Excepciones en listas y colecciones.

La excepción más conocida y usada es ElistError, esta excepción ocurre cuando:

  1. No hay memoria para expandir la lista o colección.
  2. Cuando la lista o colección intenta aumentar mas halla de su capacidad máxima.
  3. Cuando se hace referencia a un elemento inexistente en la lista.
  4. Cuando se intenta mover un elemento de la lista o colección fuera de los limites de la misma.

El siguiente ejemplo muestra como usar esta excepción con una Lista:


Descargar
{$codepage utf8}
{$mode objfpc}
Uses sysutils,classes;

Var Lista:Tlist;
    n:^integer;
Begin

  Lista:=Tlist.create;
  new(n);
  n^:=random(1000);
  Lista.add(n);
  try
   Writeln(integer(Lista.items[15]^));
  except
      on EListError do Writeln('Error elemento no existente');
  end;
End.
Código fuente 16: Excepciones con listas.
Descargar

Y este otro ejemplo con colecciones:


Descargar
{$codepage utf8}
{$mode objfpc}
Uses sysutils,classes;

Type
    TInteger=class(TCollectionItem)
      public
       n:integer;
     End;

Var ColeccionN:TCollection;
    n:TInteger;
    i:byte;
Begin
  ColeccionN:=TCollection.create(TInteger);
  n:=TInteger(ColeccionN.Add);
  n.n:=random(1000);
  try
   Writeln(TInteger(ColeccionN.items[15]).n);
  except
    on EListError do Writeln('Error elemento no existente');
  end;
End.
Código fuente 17: Excepciones con colecciones.
Descargar




SIGUIENTE
SIGUIENTE
SIGUIENTE


 
‒ Comentarios y sugerencias.

Agradezco de antemano, todo comentario, sugerencia, y donativo a través de , que ayude a mejorar los contenidos educativos de Conoce 3000. Además, cualquier pregunta o duda que tengas lo puedes hacer por este medio. Pero, todo contenido que pueda resultar ofensivo, malicioso, racista, sexista, discriminatorio, obsceno, vulgar será eliminado. Para clases particulares contactame por whatsapp al 📲 (+51) 999 264 073








PORTADA |  INTERESANTE |  APUNTES |  LIBROS |  GALERIA


Creative Commons License


Todos los textos, imágenes y videos de Conoce3000 estan colocados bajo una licencia : Creative Commons Reconocimiento-NoComercial 3.0 Unported License.