Oh I see your confusion.
First, I am against public variables (except a special one created in main.prg - custom application object). I use public oForm and all those define ... enddefine just for the sake of being able to send a testable form in pure code on a forum. Normally I would use form designer as any other human:)
Using form designer it would be easy to understand.
1) Create a new form - say named TestForm
Modify form TestForm
2) Put a Container from form controls toolbar on to form and name it "buttonContainer" - same name in our sample.
3) From menu, Form\New method and name it "AddButtonsFromDefinition" - again just for the sake of keeping naming same with the sample
4) Open the code window for that new method
-either from properties window locate and dblclick on method name
-or dblclick on form and select "AddButtonsFromDefinition" from drop down on top right
5) Paste the code between:
Procedure AddButtonsFromDefinition && btnAddButtons.Click
...
endproc
removing those 2 lines (paste the body of the code only)
6) Assuming wewould do the call in form.Init, open form's Init method code window and add:
thisform.AddButtonsFromDefinition()
7) Save and run the form (assumed you already had the definitions cursor/table)
If we were doing this in code then would add this code:
Visual Fox Pro
Define Class myForm As Form
Add Object btnAddButtons As CommandButton With Top=5,Left=5,Caption="Add buttons"
Add Object buttonContainer As Container With Top=35,Left=10
*** Here is new codeaddition
Procedure Init
thisform.AddButtonsFromDefinition()
endproc
* ... other codes as before
enddefine
In other words
Visual Fox Pro
define class ....
add ....
...
enddefine
are simply programmatic way of defining a form in code (without a VCX or SCX), we didn't really needed it to be a class but wanted to be able to post on forum (otherwise I would need to zip and send scx/sct files).