Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to check if function exists?
Message
 
 
To
27/05/2021 14:56:39
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01680784
Message ID:
01680800
Views:
30
>>>>Please let me know if the above is not correct.
>>>
>>>Aha, just "some other check", like I said in reply to Tamar.
>>
>>The problem (my problem) was that I was testing this function, GetGlobal(2) so much at the top of the application where the SET PROCEDURE was not yet declared. and the error code was that program GetGlobal.prg didn't exist.
>
>You'd get that in IDE, when "available" is "is mentioned on the stack or in set procedure". In an exe, whatever is in the project, exists. So you'd not get that result in runtime, and would have to go back to thinking it over.
>
>Yup, the test as it is now is more to the point - you are testing for a real clue as to whether the thing was set or not, i.e. the thing itself. The "do I have this function" test is obviously giving you wrong results (nonexistent before set procedure in IDE, always existent in exe).

I ended up with the following code:
cPath = GetGlobal(2)
If !type("cPath") = "C"
   cPath = pcExePath    && the pcExePath is a public variable set at the top of the program
endif
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Previous
Reply
Map
View

Click here to load this message in the networking platform