Delphi:尽管在开始之后设置了返回值,但返回值可能是未定义的

时间:2010-09-08 09:26:25

标签: delphi delphi-5

任何人都可以告诉我为什么我会在这里得到“返回值......可能未定义”:

function TXMLAcceptorBCOLSubmission.createRecordsInBCFEEPAR(AXML: TRipXMLElement): String;
var
  ...
begin
  Result := '';

2 个答案:

答案 0 :(得分:5)

我正在使用Delphi 5,看起来问题是由声明超过30个变量引起的(我知道,我知道)。它们被称为什么或它们是什么类型似乎并不重要。

答案 1 :(得分:2)

以下代码不会使用Delphi 5生成警告

  • 要么是其他Delphi版本中的 bug (你应该提到你使用的版本)
  • 或者是你没有告诉我们的东西。

<强>代码

program ProveAPoint;
{$APPTYPE CONSOLE}
uses SysUtils;

type
  TRipXMLElement = record
  end;
  TXMLAcceptorBCOLSubmission = class
  public
    function createRecordsInBCFEEPAR(AXML: TRipXMLElement): string;
  end;

function TXMLAcceptorBCOLSubmission.createRecordsInBCFEEPAR(AXML: TRipXMLElement): String;
begin
  Result := '';
end;

var
  AXML: TRipXMLElement;
begin
  with TXMLAcceptorBCOLSubmission.Create do
  begin
     createRecordsInBCFEEPAR(AXML);
     Free;
  end;
end.