.WFM file structure
The following code was generated by
Dragging a table from the Navigator table’s page onto the Form design surface
Adding a pushbutton from the Component palette
Selecting the onClick event in the Inspector and clicking its tool button
Writing simple code for an event handler that tells how many rows are in the table when the form is run and the button is clicked.
Here is the code:
** END HEADER -- do not remove this line
//
// Generated on 07/18/2014
//
parameter bModal
local f
f = new FishSampleForm()
if (bModal)
f.mdi = false // ensure not MDI
f.readModal()
else
f.open()
endif
class FishSampleForm of FORM
with (this)
height = 23.16
left = 7.3333
top = 3.56
width = 56.5556
text = "Fish"
escExit = false
scrollBar = 2 // Auto
endwith
this.DBASESAMPLES1 = new DATABASE(this)
with (this.DBASESAMPLES1)
left = 40.0
databaseName = "DBASESAMPLES"
active = true
endwith
this.FISH1 = new QUERY(this)
with (this.FISH1)
left = 34.0
database = form.dbasesamples1
sql = "select * from fish.dbf"
active = true
endwith
this.TEXTID1 = new TEXT(this)
with (this.TEXTID1)
height = 1.0
left = 1.5556
top = 3.08
width = 2.8519
wrap = false
alignVertical = 2 // Bottom
text = "ID"
endwith
this.ENTRYFIELDID1 = new ENTRYFIELD(this)
with (this.ENTRYFIELDID1)
dataLink = form.fish1.rowset.fields["id"]
height = 1.0
left = 1.5556
top = 4.4
width = 13.0
endwith
this.TEXTNAME1 = new TEXT(this)
with (this.TEXTNAME1)
height = 1.0
left = 1.5556
top = 5.72
width = 5.9352
wrap = false
alignVertical = 2 // Bottom
text = "Name"
endwith
this.ENTRYFIELDNAME1 = new ENTRYFIELD(this)
with (this.ENTRYFIELDNAME1)
dataLink = form.fish1.rowset.fields["name"]
height = 1.0
left = 1.5556
top = 7.04
width = 32.0
endwith
this.TEXTSPECIES1 = new TEXT(this)
with (this.TEXTSPECIES1)
height = 1.0
left = 1.5556
top = 8.36
width = 7.5741
wrap = false
alignVertical = 2 // Bottom
text = "Species"
endwith
this.ENTRYFIELDSPECIES1 = new ENTRYFIELD(this)
with (this.ENTRYFIELDSPECIES1)
dataLink = form.fish1.rowset.fields["species"]
height = 1.0
left = 1.5556
top = 9.68
width = 42.0
endwith
this.TEXTLENGTH_CM1 = new TEXT(this)
with (this.TEXTLENGTH_CM1)
height = 1.0
left = 1.5556
top = 11.0
width = 10.0556
wrap = false
alignVertical = 2 // Bottom
text = "Length CM"
endwith
this.SPINBOXLENGTH_CM1 = new SPINBOX(this)
with (this.SPINBOXLENGTH_CM1)
dataLink = form.fish1.rowset.fields["length cm"]
height = 1.0
left = 1.5556
top = 12.32
width = 12.0
rangeMax = 100
rangeMin = 1
endwith
this.TEXTDESCRIPTION1 = new TEXT(this)
with (this.TEXTDESCRIPTION1)
height = 1.0
left = 14.7778
top = 11.0
width = 10.25
wrap = false
alignVertical = 2 // Bottom
text = "Description"
endwith
this.EDITORDESCRIPTION1 = new EDITOR(this)
with (this.EDITORDESCRIPTION1)
height = 4.0
left = 14.7778
top = 12.32
width = 20.0
dataLink = form.fish1.rowset.fields["description"]
endwith
this.TEXTFISH_IMAGE1 = new TEXT(this)
with (this.TEXTFISH_IMAGE1)
height = 1.0
left = 1.5556
top = 16.72
width = 10.1574
wrap = false
alignVertical = 2 // Bottom
text = "Fish Image"
endwith
this.IMAGEFISH_IMAGE1 = new IMAGE(this)
with (this.IMAGEFISH_IMAGE1)
height = 4.0
left = 1.5556
top = 18.04
width = 12.0
dataSource = form.fish1.rowset.fields["fish image"]
enabled = true
endwith
this.TITLE1 = new TEXT(this)
with (this.TITLE1)
height = 2.0
left = 1.5556
top = 0.0
width = 8.7778
variableHeight = true
colorNormal = "Highlight/BtnFace"
fontSize = 18.0
fontBold = true
text = "Fish"
endwith
this.PUSHBUTTON1 = new PUSHBUTTON(this)
with (this.PUSHBUTTON1)
onClick = class::PUSHBUTTON1_ONCLICK
height = 1.08
left = 12.4444
top = 0.0
width = 13.6667
text = "Number of Rows"
endwith
this.TEXT1 = new TEXT(this)
with (this.TEXT1)
height = 1.0
left = 28.7778
top = 0.0
width = 12.0
text = "Text1"
endwith
this.rowset = this.fish1.rowset
function PUSHBUTTON1_onClick()
form.text1.text = form.Fish1.rowset.count()
return
endclass
There are four major sections in a .WFM file:
The first part is the optional Header section. This is any code above the ** END HEADER line. Comments that describe the file are usually put here.
Between the header and the beginning of the CLASS definition is the standard bootstrap code. This code instantiates and opens a form when you run the form, similar to the way the boot sector of a disk starts the system when you turn on your computer. The standard bootstrap code allows you to open the form in two ways:
If you DO the .WFM with no parameters, the form is opened with the open( ) method. The form is modeless.
If you DO the .WFM with the parameter True, the form is opened with the readModal( ) method. The form is modal. A modal form cannot be MDI, so the form’s MDI property is set to False first.
The main CLASS definition constitutes the bulk of most .WFM files. This is the code representation of forms designed visually in the Form designer.
Everything after the main class definition, if anything, makes up the General section. This is a place for other functions and classes.