testpop

{
    $Id: testpop.pp,v 1.3 2005/02/14 17:13:12 peter Exp $
    This file is part of the Free Component Library (FCL)
    Copyright (c) 1999-2000 by the Free Pascal development team
 
    See the file COPYING.FPC, included in this distribution,
    for details about the copyright.
 
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
 **********************************************************************}
{$mode objfpc}
{$h+}
 
program testpop;
 
uses db,memds,classes,sysutils;
 
Procedure DoTest;
 
var
  I,ACount : integer;
  D   : TDateTime;
 
begin
  with TMemDataset.Create(Nil) do
    Try
      With FieldDefs do
        begin
        Clear;
        Add('Boolean', ftBoolean, 0, False);
        Add('Integer', ftInteger, 0, False);
        Add('SmallInt', ftSmallInt, 0, False);
        Add('Float', ftFloat, 0, False);
        Add('String', ftString, 30, False);
        Add('Time', ftTime, 0, False);
        Add('Date', ftDate, 0, False);
        end;
      CreateTable;
      Open;
      D:=now;
      ACount:=1000;
      for I:=1 to ACount do
        begin
        Append;
        FieldByName('Boolean').AsBoolean:=False;
        FieldByName('Integer').AsInteger:=I;
        FieldByName('SmallInt').AsInteger:=I;
        FieldByName('Float').AsFloat:=I/10;
        FieldByName('String').AsString:='Test-Data '+IntToStr(I);
        FieldByName('Time').AsDateTime:=D;
        FieldByName('Date').AsDateTime:=D;
        Post;
        end;
      First;
      ACount:=0;
      While Not EOF do
        begin
        Inc(ACount);
        Writeln('Record ',ACount,' : ');
        Writeln('------------------------');
        For I:=0 to Fields.Count-1 do
          Writeln(Fields[I].FieldName,' : ',Fields[I].AsString);
        Writeln;
        Next;
        end;
      Writeln('Total data size : ',DataSize);
      If (ParamCount>0) then
        FileName:=ParamStr(1);
      Close;
  finally
    Free;
  end;
end;
 
begin
  DoTest;
end.
 

¿Has encontrado algún error? ¿Tienes la solución? Dejame tu correción ;-)

Antes de comentar: Gran parte de los ejercicios propuestos no tienen librerías debido a que Wordpress las eliminó al verlas como etiquetas HTML. Si sabes/tienes/conoces las librerías que hacen falta, déjalo en los comentarios. Y lo mas importante: Todos los ejemplos fueron realizados por personas con únicamente conocimiento básico del lenguaje, no de programación.

Otro punto importante: Si vas a sugerir un segmento de código en algún lenguaje debes hacerlo así:

  • Si es lenguaje C [c]Código en C[/c]
  • Si es lenguaje Pascal [pascal]Aquí dentro el código de Pascal[/pascal].

De esta manera el código coloreas el código.

Otro punto importante para muchos que sienten que se les ignora: Todos los comentarios los reviso y en su debido momento los apruebo, pero ojo con el con lo siguiente:

Me reservo el derecho de alterar, publicar o no los comentarios as´ como cambiar mis condiciones en el momento que así lo requiera.

¿estas de acuerdo? entonces adelante que ya te he quitado bastante tiempo leyendo esta basura de advertencias :)