Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Can call a function from DEFINE class?
Message
From
06/05/2024 00:15:13
Lutz Scheffler (Online)
Lutz Scheffler Software Ingenieurbüro
Dresden, Germany
 
 
To
05/05/2024 19:09:40
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Miscellaneous
Thread ID:
01687987
Message ID:
01687989
Views:
47
>Hi,
>
>I would like to be sure that what I am doing is not possible. I am calling a function (using DO FunctionName) from the DEFINE CLASS statement. I get an error.
>
>Does it mean that I must have the function FunctionName as a Procedure in the CLASS?
>
>TIA

Dmitry,

A lot of stuff.

First. This (see help DEFINE CLASS Command)
DEFINE CLASS ClassName1 AS ParentClass
 PROCEDURE cName
  ENDPROC
ENDDEFINE
Declares a Method cName of Class ClassNHame1. Even if it shares the PROCEDURE keyword and some syntax, it is not to be mixed with a function or procedure. There is a lot of difference.

A (User Defined) Function could be called from anywhere, as long as it is to be found. For VFP, there is not much difference declaring a procedure vs. declaring a function.
The declaration of FUNCTION or PROCEDURE does not determine how to use. Only the call (as below) determines the use. For short User Defined Function or Procedure are named UDF.
DO BlyBla
is not a function call. It's a call for a prg or a procedure. A function is called like
BlaBla()
. A function will have a return value, a procedure not.
There are also differences if parameters are by value or by reference. See help for function calls and DO command.

Both functions and procedures are stored in PRG files. A prg file in itself could be a procedure like unit called a program.

Now calling an UDF needs the UDF to be found. Normally the UDF must be within the app or exe, or set visible using SET PROCEURE TO (see help), or if called like
DO MYPROG.prg
, within the same prg file.

HTH
Lutz
Words are given to man to enable him to conceal his true feelings.
Charles Maurice de Talleyrand-Périgord

Weeks of programming can save you hours of planning.

Off

There is no place like [::1]
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform