Steveinalab
Programmer
I have a Delphi program that has a simple function (mysum) defined in the public area
of the form. I drop a button on the form, and on its click event I call my simple function
and get the result;
I later create a new project, and decide I want to use the mysum function, so I
add the first program (containing the mysum function) to the uses clause after
the implementation line.
I can right click on the unit name and select find declaration and it shows the unit I
want with the function, but it won't compile if I try to use the function, giving the error
"undeclared identifier mysum". I tried using the unit name dot the function name like
x := mydemou1.mysym(3,2) but I get the same error.
My solution is to create a new function in the same unit, named mysum2, but not make it part of the
form's class definition, instead it is right after the end line that ends the class definition.
so it is right before "var Form2 : Tform2".
It compiles and works fine, but it cannot refer to any components on the form.
My question is can you call a function that is defined in the form's Public Area from another
program that uses it? Or is it impossible for a calling program to call any functions
defined in the form's public area?
of the form. I drop a button on the form, and on its click event I call my simple function
and get the result;
I later create a new project, and decide I want to use the mysum function, so I
add the first program (containing the mysum function) to the uses clause after
the implementation line.
I can right click on the unit name and select find declaration and it shows the unit I
want with the function, but it won't compile if I try to use the function, giving the error
"undeclared identifier mysum". I tried using the unit name dot the function name like
x := mydemou1.mysym(3,2) but I get the same error.
My solution is to create a new function in the same unit, named mysum2, but not make it part of the
form's class definition, instead it is right after the end line that ends the class definition.
so it is right before "var Form2 : Tform2".
It compiles and works fine, but it cannot refer to any components on the form.
My question is can you call a function that is defined in the form's Public Area from another
program that uses it? Or is it impossible for a calling program to call any functions
defined in the form's public area?