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

How do I view code behind a form 7

Status
Not open for further replies.

stable

Programmer
Mar 19, 2003
92
NZ
Hi there,

I've not used FoxPro before. I've inherited an application originally developed in an old version of FoxPro and converted into Visual FoxPro.

When I open the project in VFP I can see the forms but there is no code "behind" the form - more to the point I don't know how to look at the code. My background is in using MS Access and I expected to see something like the Properties box and an events tab where there is the facility to enter an event procedure for an event.

To view the form in the Project manager window I select the form and click the modify button. The form displayed looks more like an image i.e. I can't click on any controls to get the focus. It is possible to add new controls to the form and seemingly a procedure can also be added for an event.

When the application runs I know that there are comboboxes that are updated depending on user selection so there definitely is some logic behind the form.

Any hints would be much appreciated!

Cheers
 
In the directory where the form is type:

MODI FORM MyForm

You can the double click on controls and access their methods either through the combobox at the top of the document that pops up, or right click on a control and select properties and access them that way.

Under the poperties->methods if you see [user procedue], that means there's code there.

Brian
 
stable

To add to Brian's suggestion, you could also go to Tools->Class Browser (use the Open folder and change the combo at the bottom to Form) locate your form and load it in the class browser and click on the "view class code" button, which will show you all the code for the methods (and more) for the form.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Stable,
Note that Mike's suggestion will only show you the code of the current class/form - not any that it inherits either from it "parent" or the VFP base classes.

Also, unless you are using VFP 8.0, you won't be able to view Parent code in the Form/Class designer "directly", you'll need to use the class browser and drill in.

Rick
 
Hi every one,

Thanks for your all your replies.

Brian, I'm not sure what you mean by "directory where the form is". How do I get to the "window" where I can type in the command
MODI FORM MyForm

I've looked in the VPR help and its seems that there are VFP commands that refer to directories.

I am using VFP 8.0.

Sorry for asking such basic questions!
I just want to view the logic behind the forms. The application is due for a redevelopment to SQL server database and an new client front end. I will be using MS Access ADP for the front end.

Cheers
Stable
 
Try this to navigate to the directory where your form is. You could always type in the full path yourself too.

SET DEFAULT TO GETDIR()
 
Hi Brian,

The problem is I don't know where to type that line of code! I'm assuming its inside VFP somewhere is that correct? If so how do I get there?

Sorry that these questions are so basic!!

cheers
Stable



 
Sounds like you might be running an application written with VFP and not VFP itself. Look to see if it is installed on your computer under c:\program files\Microsoft Visual FoxPro 8\vfp8.exe

Brian
 
Hi Brian,

Yes vfp8.exe is installed there. When I start vfp8.exe I get exactly the same scenario.

Have I not installed VFP correctly?

Stable
 
1. If the screen is there try Control-F2 or go to window -> command window on the menu

2. There might be some settings in a file called 'config.fpw' in the VFP folder which might be changing the default start up. If it's there, open it with notepad and tell us what you see.

3. Also if the screen is there, go to tools -> options -> file locations and look to see if there's anything under 'startup program', if so open with notepad and tell us what you see.

Brian
 
Hi,

You could also consider to read the whole code by using:


scctext("myForm.scx")
modi comm myForm.sca



Koen

 
Hi people,

please don't forget that "stable" is talking about forms converted from older versions of Fox. In those cases forms (called screens sooner) are far from to be normal forms. During conversion there are some choices (keep functionality or visual form – I don't remember it after ages) and sometimes converted forms work well, but it is not possible to edit them normal way. The whole form with controls, when opened, really looks like picture – as stable has said.
I think that the only solution for stable is to edit code at that old version of Fox, or repeat the conversion another way.

To stable: I hope that you have finally the form opened for editing (double click on included controls does nothing). Try rightclick and select Properties in shortcut menu. At list box in the upper part of Properties window try to find PageFrame object and select it (or select something else). If you are lucky, you are now ready to edit controls by double-clicking on them.

Bye Tom
 
Hi everyone,

Thanks very much for your responses.

Brian:
I've typed Modi Form filename and it bring up the form as an "image" like before.
Under the properties ->methods there are no user procedure.

I've tried to "view class code" on the form and there's nothing there - just a blank screen.

I could not find a 'config.fpw' in the VFP folder.

Under tools->options->file locations startup program I get
c:\program files\microsoft visual foxpro 8\taskpane.app. when I open this in notepad it's a large file but not readable.

Koen:
I get the message file 'scctext.prg' does not exist.
modi comm formname.sca produces no code.

Tom:
Sounds very much like that's my problem. I do not have access to the original forpro code.

Fortunately this is not a very complicated system and meantime I have gleaned alot of information from the current users and begun front end development. It would have been nice to confirm the validation etc behind the forms.

Thanks to you all for your patience - I'm continually amazed at how members are so willing to share their knowledge!

Stars to you all.

Stable



 
Change the start up program to nothing, then you should have the default programming environment.

Brian
 
Hi Brian,

I've tried that.
when I select the form and try to view the class code I still get a blank viewcode.prg window.

Stable
 
Stable,
I get the message file 'scctext.prg' does not exist.

SCCTEXT.PRG should be in you VFP Home directory. Try:
Code:
MODIFY COMMAND (HOME(1)+"scctext")
* or to try what Koen was suggesting
DO (HOME(1)+"scctext") with "myForm.scx"
MODI COMM myform.sca
Rick
 
Stable,
"SccText.PRG" Does not exist! Maybe you are in 'the wrong directory'. Firstly I would search my pc if SccText.PRG is indeed missing. When so you have a problem. If not copy this to the directory where the form is from which you want the code. Then it should work. If still negative you have a problem and I suggest you mail me.
Koen
 
Hi Rick and Koen,

I've tried both of your methods and still I get a blank
.sca file.

I'm progressing with my new front end development.

Thanks for your help.

Stable
 
Stable,

Have you now found the scctext.prg?? IF yes, the only thing I can think of is a typo. Any errors?

Koen
 
Hi Koen,
Yes I found the scctext.prg under
C:\Program Files\Microsoft Visual FoxPro 8
I've taken a copy of this file and placed it in the same folder as the .scx file on our network and then typed in the commmand window:
scctext("orgedit.scx")
modi comm orgedit.sca
All I get is the blank .sca window.

I suspect my problem is related to the post that Toman made
earlier as I can't even click on any of the objects on the form.

Cheers
Stable
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top