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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Call function....

Status
Not open for further replies.

Matilde

Programmer
Nov 30, 2001
18
DK
How come i can't call a function inside a procedure??? And how do I fix this?

Thanks
Matilde...
 
You can call a function inside a procedure. I think (although I don't advise doing it) you can even write a function inside a procedure. Can you show us the code that doesn't work? Brian
"There are 2 kinds of people in the world, those that divide people into two groups and those that don't. I belong to the second group." - tag line I stole
 
I'm doing this program about graphing and I need to be able to read the functions from a user input... This is a little part of the program, and it's where I call the raised function it makes an error...


procedure multi(start:integer;slut:integer);
var
r:integer;
answ:real;
begin
for r:=start to slut do
begin
if (func[r]=#42) then
begin
if (func[r+1]=#120) then
begin
if (func[r+2]=#94) then
answ:=raised(r+2,0);
end;

end;

end;


end;
 
I think the request (made in a previous post: thread102-468045) is a bit ambiguous. What I think Matilde is asking is not to call a function (i.e. a routine with a prototype like
Code:
function myfunction:Boolean
) but actually is defining the term "function" to mean "a mathematical operation" that the user can enter e.g. x^2/3 or 2x^2+6. I had a go at answering before, but some other views would be welcome as I don't think my answer was satisfactory! Clive [infinity]
 
I decided not to do the way you suggested because there is a infinite amount of different functions and I want the program to be as user friendly as possible... So I kept on doing the input thing. So now i'm doing a program first to read the function that the user inputs. The best way I could find was to build it up by functions and procedures, but in order to make this work I have to call functions inside procedures and the other way... I don't know if you have any other suggestions or some way that I can solve the error problem...?

Thanks
Matilde... :eek:)
 
Can you step into raised() to see what the error is? Brian
"There are 2 kinds of people in the world, those that divide people into two groups and those that don't. I belong to the second group." - tag line I stole
 
I don't know.. Delphi can't find the declaration or anything about the fnction. It toggles it as a regular undefined variable!
 
Where is raised()? Is it in a compiled unit? Is it possible that real is not a valid data type for the returned value from raised()? Brian
"There are 2 kinds of people in the world, those that divide people into two groups and those that don't. I belong to the second group." - tag line I stole
 
Try doing a Find in Files and choose a top level directory and see if you can find it. What do you know about this Raised function and why are you using it? Did you see it in some help file?

lou
 
No it's a function that I created myself..! It's in the same unit as the multi procedure..!
 
Have you put the declaration for Raised at the top of the unit (in the unit 'header')?

Would it not be better to make everything part of a class?
 
Yes it's already declared... I almost bearly started on Delphi programming so I'm not that much in to it, it might be better to put it in to a class... I just can't figure out this problem.!
 
Can you show us the declaration in the interface section, the function declaration in the implementation section, and tell us what error message the compiler is generating? Brian
"There are 2 kinds of people in the world, those that divide people into two groups and those that don't. I belong to the second group." - tag line I stole
 
Allright I solved the problem by changing some of the procedures so everything is fine! But thank you very much for all your help...

Thanks
Matilde... :eek:)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top