Hi there. I just installed a Visual FoxPro 9.0 and started "playing" with it. Tried to create a table - it is straightforward and then a form. It seems to be a rich platform.
Something puzzles me though. I do have extensive experience with Visual dBASE PLUS and previous versions in terms of OO language and form/table designer. Thus I am trying to compare. I am attempting to migrate to MS software/platforms wholesale since the dBASE is offering limited options as compared to MS's tools. I am doing C# and Visual FoxPro at the same time.
Anyway, So far, after about two hours of playing with FoxPro Form designer I encountered some problems. They might be due to my unfamiliarity with the setup. Perhaps there are some keys or designer options I have to switch or whatever to make it work the way I think it should.
My major problem now: I cannot seem to find the source code that describes the form. There should be a set of constructors for all controls, the form itself, all the classes, etc. When I add methods there should be some functions in the file. In the designer there are tabs: CODE but when I click on them empty windows with white fields come up and that's it.
Another thing I cannot comprehend is how containers work in here. In dBASE when you dropped a container on a form, the form becomes a parent of this container. You can drop controls (buttons, textboxes (they call them entryfields over there) on the container and the container object becomes a parent for those child control objects, etc. It is very easy to reference the whole hierarchy of objects this way. I could not accomplish it in FoxPro so far.
in dBASE Plus we edit the source code extensively adding new functions after initial work with the designer. Where is the source code in here
Thanks.
Something puzzles me though. I do have extensive experience with Visual dBASE PLUS and previous versions in terms of OO language and form/table designer. Thus I am trying to compare. I am attempting to migrate to MS software/platforms wholesale since the dBASE is offering limited options as compared to MS's tools. I am doing C# and Visual FoxPro at the same time.
Anyway, So far, after about two hours of playing with FoxPro Form designer I encountered some problems. They might be due to my unfamiliarity with the setup. Perhaps there are some keys or designer options I have to switch or whatever to make it work the way I think it should.
My major problem now: I cannot seem to find the source code that describes the form. There should be a set of constructors for all controls, the form itself, all the classes, etc. When I add methods there should be some functions in the file. In the designer there are tabs: CODE but when I click on them empty windows with white fields come up and that's it.
Another thing I cannot comprehend is how containers work in here. In dBASE when you dropped a container on a form, the form becomes a parent of this container. You can drop controls (buttons, textboxes (they call them entryfields over there) on the container and the container object becomes a parent for those child control objects, etc. It is very easy to reference the whole hierarchy of objects this way. I could not accomplish it in FoxPro so far.
in dBASE Plus we edit the source code extensively adding new functions after initial work with the designer. Where is the source code in here
Thanks.

FoxPro v9 vs Visual dBASE Plus 2.01 BDE 5.2.02
cowanm
You can create forms and other objects using designers or via manual coding. I want to clarify a thing:
You drop a container and drop controls on it in dBase like in .Net I guess. If so, procedure is a litlle different in VFP. First you rightclick and select edit (or Ctrl+click). Then add other controls. Otherwise other controls you drop are not part of the container.
I don't know dBase (since dBaseIII+ at least) but a nice feature that I couldn't find in .Net. You can:
-Create a dummy temp form,
-drop some controls, arrange and add code to them
-From menu select 'File\Save As Class' && selected controls create a container class
Something like .Net's control class library but more flexible than that (maybe in future .Net versions:). Same is available for a single control and/or for compound container type controls like grid,pageframe etc.
Gerhard
Visual dBASE plus affords a lot of control over the source code. Once you've mastered some tricks you can pretty much use it as a tool to mold things your way. Sometimes I go to the source to move controls a little to the right oleft or align them since it is easier to do. If I rearrange them in the designer and save the form the designer's editor will mess things up for me in terms of visual appeal. Many names will be changed, lower case will become upper, etc. Anything but your functions (methods, events) will be molested. Thus it is easier to make changes in the designer, then check the source code right away, notice the metric changes that it introduced, copy pieces of constructor code, shut down the designer but without saving the changes and then go straight to the source file and paste those changes at appropriate place.
And also all the delegates I always do by hand in the source file--it is so much easier. All event handlers are done by hands. I am using C# terminology here, it is not called this way in Visual dBASE. I do not know how it is called in FoxPro though.
cerebrate
My question is: Is FoxPro a part of .NET formally or it is outside this category
Also if I developed a form in Visual Studio .NET browser 2003 can I subsequently open it up in a FoxPro browser and vice versa
What does "wiki" stand for anyway
Thanks.
Capitao Esponja
Besides reading the Help file (CHM) which is not bad, you can follow the examples on the Task Pane (one of the toolbar buttons on the extreme right) or you can open it from the Command Box with:
DO (_taskpane)
This is an app written in FoxPro itself that gives you functionality, and discoverability of item and examples. It consustes of several sub-apps (panes) on the top toolbar. The one you should look at is Solution Samples. It consists of a TreeView Control with lots and lots of working examples with source code.
Have fun!
Also look at the richness of information in the VFP Wiki (also a web app fully written in VFP)
http://fox.wikis.com/wc.dll Wiki~ListCategories
fasttrack
Alternatively you can write code in PRGs (text files if you like). This includes classes, forms, and standard Xbase code.
The Class Browser tool will export the code from VCX and SCX files into PRG files, but sometimes it writes code which does not run.
B. Gargle
I have written perhaps half a million lines of source code in Visual dBASE much of it used in my daily routines but now I have to think about becoming integrated in a larger world.
VdBASE does have a driver that allows you to read FoxPro tables although I've never used it. I am wondering if FoxPro community somewhere has a driver that reads the native .dbf tables of dBASE It would allow me to convert many of my database tables to the new format.
Thanks.
SufferTheFools
Hi Alex,
Usually the drivers to read tables are created and distributed by the people who create the software. You can download VFP's ODBC and OLE DB providers from msdn.microsoft.com/vfoxpro/downloads/updates although you should have them already if you'v installed VFP9.
To get dBASE drivers you would need to get them from the people who wrote dBASE, or they will already be installed on your machine with the dBASE install.
The dBASE drivers for FoxPro may not be up-to-date. VFP's ODBC works with all versions of FoxPro tables up to VFP6. After that new features were added to the tables and the data engine that are not compatible with ODBC, and you must access the data via OLE DB. However, tables created with VFP7-9 that do not use any of the new data features are compatible with ODBC.
You may be able to create tables in FoxPro and use your dBASE drivers to write to those tables from the dBASE environment, therefore moving your data. Another way is to export the dBASE tables to some sort of text file and then import that (there are several ways) into FoxPro.
Reza Bemanian
In the old version of foxpro you could edit the screen file, not anymore.
We have containers with hierarchy of objects also. You refer to them with something similar to this:
Thisform.thiscontrol.thiscontrol.attribute
For example:
Thisform.txtLastName.Value = "Higgins"
will change the value of this textbox to "Higgins"
Another example: A label on the form says "Name:"
thisform.lblLastName.caption = "Last Name:"
will change the LABEL called lblLastName to "Last Name"
kian_z20
Ours is at:
http://fox.wikis.com/wc.dll Wiki~FoxProWiki
The most famous one is Wikipedia:
http://en.wikipedia.org/wiki/Main_Page
Visual FoxPro is not a part of .NET in that it does not compile to the CLR. But it can coexist and share information fairly easily through COM Interop
Sample whitepaper:
http://www.west-wind.com/presentations/VFPDOTNETiNTEROP/VFPDOTNETINTEROP.HTM
VFP will work better with .NET in the next release, codenamed "Sedna". See the Sedna Roadmap at:
http://msdn.microsoft.com/vfoxpro/roadmap
cydrakonis
If you think of old days, source code was simple ASCII file. Any editing would be spoiled by designer. In VFP however designer generated code is in tables (scx for form, vcx for class and so on). You can 'hack' the scx, vcx and designer loads with your hacks (cool for me - I always liked manual touch rather than using mouse everywhere:) Also I can give you a tip to interact with your design surface during design time manually.
Suppose you created a checkbox on form, set its font, color etc. Its caption would be something like "Room 1". You want 20 more of these checkboxes lined with 'same left' and only name and caption changes sequentially.
-Drop a checkbox on form
-It's selected by default if not Click to select
-Go to command window and type
Modify Command[ENTER] && or MC[space][ENTER] - case insensitive
-Directly code your "builder" there. ie:
ASelObj(aObj) && Creates an array of selected objects
ASelObj(aObjFrm,1) && Creates an array which points to the parent container
loChkRoom = aObj[1]
loParent = aObjFrm[1]
loChkRoom.Name='chkRoom1'
loChkRoom.Caption='Room 1'
For ix=2 to 20
loChkRoom.CloneObject('chkRoom'+Ltrim(Str(m.ix)))
With Evaluate('loParent.'+'chkRoom'+Ltrim(Str(m.ix))) && obj ref of clone
.Caption = "Room "+Ltrim(Str(m.ix))
.Left = loChkRoom.Left
.Top = loChkRoom.Top + ( loChkRoom.Height + 2 ) * (m.ix - 1)
.Autosize = .t.
EndWith
EndFor
loParent.Refresh
-[Ctrl+A] to select all code and rightclick "Execute Selection"
(It executes selected code but doesn't save anywhere unless you say so - sort of same as select/copy a piece of code from anywhere and execute "ExecScript(_cliptext)" in command window)
This sample doesn't show its power but know that basically it's the same approach "builders" use. With this I rarely need to hack scx myself. For example, in designer properties like class/classlibrary are readonly. You can change them in code hacking scx or this builder approach too works:) - Disclaimer: Hacking forms/classes should always done with a backup and at one's own risk. If you do don't forget to compile.
A final note (I was confused with it when I first stepped into VFP3 OOP from 2.x):
There are methods and events. They're practically the same thing - "procedure" or function. Events are implicitly invoked (while you could explicitly invoke too) as a response to something, methods need explicit calls. (events are C# delegates which you subscribe by default). IOW in C# it looks like:
private void myButton_click(object sender, EventArguments e) {}
If you dblclick an object you get its events/methods code window (dropdown at top right shows the event, left shows the object - so left "myButton", right "Click")
If you code something it's executed at runtime followed by deafult base code of event. A typical example of this is Keypress event:
lparameters nKeyCode, nShiftAltCtrl
if nKeyCode = 13
NODEFAULT && prevent default base code - acts as if [ENTER] not pressed
Keyboard "{TAB}" && replace it with [TAB]
endif
object sender is "this". Eventarguments are 2 int arguments. Well I should stop trying to make analogy - they're not very same:)
In C# you add a method like:
private double getBalance(...) {...}
and a property:
public string MyProperty { get;set; }
In VFP you add a new method via menu in designers (ie: Form-Add method). If not using designer it's simply a new procedure in class code:
define class myForm as Form
add object myTextbox as TextBox
Procedure Init && Form.init
*...
endproc
Procedure myTextBox.Click && form.myTextbox.click
*...
endproc
enddefine
Properties are added via menu in designer too. In code there are more than one way to add them.
define class myForm as Form
myProperty = "InitialValue"
enddefine
myObject.AddProperty() && If object supports method
AddProperty(oObj,...)
I think I told more than needed:)
Steve Cook MSFT
Also there is Microsoft Visual FoxPro-Treiber 4.0 Driver and Microsoft FoxPro Driver (.dbf) on the same machine.
All these drivers are part of the DBE engine and come with the subscription. What I am really looking for is to have a driver in the opposite direction.
Of course, dumping native .dbf dBASE tables into a text file and reading them from there is the last resort. I have this option in the back of my mind. I have used it before when I found indices grossly corrupted or for some other reason.
Thanks.
Jay1964
Another example would be calculating tax from 2 fields called txtPrice and txtQuantity. I would create a textbox called txtTaxAmount with a control source of a property called TaxAmount. Create a property in the form called TaxAmount, another property called TotalCharge, and a custom method called CalcTax. In the valid event in the txtPrice textbox I call a custom method called CalcTax like this:
thisform.CalcTax()
thisform.refresh()
In the CalcTax method I would write:
local nTotal, nTaxPercent, nTotalCharge
*** select setup table to find tax percent stored in table
select setup
nTaxPercent = taxpercent
*** calculate total price and tax
nTotal = thisform.txtPrice * thisform.txtQuantity
thisform.TaxAmount = nTotal * nTaxPercent
thisform.TotalCharge = nTotal + thisform.TaxAmount
Paul Nystrom - MSFT
Maybe it is for the better, I do not know. One has to adjust to what the reality is, not the other way around. Anyway I am waiting for comments from the experts. Perhaps I am wrong on that. Thanks.
chris78