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

Вниз

Возврат результата из вложенной функции   Найти похожие ветки 

 
XCoder   (2014-02-06 15:26) [0]

Есть функция DoSomething, которая включает в себя 2 функции - InternalDoSomethingA и InternalDoSomethingAA. Как КОРРЕКТНО возвратить результат DoSomething из вложенной функции InternalDoSomethingAA:


function DoSomething: Boolean;

 procedure InternalDoSomethingA;

   procedure InternalDoSomethingAA;
   begin
     Result := True;
   end;

 begin

 end;

begin

end;


 
Rouse_ ©   (2014-02-06 15:28) [1]

function DoSomething: Boolean;

procedure InternalDoSomethingA;

  procedure InternalDoSomethingAA;
  begin
    DoSomething := False;
  end;

begin
  InternalDoSomethingAA
end;

begin
 InternalDoSomethingA;
end;


 
XCoder   (2014-02-06 15:29) [2]

или лучше так:


function DoSomething: Boolean;
var
 Res: Boolean;

 procedure InternalDoSomethingA;

   procedure InternalDoSomethingAA;
   begin
     Res := True;
   end;

 begin

 end;

begin
 Result := Res;
end;


 
изыди   (2014-02-06 15:29) [3]

function DoSomething: Boolean;

function InternalDoSomethingA: Boolean;

  function InternalDoSomethingAA: Boolean;
  begin
    Result := True;
  end;

begin
 Result := InternalDoSomethingAA;
end;

begin
 Result := InternalDoSomethingA;
end;


 
Rouse_ ©   (2014-02-06 15:30) [4]

Ну и вариант 2:

function DoSomething: Boolean;

 function InternalDoSomethingA: Boolean;

   function InternalDoSomethingAA: Boolean;
   begin
     Result := True;
   end;

 begin
   Result := InternalDoSomethingAA
 end;

begin
 Result := InternalDoSomethingA;
end;


 
XCoder   (2014-02-06 15:30) [5]


> Rouse_ ©   (06.02.14 15:28) [1]


Спасиб


 
DVM ©   (2014-02-06 15:31) [6]

Это что ли надо?

function DoSomething: Boolean;

procedure InternalDoSomethingA;

  procedure InternalDoSomethingAA;
  begin
    DoSomething:= True;
  end;

begin

end;

begin

end;


 
XCoder   (2014-02-06 15:47) [7]


> DVM ©   (06.02.14 15:31) [6]
> Это что ли надо?


Да, раньше не приходилось так возвращать результат, вот и усомнился.


 
icWasya ©   (2014-02-06 17:28) [8]

А вот ещё
http://delphimaster.net/view/15-1390751141/



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

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

Наверх




Память: 0.48 MB
Время: 0.005 c
15-1408018598
Дмитрий СС
2014-08-14 16:16
2015.03.29
Как это называется?


15-1408003458
NailMan
2014-08-14 12:04
2015.03.29
Никому не интересна работа программера Delphi?


15-1407478480
AScript
2014-08-08 10:14
2015.03.29
ActionScript


15-1407848974
Дмитрий СС
2014-08-12 17:09
2015.03.29
Com объект без регистрации библиотеки


15-1407837735
Пит
2014-08-12 14:02
2015.03.29
Интересный номер машины..