Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Seperating out procedures. 1

Status
Not open for further replies.

PaidtheUmpire

Programmer
Jan 4, 2004
105
0
0
AU
Is there a way to get a second procedure activated inside another procudure. Likea so:

Procedure A
begin
Blah Blah Blah
VariableC := 6 * VariableB;
-- Run Procedure C
end;

Procedure A
begin
Blah Blah Blah
VariableC := (3.5 * VariableB) + 5;
-- Run Procedure C
end;

Procedure C
begin
Edit1.text := VariableC;
end;

Because I have a set of 5 buttons which will do five seperate functions, but then i want them all to meet back at point and then do some more functions.
I know it is possibel i just can't seem to do it :)

Thankyou in advance.
 
Just mention (call) the procedure !!! Or am i missing something ?

Code:
Procedure C;
begin
Edit1.text := VariableC;
end;

Procedure A;
begin
//Blah Blah Blah
VariableC := 6 * VariableB;
// Run Procedure C:
 C;
end;

Procedure B; // ?edited
begin
//Blah Blah Blah
VariableC := (3.5 * VariableB) + 5;
// Run Procedure C:
 C;
end;

hth

- fruNNik
 
make sure that variableC is defined as a global variable known to procs a,b and c

--------------------------------------
What You See Is What You Get
 
Sadly you didn't miss anything...

Just mention (call) the procedure !!! Or am i missing something ?


CODE
Procedure C;
begin
Edit1.text := VariableC;
end;

Procedure A;
begin
//Blah Blah Blah
VariableC := 6 * VariableB;
// Run Procedure C:
C;
end;

How do you then get the code to work.
I wrote the following code:

procedure OneToOneR;
begin
Light1.Picture.LoadFromFile('Images\GreenLight.jpg');
Light2.Picture.LoadFromFile('Images\YellowLight.jpg');
Panel2.Visible := False;
Panel6.Visible := True;
end;

but now i'm getting bugs that make no sense... like:
Undeclared identifier: 'Light1'

even though in other places in my code it is fine. Do I have to initalize the procedure or something?
 
Where is this procedure OneToOneR? If it's not in the same unit as the component Light1 then it can't be found. You have to add the form (where the components are) to your uses clause of the unit where the procedure OneToOneR is and then reference to the component like this:

Code:
FormName.Light1.Picture.LoadFromFile('Images\Greenlight.jpg');

This is how it seems to me since there is no form reference in front of the procedure declaration(implementation).

Off course if you move this procedure to the form where the components are it will work without any other changes. In this case the procedure's implementation part will look like this:
Code:
procedure TFormName.OneToOneR;
begin
Light1.Picture.LoadFromFile('Images\GreenLight.jpg');
Light2.Picture.LoadFromFile('Images\YellowLight.jpg');
Panel2.Visible := False;
Panel6.Visible := True;
end;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top