On Tue, 09 Dec 2008 16:08:47 -0500 kees van rooijen
Sender: kees van rooijen <***@home.nl>
wrote the following in:
Newsgroup: dbase.getting-started
Post by kees van rooijenIvar and Geoff
I lost track and are still up the creek without a paddle.
Now how do i get indexqry.cc to run with a datamodule and a rowset?
Thanks
Kees,
I tried to fix IndexQry.cc, but ended up ( 15 minutes ago ) with a different and untested version
named IndexQryEx.cc.
Save, in the same folder, the code below my signature as indicated and run. It works for me so far.
Ivar B. Jessen
//----- Save as IndexQryEx.cc -----
/*
INDEXQRYEX.CC
9-12.2008
Ivar B. Jessen
Based heavily on IndexQry.cc by Ken Mayer
A custom query class with a "selIndex()" method.
Note that this file has two classes: the query (IndexQryEx)
and a form (IndexQryExForm)
Usage:
set procedure to IndexQryEx.cc additive
q = new IndexQryEx()
q.sql = "select * from 'MyTable'"
q.active = true
// so far, just like a normal query, you can also
// assign a database before the active statement
q.selIndex() // blank will bring up a form
OR
q.selIndex("MyIndex") // will attempt to find it,
// and if found, will set it ...
NOTE: This code always sets the row pointer to the top of
the rowset (this.rowset.first() ) -- there are two
places it does this -- if you would rather it didn't,
simply comment them out ...
*/
class IndexQryEx of QUERY custom
protect cName, indexFlag, tDef
Procedure selIndex ( cIndexName )
this.cName = this.rowset.tableName
if empty(this.cName )
msgbox( "Error -- invalid table name" )
return
endif
this.tDef = new tableDef()
this.tDef.database = this.database
this.tDef.tableName = this.cName
this.tDef.load()
this.indexFlag = iif( this.tDef.indexes.size > 0, true, false )
if this.indexFlag
if empty( cIndexName )
fQryx = new IndexQryExForm()
fQryx.Indexes = new Array()
// Load array used in form for listbox:
fQryx.Indexes.add( "<No Index>" )
for i = 1 to this.tDef.indexes.size
fQryx.Indexes.Add( this.tDef.indexes[i].indexName )
next i
fQryx.indexes.sort()
fQryx.indexListBox.dataSource := "array fQryx.indexes"
fQryx.indexListBox.curSel := 1
// Open it!
fQryx.ReadModal()
// set it!
if fQryx.indexListBox.value == "<No Index>"
this.rowset.indexName := ""
else
this.rowset.indexName := fQryx.indexListBox.value
endif
this.rowset.first()
else
// let's try to find it ...
this.rowset.indexName := "" // empty it out
for i = 1 to this.parent.t.indexes.size
if upper(cIndexName) == upper( this.tDef.indexes[i].indexName )
this.rowset.indexName := cIndexName
this.rowset.first()
exit
endif
next i
// if the indexName is still empty:
if empty( this.rowset.indexName )
msgbox( "Could not find indexName: " + cIndexName + "." )
endif
endif // empty( cIndexName )
else
// Let user know somewhere there's a mistake ... <G>
msgbox( "There are no indexes for this table" )
endif
*/
endclass
// end of class: INDEXQRYX()
// form used above in SelIndex routine:
class indexqryExForm of FORM
with (this)
scaleFontBold = false
height = 11
left = 31.2857
top = 4.9545
width = 40
text = "Select index for data"
clientEdge = true
topMost = true
autoCenter = true
mdi = false
smallTitle = true
sizeable = false
escExit = false
maximize = false
minimize = false
endwith
this.INDEXLISTBOX = new LISTBOX(this)
with (this.INDEXLISTBOX)
height = 5.7727
left = 1.8571
top = 0.8182
width = 35.5714
id = 101
colorHighLight = "white/blue"
endwith
this.TEXTEXPL = new TEXT(this)
with (this.TEXTEXPL)
height = 2.1818
left = 2.5714
top = 6.9545
width = 34.1429
border = true
fontSize = 8
fontItalic = true
text = "Select the index you wish to use. " + ;
"When you click the button below, " + ;
"whatever index you have chosen will take effect on your table."
borderStyle = 10 // Etched Out
endwith
this.DONEPUSHBUTTON = new PUSHBUTTON(this)
with (this.DONEPUSHBUTTON)
height = 1.0909
left = 17.2857
top = 9.4091
width = 4.7143
text = ""
default = true
upBitmap = "RESOURCE #1005"
downBitmap = "RESOURCE #1006"
speedTip = "Done"
value = false
onClick = {; form.close() }
endwith
endclass
/*
end of file: indexqryEx.cc
*/
//-----
//----- Save as IdxQExFish.wfm -----
** END HEADER -- do not remove this line
//
// Generated on 08-12-2008
//
parameter bModal
local f
f = new IdxQExFishForm()
if (bModal)
f.mdi = false // ensure not MDI
f.readModal()
else
f.open()
endif
class IdxQExFishForm of FORM
set procedure to Idxqx.dmd additive
with (this)
height = 7.6818
left = 24.0
top = 10.4091
width = 91.4286
text = ""
endwith
this.IDXQXDATAMODULE1 = new IDXQXDATAMODULE()
this.IDXQXDATAMODULE1.parent = this
with (this.IDXQXDATAMODULE1)
left = 4.0
top = 1.5
endwith
this.GRID1 = new GRID(this)
with (this.GRID1)
onRightMouseDown = class::GRID1_ONRIGHTMOUSEDOWN
dataLink = form.idxqxdatamodule1.fish1.rowset
height = 6.5
left = 2.0
top = 1.0
width = 88.0
endwith
this.rowset = this.idxqxdatamodule1.fish1.rowset
function GRID1_onRightMouseDown(flags, col, row)
form.IDXQXDATAMODULE1.Fish1.selIndex()
return
endclass
//-----
//----- Save as Idxqx.dmd -----
** END HEADER -- do not remove this line
//
// Generated on 07-12-2008
//
class IdxqxDATAMODULE of DATAMODULE
set proc to :duflp:IndexQryEx.cc additive
with (this)
left = -1.0
top = -1.0
endwith
this.DBASESAMPLES1 = new DATABASE()
this.DBASESAMPLES1.parent = this
with (this.DBASESAMPLES1)
left = 19.0
top = 135.0
databaseName = "dBaseSamples"
active = true
endwith
this.FISH1 = new IndexQryEx()
this.FISH1.parent = this
with (this.FISH1)
left = 125.0
top = 45.0
width = 114.0
height = 132.0
database = form.dbasesamples1
sql = 'Select * from "Fish"'
active = true
endwith
with (this.FISH1.rowset)
indexname = "Species"
endwith
endclass
//-----