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

Error -> "File does not exist" on calling any function of .prg file

Status
Not open for further replies.

KALP1

Programmer
Aug 26, 2016
102
IN
I have put all my generic functions in 1 .prg file(say named it 'General_functions') and in the main program I called
Do General_Functions
In all other programs I just call a function(say Get_Running_year()) defined in General_functions.prg .

Problem is that in some cases not always, I get error "File Get_Running_year.Prg does not exist."
What might be the reason for this as calling in the main prg, all functions defined in General_functions will be made available.

I have tried "Set procedure to General_functions additive" ,then too sometime I get this error.

Is there any other way to do that.
 
Set procedure to General_functions additive is the normal way to make the prg file known and usable.
DO does not make this file known, only a SET PROCEDURE looks for any functions, procedures, and also classes defined in a prg.

Well, and compiling an EXE makes it available even with SET PROCEDURE.
What can cause the error is unsetting the procedures, eg also CLEAR ALL could "unregister" the prg file.
If you have no error handler and select "Suspend" from the error message box, then start the debugger, put a watch on SET('PROCEDURE') and you'll see, whether General_functions.prg is listed or not, if it's not known, something removed it or it was never added.

Like everything SET PROCEDURE works best with an absolute path to the file, or when you CD into the directory or SET PATH has sufficient info, otherwise the SET PROCEDURE ... ADDITIVE might simply fail finding the prg, but that only plays a role within the IDE anyway.

Bye, Olaf.
 
The most likely reason is either:

- Get_Running_Year is not the exact name of the function or procedure within your General_Functions.prg; or

- You didn't correctly define the function or procedure; for exammple, you might have mis-typed the keyword FUNCTION or PROCEDURE, or some other syntactical error.

The easiest way to check the above is to try to call Get_Running_Year() from the command window. Execute your DO or SET PROCEDURE there, and then execute [tt]? Get_Running_Year()[/tt], passing any relevant parameters.

One other possibility is that you executed a CLEAR ALL or CLEAR PROGRAM after calling the PRG but before calling the function.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
In normal course, When I suspend and execute Get_Running_Year, I get its value. When this error occurs and I suspend my program , I don't see it in Set("Procedure") list.
I have 1 program, when I run it , I have General_functions in my list and Get_Running_Year returns currect value . When I esc and and again click that option, I get above said error .I don't see it the Set("Procedure") list.

It was too strange for me as I have not issued Clear all or Clear Program. I have just release my form.
 
Is there any chance your form has a name that conflicts with the function you are calling?

I would append all your general functions to the bottom of your 'main' procedure file, then you don't need to set procedure to anything to use them and 'clear' and 'clear all'
are safe to use (I think)

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
I'm not sure I understand what you are saying. Do you mean that you have [tt]SET PROCEDURE TO General_functions.prg[/tt] in your main program, but when you execute [tt]? SET("Procedure")[/tt], it doesn't show General_functions.prg?

If so, and if you have not executed CLEAR ALL or CLEAR PROGRAM, the only explanation I can think of is that you subsequently issued another SET PROCEDURE (with a different filename), and you did not include the ADDITIVE keyword.

Also, it is not clear what you mean by "When I esc". Are you hitting the ESC key at some point? If so, why and when?

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
'clear' and 'clear all' are safe to use (I think)

The only time I believe it is safe to use CLEAR ALL within a program is right at the start, before you have a assigned any variables, opened any tables, declared any DLLs, or created any menus. Personally, I would not use it at any other time (within a program).

CLEAR on its own is another matter. That simply clears the background screen. I don't normally have any reason to do that within a program, but it does no harm if you do.

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
I think it's a file/object/variable naming conflict.

I spent ages once (many years ago) chasing why my variable 'Transmit' sometimes vanished, before I noticed I had a form called 'Transmit' as well.
Whenever I released the form, the variable went too.

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
One other possibility comes to mind (albeit a very slim one):

For some reason, General_functions didn't get compiled, and your program is looking in an old version of the FXP file that didn't have the function in question. Try deleting General_functions.FXP, then running the test again.

It's unlikely that this is the cause of the problem, but it is worth taking a few seconds to check.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
You are right Mike, I use CLOSE ALL and CLEAR DLLS quite a bit, not CLEAR ALL

And as for the naming thing, that's why most people use a naming convention frmXX, gblXX, txtXX etc

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
I don't have conflicting form name with functions name.

By code references I have thoroughly checked whether additive clause is missing in set procedure or not. I haven't found it anywhere.
As I have put very generic functions in that prg,so they are called from many programs.While working sometimes that error message prompts up.

So I think Griff's suggestion to put all prgs in main program should work.
 
Will try that Mike. But don't know when this error will come or got solved.
 
System can't 'forget' the main program - it's still running, usually...

Good luck.

One other thing, you might have a memory leak, where something is progressively using up memory and then VFP does sometimes forget things...
If your program is iterating through something, perhaps you could reload it every 100 iterations?

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
Shellexecute the same executable and then quit.

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
Working environment would be lost in that case then.
 
Yes, that's true - but if you are in an iterative position you could rebuild it couldn't you?

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
I don't know if this is something still a problem with VFP9, but I recall sometimes VFP had problems with long Function/Procs names.
I think it only looks for a specific number of characters in the names...
 
Also, that is rather the point - to abandon the current status and reload the .exe from scratch, so that any memory leak is mitigated.

Memory leaks come from a number of places, BTW, I have one exe that forgets things if an email address it is sending to is slightly awry. So, if it emails a big file to mg;xs@gby.co
it might forget which tables were open and crash on a skip or whatever. Another processes JPG files and that slowly eats the memory

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top