1ro No tengo acceso a Internet: por lo que no puedo buscar por esa v�a.
2do Se que while es una palabra reservado de muchos lenguajes de programaci�n: pero cuando digo funci�n while me refiero a la acci�n que hace while dentro del lenguaje que en difinitiva debe ser una funci�n interna del lenguaje.
3ra te copio textual lo que dice el archivo rtl.pdf que me hizo llegar un miebro de la lista que lamentablemente no recuerdo ahora quien fue.
36.9.25 Break
Synopsis: Exit current loop construct.
Declaration: procedure Break
Visibility: default
Description: Break jumps to the statement following the end of the current repetitive statement. The code
between the Break call and the end of the repetitive statement is skipped. The condition of the
repetitive statement is NOT evaluated.
This can be used with For, var{repeat} and While statements.
Note that while this is a procedure, Break is a reserved word and hence cannot be redefined.
Errors: None.
See also: Continue (1234), Exit (1246)
Listing: ./refex/ex87.pp
4to Acabo de probar con la (palabra reservada) continue y tambi�n da error al entrar en el while.
En otro mensaje mando la imagen del error para que veas.
Saludos
=========
|| ISMAEL ||
=========
Earlier message 152 lines
----- Mensaje original -----
De: Raistware
Para: Spanish version of Lazarus List
Enviado: lunes, 23 de noviembre de 2009 10:41
Asunto: Re: [Lazarus-es] Error en funci?n while
Ismael L. Donis Garc?a escribi�:
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.
Saludos:
Lo primero, busca un poco por internet tutoriales b�sicos de Pascal, en especial referente a bucles, porque tienes un lio que no te enteras. Lo segundo, while no es ninguna funci�n, es una palabra reservada, algo dr�sticamente distinto.
'break' funciona para 'romper' bucles, en C y derivados. En pascal 'break', que yo recuerde, solo tiene uso en un case ... of. Para bucles se utiliza 'Continue', que lo que hace es continuar con el siguiente. En tu ejemplo, un simple continue te basta, puesto que ya has puesto una de las condiciones en el while para que salga: bolhenc false
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.
------------------------------------------------------------------------------