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

Losing Set Procedure

Status
Not open for further replies.

jjdavis

Technical User
Aug 27, 2002
17
0
0
US
I am using the application framework in VFP8 and I put a set procedure command in the main program. I have several commonly used procedures combined into a "library" program that I want to access at any time. When I build the exe, it seems like it "loses" the library program, basically closing it I guess. But I don't think that I am doing anything in my code to close it. When I was using it in an app file, I never had a problem. Should I even be specifying my library programs this way or is some other way better?

Thanks,
 
Use the Code References tool to search for a SET PROCEDURE that doesn't have the ADDITIVE clause.

Regards,

Mike
 
As the others stated, it sounds like the set procedure command is being executed again without the additive parameter.

I worked on a project for a client a while back and the original developer used SET PROC TO throughout his code and classes. It was a nightmare. Because of that, I have changed my procedures to classes on a lib. Now all I need to do is define my object in startup as public, and then I have access to my method / properties.

* sample startup code
PUBLIC goApp
goApp = CREATEOBJECT('capp')

I get a little fancier and initialize a many properties as possible in the INIT event of the container.

* sample init event code of container.
goApp.tempdir = ADDBS(SYS(5)+SYS(2003)) + "temp"

This does not solve your problem, but it is another way of doing that typically does not get stomped on by others clearing the SET PROCEDURE.



Jim Osieczonek
Delta Business Group, LLC
 
Thanks, for the advice. Still does not help. If I recompile as an app, it works okay, but as soon as I complile as an exe, it still does it. I tried using the Code References tool, but no luck. Sorry Jim, I may have to do some research for your suggestion. Over my head. Have not had any experience using classes other than some button stuff. I just started to use the exe option in VFP8 and now am almost regretting it. It seems much more problematic. Is this just me?
 
When you used the Code Referencer what was your search string? I thought about it later and rather than searching for SET PROCEDURE you should search for SET PROC which would find both.

Regards,

Mike
 
I did try SET PROC and still only returned the ones that I did.

Okay, the place where it was hanging up was an option on a form where I did a RUN command whereas the other options I did calls to the library. I moved the RUN command to a call to the library and now it works. Why I don't know??!!
 
In your search, you may also want to look for CLEAR PROGRAM, and CLEAR ALL - these will "reset" a SET PROCEDURE.

Rick
 
As Rick points out, there are other ways to reset. The help may even show some more. You should have an ADDITIVE clause on your SET PROCEDURE.

Please post the code that caused the problem. Perhaps we can see why it hung.

Regards,

Mike
 
It is working so I'm not too worried about it, but it does bother me a little. The code is below, but I'm pretty sure that the code should not be causing the problem. It does not actually generate an error, but right after I perform that action it gets the error, trying to run something else.

Do Case
Case ThisForm.OGReport.value = 1
do viewdes
Case ThisForm.OGReport.value = 2
Run /N c:\vfp\wsmooth.exe windings.out && err line
Case ThisForm.OGReport.value = 3
Do viewdes3
Case ThisForm.OGReport.value = 4
Do Form eeforms\custom
EndCase
 
I'm thinking that wsmooth.exe is changing the current directory. Just for grins, try this and see if the error goes away.
Code:
LOCAL lcOldDir
Do Case
Case ThisForm.OGReport.value = 1
    do viewdes
Case ThisForm.OGReport.value = 2
    lcOdlDir = CURDIR()
    Run /N c:\vfp\wsmooth.exe windings.out  && err line
    CD &lcOldDir.
Case ThisForm.OGReport.value = 3
    Do viewdes3
Case ThisForm.OGReport.value = 4
    Do Form eeforms\custom
EndCase
Regards,

Mike
 
Tried it. Still go the same error. Cannot find the procedure in the library file. Thanks anyway. You deserve a star for effort.
 
Hi

Some where CLOSE CLEAR is removing the library.
OR
you get into an error situation which calls for the ON ERROR and clears at that time the Library in memory.

Just to solve the problem, probably you can add the code..

LOCAL lcLibrary
lcLibrary = "MYLIBRARY"
IF ! (lcLibrary $ UPPER (SET("PROCEDURE")))
SET PROCEDURE TO (lcLibrary) ADDITIVE
ENDIF
DO CASE
...
...
..

suitably change MYLIBRARY in the above code with the name of library prog and if necessary add path. Similar code can be used, if you are using CLASSLIB also.

:)

____________________________________________
ramani - (Subramanian.G) :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top