[Lazarus-es] Error en funci?n while

Ismael L. Donis Garc?a ismael en citricos.co.cu
Lun Nov 23 17:51:40 CET 2009


He estado todo este fin de semana atascado en un error que me da la función 
while, he tratado por todas las vías que conozco y no he podido solucionar 
el problema.

Al ejecutar la función while en una función que a la ves es llamada por otra 
función y que esta otra función es llamada por un evento, me ocurre el 
error.

Le adjunté en otro mensaje un proyecto de ejemplo pero fue retenido, el 
mismo tenía sintise del error para ver si me
pueden ayudar o es algún error del lazarus o del fpc.

Por lo que copio y pego el código del formulario para que pueda ser 
revisado, es un formulario con 1 boton.

unit uprueba;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, 
Dialogs,
  StdCtrls, StrUtils;

type

  { TForm1 }

  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
    procedure FormShow(Sender: TObject);
  private
    { private declarations }
    function datos(): Boolean;
  public
    { public declarations }
    function IniExistHead(fileini: string; head: string): boolean;
  end;

var
  Form1: TForm1;

implementation

{ TForm1 }

procedure TForm1.Button1Click(Sender: TObject);
  var
    fileini: String;
begin
  {$IFDEF UNIX}
    fileini := GetEnvironmentVariable ('HOME') + '/mprima.ini';
  {$ELSE}
    fileini := ExtractFilePath (Application.Exename) + 'mprima.ini';
  {$ENDIF}
  if datos () then
    begin
      Showmessage ('El archivo ya existía');
      Showmessage (fileini);
    end
  else
    Showmessage ('El archivo fue creado');
end;

procedure TForm1.FormShow(Sender: TObject);
begin
 Button1Click(sender);
end;

function TForm1.datos(): Boolean;
  var
    fileini: String;
    logfile: TFileStream;
begin
  {$IFDEF UNIX}
    fileini := GetEnvironmentVariable ('HOME') + '/mprima.ini';
  {$ELSE}
    fileini := ExtractFilePath (Application.Exename) + 'mprima.ini';
  {$ENDIF}
  if FileExists (fileini) then
    if IniExistHead(fileini, 'Datos') = false then
      result := false
    else
      result := true
  else
    begin
      logfile := TFileStream.Create (fileini, fmCreate or fmOpenReadWrite);
      logfile.free;
      result := false;
    end;
end;

function TForm1.IniExistHead(fileini: string; head: string): boolean;
  var
    bolhenc: boolean;
    strlinea, strhead: string;
    oldfileini: TextFile;
begin
  bolhenc := false;
  AssignFile (oldfileini, fileini);
  Append (oldfileini); // abre un archivo existente

  showmessage ('Punto 1');

  while (not bolhenc) and (not eof(oldfileini)) do
    begin

  showmessage ('Punto 2');

      readln(oldfileini, strlinea);
      strlinea := trim(strlinea);
      if strlinea <> '' then
        if leftstr(strlinea, 1) <> ';' then
          if strlinea = strhead then
            begin
              bolhenc := true; // al documentar la proxima linea el error se 
da aquí
              //break; // si descomento esta linea me da error aqui
            end;
    end;
  closefile(oldfileini);
  result := bolhenc;
end;

initialization
  {$I uprueba.lrs}

end.

Saludos.
=========
¦¦ ISMAEL ¦¦
=========
PD: El atasco me es tal que el viernes por la tarde llamé a un amigo por
teléfono que tiene Internet y el domingo me descargó la última versión
existente y hoy por la mañana la instalé y sigue el problema igual con
Lazarus-0.9.29-22700-fpc-2.3.1-20091122-win32.exe

=========
¦¦ ISMAEL ¦¦
=========
"Oír o leer sin reflexionar es una ocupación inútil".
               Confucio (551-479 a. C.); filósofo chino.

----- Mensaje original ----- 
De: <lazarus-es-bounces en lists.lazarus.freepascal.org>
Para: <ismael en citricos.co.cu>
Enviado: lunes, 23 de noviembre de 2009 08:44
Asunto: El mensaje enviado a Lazarus-es espera la aprobacion del moderador


El mensaje que ha enviado a la lista 'Lazarus-es' y que versa sobre:

    Error en funci?n while

Ha sido retenido en espera de que el moderador de la lista lo revise y
apruebe.

Ha sido retenido por:

    El cuerpo del mensaje es demasiado grande: 1043459 bytes con un
límite
de 40 KB

O se mandará el mensaje a la lista o se le enviará una notificación
con la decisión del moderador. Si desea cancelar este envío, puede
hacerlo a través de la siguiente URL:

    http://lists.lazarus.freepascal.org/mailman/confirm/lazarus-es/c9394a62e92623e1ecaf5989780bf49ceb9b5ae0






More information about the Lazarus-es mailing list