Board index » delphi » HELP - calling a Procedure from with a Procedure??

HELP - calling a Procedure from with a Procedure??

Hi,

I'm a Pascal newbie who has an embarasingly simple problem, but its really
got
me tearing my hair out... and I haven't got that much left... could someone
shed some light on how to call a procedure from within a procedure.

I've got an IF statement which looks something like:

-----

    IF conditionTrue THEN
    BEGIN
        {call the conditonTrue procedure}
    END
    ELSE
    BEGIN
        {call the conditionFalse procedure}
    END;

-----

Where I've commented out the two lines of code is where I want to call
either the True or False procedure.  The True and False conditions are never
called from within the main program  ... ie. within BEGIN and END.  Which
one gets executed will to depend on the whether the IF statement is True or
False.

Could someone fill in the blanks and restore my urge to learn a programming
language...

Thanks in advance.

 

Re:HELP - calling a Procedure from with a Procedure??


On Sat, 27 Jan 2001 20:08:55 -0000, "John Hunter" <d...@nospam.com>
wrote:

Quote
>Hi,

>I'm a Pascal newbie who has an embarasingly simple problem, but its really
>got
>me tearing my hair out... and I haven't got that much left... could someone
>shed some light on how to call a procedure from within a procedure.

There's nothing special about it.  What's likely going wrong for you
is that you have to remember to declare the procedures before you make
use of them.  

Your code should look something like this:

procedure IfTrueProc(arg:integer); { This one has one argument}
begin
  ...
end;

procedure IfFalseProc; { This one just happens to have none }
begin
  ...
end;

begin
    IF conditionTrue THEN
    BEGIN
       IfTrueProc(3);      
    END
    ELSE
    BEGIN
      IfFalseProc;
    END;

Re:HELP - calling a Procedure from with a Procedure??


Quote
John Hunter <d...@nospam.com> wrote in message

news:pVFc6.1487$YT3.51876@news6-win.server.ntlworld.com...

Quote
> Hi,

> I'm a Pascal newbie who has an embarasingly simple problem, but its
> really got me tearing my hair out... and I haven't got that much left...
could
> someone shed some light on how to call a procedure from within a
> procedure.

> I've got an IF statement which looks something like:

[...]

You can simplify this to:

if Condition
  then ConditionTrueProcedure
  else ConditionFalseProcedure;

Where:
"ConditionTrueProcedure" is the name of the procedure you whish to call if
"Condition" evaulates to true, and

"ConditionFalseProcedure" is the name of the procedure you wish to call if
"Condition" evaluates to false.

--
Jay

Jason Burgon - Author of "Graphic Vision"  GUI for DOS/DPMI
=== Free LFN capable Dos/WinDos replacement and ===
=== New Graphic Vision  version 2.11 available from:  ===
http://www.jayman.demon.co.uk

Other Threads