Search code examples
functiondelphireturnreturn-typedelphi-10-seattle

I need to convert some Delphi 7 code to Seattle, but I cannot use the predefined function result "Result"


This works on Delphi 7:

Function T(Noegle : String) : String;
Begin
  Result:= Noegle;
End;

but fails on Seattle with this errormessage:

[dcc32 Error] Tekster.pas(34): E2003 Undeclared identifier: 'Result'

I assume it is disabled by default, since I see Return used in code snippets on this site so I assume it must work, but I have been unable to locate where I turn it on and off.

Result is used in hundreds of functions in the old code, so I would be a happy boy if someone could tell me how to enable it.


Solution

  • The automatic Result variable is available when extended syntax is enabled. To do so, use Project->Options from the IDE main menu, then go to Delphi Compiler->Compiling->Syntax options, and make sure that Extended syntax is checked.

    the below dialog is captured from Berlin 10.1, but should be virtually identical to the one in Seattle 10:

    Project Options Compiling Dialog