Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2010.11.07;
Скачать: CL | DM;

Вниз

почта   Найти похожие ветки 

 
Михаил   (2010-08-13 18:15) [0]

Проверьте пожалуйста код

unit pochta;

interface

uses
 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
 Dialogs, IdMessage, IdBaseComponent, IdComponent, IdTCPConnection,
 IdTCPClient, IdMessageClient, IdPOP3, StdCtrls;

type
 TForm1 = class(TForm)
   IdPOP31: TIdPOP3;
   IdMessage1: TIdMessage;
   Label1: TLabel;
   Label2: TLabel;
   Label3: TLabel;
   Button1: TButton;
   Memo1: TMemo;

   procedure Button1Click(Sender: TObject);
 private
   { Private declarations }
 public
   { Public declarations }
   function Upmessage: longint;
 end;

var
 Form1: TForm1;
 msgCount, i: integer;

implementation

{$R *.dfm}

{ TForm1 }

function TForm1.Upmessage: longint;
begin
idpop31.Connect;
MsgCount:=idpop31.CheckMessages;

if msgCount>0 then
begin
for i:=1 to msgCount do
begin
idMessage1.Clear;
idpop31.Retrieve(i, idMessage1);
Label1.Caption:=idmessage1.Subject;
Label2.Caption:=idmessage1.From.Address;
Memo1.Text:=idMessage1.Body.Text;
Label3.Caption:=datetostr(idmessage1.Date);
idpop31.Disconnect;
end
end
else
begin
form1.Caption:="Ïèñåì íåò!";
idpop31.Disconnect;
end;

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

end.


[Warning] pochta.pas(45): For loop control variable must be simple local variable
[Warning] pochta.pas(62): Return value of function "TForm1.Upmessage" might be undefined

возникает при нажатии на кнопку(( как побороть?


 
Amoeba_   (2010-08-13 18:40) [1]


> как побороть?

Как? Исправить ошибки согласно указаниям компилятора.


> For loop control variable must be simple local variable

Переменная счетчика цикла не может быть глобальной переменной.


> Return value of function "TForm1.Upmessage" might be undefined

Значение, возвращаемое ф-ией (Result) должно быть так или иначе проинициализировано, а у Вас ничего этого не сделано.

unit pochta;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, IdMessage, IdBaseComponent, IdComponent, IdTCPConnection,
IdTCPClient, IdMessageClient, IdPOP3, StdCtrls;

type
TForm1 = class(TForm)
  IdPOP31: TIdPOP3;
  IdMessage1: TIdMessage;
  Label1: TLabel;
  Label2: TLabel;
  Label3: TLabel;
  Button1: TButton;
  Memo1: TMemo;

  procedure Button1Click(Sender: TObject);
private
  { Private declarations }
public
  { Public declarations }
  function Upmessage: longint;
end;

var
Form1: TForm1;
msgCount: integer;

implementation

{$R *.dfm}

{ TForm1 }

function TForm1.Upmessage: longint;
var i: integer;
begin
idpop31.Connect;
MsgCount:=idpop31.CheckMessages;

if msgCount>0 then
begin
for i:=1 to msgCount do
begin
idMessage1.Clear;
idpop31.Retrieve(i, idMessage1);
Label1.Caption:=idmessage1.Subject;
Label2.Caption:=idmessage1.From.Address;
Memo1.Text:=idMessage1.Body.Text;
Label3.Caption:=datetostr(idmessage1.Date);
idpop31.Disconnect;
end
Result := 1;
end
else
begin
form1.Caption:="Ïèñåì íåò!";
idpop31.Disconnect;
Result := 0;
end;
end;

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

end.



Страницы: 1 вся ветка

Текущий архив: 2010.11.07;
Скачать: CL | DM;

Наверх




Память: 0.47 MB
Время: 0.012 c
6-1228604398
Caesar32
2008-12-07 01:59
2010.11.07
Веб сервис доступа к БД : SOAP + InterBase


2-1281938546
mefodiy
2010-08-16 10:02
2010.11.07
Сравнение "runtime" и "design time"


15-1280041741
Loginov Dmitry
2010-07-25 11:09
2010.11.07
Пишем свой wysiwyg HTML-редактор


15-1280003372
Юрий
2010-07-25 00:29
2010.11.07
С днем рождения ! 25 июля 2010 воскресенье


2-1281499635
6ruse
2010-08-11 08:07
2010.11.07
Помогите с полем