Discussion:
IndexQry.cc from dUFLP
(too old to reply)
kees van rooijen
2008-12-06 18:56:29 UTC
Permalink
I cannot seem to get it right.
I have a form with a datamodule on it referring to the alias and the table and a grid on the form stocked with table data. I try to set the index using indexQry.cc but somehow i dont get it to work.
It (indexQry.cc) does not seem to find my rowset, no matter how I try and whatever value i pass with cTableName. Any assistance is appreciated

KvR
Geoff Wass [dBVIPS]
2008-12-07 06:45:54 UTC
Permalink
In article <#***@news-server>, ***@home.nl
says...
Post by kees van rooijen
I cannot seem to get it right.
I have a form with a datamodule on it referring to the alias and the table and a grid on the form stocked with table data. I try to set the index using indexQry.cc but somehow i dont get it to work.
It (indexQry.cc) does not seem to find my rowset, no matter how I try and whatever value i pass with cTableName. Any assistance is appreciated
KvR
Kees,

You'll have to help us to help you. Can you show us what you are doing
and tell us exactly the error message your are getting and on which line
it is happening?
--
Geoff Wass [dBVIPS]
Montréal, Québec, Canada

.|.|.| dBASE info at http://geocities.com/geoff_wass |.|.|.
.|.|.| ---------------------------------------------------------- |.|.|.
.|.|.| IT Consultant http://Geoff_Wass.com |.|.|.
unknown
2008-12-07 09:31:49 UTC
Permalink
On Sat, 06 Dec 2008 13:56:29 -0500 kees van rooijen
Sender: kees van rooijen <***@home.nl>
wrote the following in:
Newsgroup: dbase.getting-started
Post by kees van rooijen
I cannot seem to get it right.
I have a form with a datamodule on it referring to the alias and the table and a grid on the form stocked with table data. I try to set the index using indexQry.cc but somehow i dont get it to work.
It (indexQry.cc) does not seem to find my rowset, no matter how I try and whatever value i pass with cTableName. Any assistance is appreciated
KvR
The explanation under Usage in the header of file IndexQry.cc appears to be wrong. The method
selIndex is a method of the object New IndexQry() and not of the rowset.

Try the code below my signature to see a demo.


Ivar B. Jessen

//-----
clear

copyFlag = false

if not file("Fish.dbf")
copy table :dbasesamples:Fish to Fish
copyFlag = true
endif

set procedure to :duflp:IndexQry.cc additive
q = new IndexQry()
q.sql = "select * from Fish"
q.active = true

// Set the index to "Name"
q.selIndex("Name")
? "Name of active index set programmatically = ", q.rowset.indexname

// Select an indexname from the listbox
q.selIndex()
? "Name of active index selected from listbox = ", q.rowset.indexname

q.active = false
release object q; release q

if copyFlag
drop table Fish
endif
//-----
kees van rooijen
2008-12-07 14:41:00 UTC
Permalink
Hello Ivar and Geoff

Thanks for your replies. I tried Ivar program below. Same problem with this program, it does not run. In order to explain and to meet Geoff's request, consider that ivars program is mine. I have added msgboxes to indexqry.cc to assist in detecting the problem.

// setup a tableDef:
this.t = new TableDef()
this.t.tableName := cName
msgbox( "cName is "+cName ) (= Fish)
this.t.database := this.database
msgbox( "this.database is "+this.database ) (= object)
this.t.load()
msgbox( "this.t.load()is "+this.t.load() ) (= true)
this.rowset.indexFlag = iif( this.t.indexes.size > 0, true, false )
msgbox( "this.rowset.indexFlag is "+this.rowset.indexFlag ) (= false)

The problem lies in that this.rowset.indexflag return a false, even though the previous 3 messageboxes returned correct results (i believe)

hope this explanation helps you to help me

Thanks

KvR
Post by unknown
On Sat, 06 Dec 2008 13:56:29 -0500 kees van rooijen
Newsgroup: dbase.getting-started
Post by kees van rooijen
I cannot seem to get it right.
I have a form with a datamodule on it referring to the alias and the table and a grid on the form stocked with table data. I try to set the index using indexQry.cc but somehow i dont get it to work.
It (indexQry.cc) does not seem to find my rowset, no matter how I try and whatever value i pass with cTableName. Any assistance is appreciated
KvR
The explanation under Usage in the header of file IndexQry.cc appears to be wrong. The method
selIndex is a method of the object New IndexQry() and not of the rowset.
Try the code below my signature to see a demo.
Ivar B. Jessen
//-----
clear
copyFlag = false
if not file("Fish.dbf")
copy table :dbasesamples:Fish to Fish
copyFlag = true
endif
set procedure to :duflp:IndexQry.cc additive
q = new IndexQry()
q.sql = "select * from Fish"
q.active = true
// Set the index to "Name"
q.selIndex("Name")
? "Name of active index set programmatically = ", q.rowset.indexname
// Select an indexname from the listbox
q.selIndex()
? "Name of active index selected from listbox = ", q.rowset.indexname
q.active = false
release object q; release q
if copyFlag
drop table Fish
endif
//-----
Geoff Wass [dBVIPS]
2008-12-08 06:12:12 UTC
Permalink
In article <***@news-server>, ***@home.nl
says...
Post by kees van rooijen
Hello Ivar and Geoff
Thanks for your replies. I tried Ivar program below. Same problem with this program, it does not run. In order to explain and to meet Geoff's request, consider that ivars program is mine. I have added msgboxes to indexqry.cc to
assist in detecting the problem.
Post by kees van rooijen
this.t = new TableDef()
this.t.tableName := cName
msgbox( "cName is "+cName ) (= Fish)
this.t.database := this.database
msgbox( "this.database is "+this.database ) (= object)
this.t.load()
msgbox( "this.t.load()is "+this.t.load() ) (= true)
this.rowset.indexFlag = iif( this.t.indexes.size > 0, true, false )
msgbox( "this.rowset.indexFlag is "+this.rowset.indexFlag ) (= false)
The problem lies in that this.rowset.indexflag return a false, even though the previous 3 messageboxes returned correct results (i believe)
hope this explanation helps you to help me
Thanks
KvR
Post by unknown
On Sat, 06 Dec 2008 13:56:29 -0500 kees van rooijen
Newsgroup: dbase.getting-started
Post by kees van rooijen
I cannot seem to get it right.
I have a form with a datamodule on it referring to the alias and the table and a grid on the form stocked with table data. I try to set the index using indexQry.cc but somehow i dont get it to work.
It (indexQry.cc) does not seem to find my rowset, no matter how I try and whatever value i pass with cTableName. Any assistance is appreciated
KvR
The explanation under Usage in the header of file IndexQry.cc appears to be wrong. The method
selIndex is a method of the object New IndexQry() and not of the rowset.
Try the code below my signature to see a demo.
Ivar B. Jessen
//-----
clear
copyFlag = false
if not file("Fish.dbf")
copy table :dbasesamples:Fish to Fish
copyFlag = true
endif
set procedure to :duflp:IndexQry.cc additive
q = new IndexQry()
q.sql = "select * from Fish"
q.active = true
// Set the index to "Name"
q.selIndex("Name")
? "Name of active index set programmatically = ", q.rowset.indexname
// Select an indexname from the listbox
q.selIndex()
? "Name of active index selected from listbox = ", q.rowset.indexname
q.active = false
release object q; release q
if copyFlag
drop table Fish
endif
Kees,

Using Ivar's code, I was able to duplicate your problem. I edited
IndexQry.cc.

I changed this:

// let's try to find it ...
this.rowset.indexName := "" // empty it out
for i = 1 to this.parent.t.indexes.size

to this:

// let's try to find it ...
this.rowset.indexName := "" // empty it out
for i = 1 to this.t.indexes.size

Ivar, can you confirm this? If so, we need to let Ken Mayer know.
Thanks.
--
Geoff Wass [dBVIPS]
Montréal, Québec, Canada

.|.|.| dBASE info at http://geocities.com/geoff_wass |.|.|.
.|.|.| ---------------------------------------------------------- |.|.|.
.|.|.| IT Consultant http://Geoff_Wass.com |.|.|.
unknown
2008-12-08 09:19:42 UTC
Permalink
On Mon, 8 Dec 2008 01:12:12 -0500 Geoff Wass
Sender: Geoff Wass [dBVIPS] <***@attglobal.net>
wrote the following in:
Newsgroup: dbase.getting-started
Post by Geoff Wass [dBVIPS]
Using Ivar's code, I was able to duplicate your problem. I edited
IndexQry.cc.
Geoff,

Kees could not make IndexQry.cc work. I posted some code to show how it could be done. Kees did not
tell if the code worked, but mentioned that something else in the cc gave a problem.
Post by Geoff Wass [dBVIPS]
// let's try to find it ...
this.rowset.indexName := "" // empty it out
for i = 1 to this.parent.t.indexes.size
// let's try to find it ...
this.rowset.indexName := "" // empty it out
for i = 1 to this.t.indexes.size
Ivar, can you confirm this? If so, we need to let Ken Mayer know.
Thanks.
Really, what should I confirm? That you wrote the lines above? I don't doubt it <g>

When I posted my code the intention was that Kees or somebody else would come back and confirm that
this specific code also worked for them. If I got a confirming answer Kees could adapt the code to
his own program and would not be delayed because of suspected bugs in IndexQry.cc.

We could then start analyzing the code in IndexQry.cc, maybe in a new thread, or leave it up to Ken
Mayer to figure it out. It could be that none of us have used the cc as intended :-)

So, please, did my code run without errors and did you see the listbox from which indexes could be
selected?


Ivar B. Jessen
Geoff Wass [dBVIPS]
2008-12-09 06:06:12 UTC
Permalink
In article <***@4ax.com>, Ivar B. Jessen
says...
Post by unknown
On Mon, 8 Dec 2008 01:12:12 -0500 Geoff Wass
Newsgroup: dbase.getting-started
Post by Geoff Wass [dBVIPS]
Using Ivar's code, I was able to duplicate your problem. I edited
IndexQry.cc.
Geoff,
Kees could not make IndexQry.cc work. I posted some code to show how it could be done. Kees did not
tell if the code worked, but mentioned that something else in the cc gave a problem.
Post by Geoff Wass [dBVIPS]
// let's try to find it ...
this.rowset.indexName := "" // empty it out
for i = 1 to this.parent.t.indexes.size
// let's try to find it ...
this.rowset.indexName := "" // empty it out
for i = 1 to this.t.indexes.size
Ivar, can you confirm this? If so, we need to let Ken Mayer know.
Thanks.
Really, what should I confirm? That you wrote the lines above? I don't doubt it <g>
When I posted my code the intention was that Kees or somebody else would come back and confirm that
this specific code also worked for them. If I got a confirming answer Kees could adapt the code to
his own program and would not be delayed because of suspected bugs in IndexQry.cc.
We could then start analyzing the code in IndexQry.cc, maybe in a new thread, or leave it up to Ken
Mayer to figure it out. It could be that none of us have used the cc as intended :-)
So, please, did my code run without errors and did you see the listbox from which indexes could be
selected?
Ivar B. Jessen
Ivar,

I'm sorry I was vague. I tried your code and it threw an error. When I
changed the one line in IndexQry.cc (I removed a ".parent"), the code
worked correctly. Since you posted the code, I felt uneasy suggesting
your code did not work and thought I should ask you to confirm it. I now
understand what the intention was.

So, in the end, it looks to me there is one line we need to ask Ken
Mayer to fix.
--
Geoff Wass [dBVIPS]
Montréal, Québec, Canada

.|.|.| dBASE info at http://geocities.com/geoff_wass |.|.|.
.|.|.| ---------------------------------------------------------- |.|.|.
.|.|.| IT Consultant http://Geoff_Wass.com |.|.|.
unknown
2008-12-09 07:32:28 UTC
Permalink
On Tue, 9 Dec 2008 01:06:12 -0500 Geoff Wass
Sender: Geoff Wass [dBVIPS] <***@attglobal.net>
wrote the following in:
Newsgroup: dbase.getting-started
Post by Geoff Wass [dBVIPS]
Post by Geoff Wass [dBVIPS]
// let's try to find it ...
this.rowset.indexName := "" // empty it out
for i = 1 to this.parent.t.indexes.size
// let's try to find it ...
this.rowset.indexName := "" // empty it out
for i = 1 to this.t.indexes.size
[snip]
Post by Geoff Wass [dBVIPS]
I'm sorry I was vague. I tried your code and it threw an error. When I
changed the one line in IndexQry.cc (I removed a ".parent"), the code
worked correctly. Since you posted the code, I felt uneasy suggesting
your code did not work and thought I should ask you to confirm it. I now
understand what the intention was.
Geoff,

No need to be sorry, I just missed info on any error message and if possible a line number. Looking
back at this I had fiddled with the code in IndexQry.cc and probably forgot where, and that was why
my code was running. Later I reloaded a fresh version of the cc and got errors.
Post by Geoff Wass [dBVIPS]
So, in the end, it looks to me there is one line we need to ask Ken
Mayer to fix.
In my opinion there is more than one line to fix. For example,

1) According to the OLH on CLASS:

"Before the first statement in the constructor is executed, if the CLASS extends another class, the
constructor for that superclass has already been executed, so the object contains all the superclass
properties."

Is the the line 'super::execute()' really necessary? When it is commented out the code still works
as before.

2) Run the following from the command pane or a prg,

set proc to :duflp:IndexQry.cc additive
q = new IndexQry()
q.sql = 'select * from Fish'
q.active = true
inspect(q)

Notice that T is a property of q (and not of the rowset, which explains the code change you
propose), and q has the methods GetTablename() and SelIndex(). Then go to the rowset objet and
notice that it has a proerty named IndexFLAG and a method named SelIndex(). That method is created
by the line in the cc: 'this.rowset.selIndex = class::SelIndex'

The errors probably occur because the assignment of SelIndex() to the rowset is not working or the
code gets confused by having two methods of the same name.


Ivar B. Jessen
kees van rooijen
2008-12-09 21:08:47 UTC
Permalink
Ivar 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
unknown
2008-12-09 21:36:51 UTC
Permalink
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 rooijen
Ivar 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
//-----
kees van rooijen
2008-12-10 02:59:15 UTC
Permalink
Ivar

Tried to run the new program (3 programs). Result: Line 51 of IndexQryEx.cc Error: Class does not exist: INDEXQRYEXFORM::INDEXQRYEXFORM and my dbase crashes when exiting

Sorry to say

Kees

kees van rooijen
2008-12-08 18:20:57 UTC
Permalink
Post by Geoff Wass [dBVIPS]
says...
Post by kees van rooijen
Hello Ivar and Geoff
Thanks for your replies. I tried Ivar program below. Same problem with this program, it does not run. In order to explain and to meet Geoff's request, consider that ivars program is mine. I have added msgboxes to indexqry.cc to
assist in detecting the problem.
Post by kees van rooijen
this.t = new TableDef()
this.t.tableName := cName
msgbox( "cName is "+cName ) (= Fish)
this.t.database := this.database
msgbox( "this.database is "+this.database ) (= object)
this.t.load()
msgbox( "this.t.load()is "+this.t.load() ) (= true)
this.rowset.indexFlag = iif( this.t.indexes.size > 0, true, false )
msgbox( "this.rowset.indexFlag is "+this.rowset.indexFlag ) (= false)
The problem lies in that this.rowset.indexflag return a false, even though the previous 3 messageboxes returned correct results (i believe)
hope this explanation helps you to help me
Thanks
KvR
Post by unknown
On Sat, 06 Dec 2008 13:56:29 -0500 kees van rooijen
Newsgroup: dbase.getting-started
Post by kees van rooijen
I cannot seem to get it right.
I have a form with a datamodule on it referring to the alias and the table and a grid on the form stocked with table data. I try to set the index using indexQry.cc but somehow i dont get it to work.
It (indexQry.cc) does not seem to find my rowset, no matter how I try and whatever value i pass with cTableName. Any assistance is appreciated
KvR
The explanation under Usage in the header of file IndexQry.cc appears to be wrong. The method
selIndex is a method of the object New IndexQry() and not of the rowset.
Try the code below my signature to see a demo.
Ivar B. Jessen
//-----
clear
copyFlag = false
if not file("Fish.dbf")
copy table :dbasesamples:Fish to Fish
copyFlag = true
endif
set procedure to :duflp:IndexQry.cc additive
q = new IndexQry()
q.sql = "select * from Fish"
q.active = true
// Set the index to "Name"
q.selIndex("Name")
? "Name of active index set programmatically = ", q.rowset.indexname
// Select an indexname from the listbox
q.selIndex()
? "Name of active index selected from listbox = ", q.rowset.indexname
q.active = false
release object q; release q
if copyFlag
drop table Fish
endif
Kees,
Using Ivar's code, I was able to duplicate your problem. I edited
IndexQry.cc.
// let's try to find it ...
this.rowset.indexName := "" // empty it out
for i = 1 to this.parent.t.indexes.size
// let's try to find it ...
this.rowset.indexName := "" // empty it out
for i = 1 to this.t.indexes.size
Ivar, can you confirm this? If so, we need to let Ken Mayer know.
Thanks.
--
Geoff Wass [dBVIPS]
Montréal, Québec, Canada
.|.|.| dBASE info at http://geocities.com/geoff_wass |.|.|.
.|.|.| ---------------------------------------------------------- |.|.|.
.|.|.| IT Consultant http://Geoff_Wass.com |.|.|.
Hi Geoff, the above suggestion did not improve the situation.
Same results. None.

In line 66 of IndexQry Error: Variable undefined: ROWSET

Kees
Rainald
2008-12-09 04:11:39 UTC
Permalink
Post by kees van rooijen
Hi Geoff, the above suggestion did not improve the situation.
Same results. None.
In line 66 of IndexQry Error: Variable undefined: ROWSET
Kees, why to quote just *EVERYTHING* which had been posted before?

It's very hard to follow this way {siiiigh}.

The way to work in Newsgroups is to *QOUTE* the relevant parts (not take
over just everything).

Pls be so kind as to keep to this basic pattern.


Rainald
unknown
2008-12-08 06:54:17 UTC
Permalink
On Sun, 07 Dec 2008 09:41:00 -0500 kees van rooijen
Sender: kees van rooijen <***@home.nl>
wrote the following in:
Newsgroup: dbase.getting-started
Post by kees van rooijen
Hello Ivar and Geoff
Thanks for your replies. I tried Ivar program below. Same problem with this program, it does not run.
Kees,

What does it mean that it does not run? Do you get an error message, and if Yes, what is it.
Post by kees van rooijen
In order to explain and to meet Geoff's request, consider that ivars program is mine. I have added msgboxes to indexqry.cc to assist in detecting the problem.
Don't use message boxes for debugging. When you press Ok, the message is gone and you have to write
it down in order to report it here. It is better to print results to the results pane. For example
replace the line,
Post by kees van rooijen
msgbox( "cName is "+cName )
with the line,

? "cName is " + cName

Save the code below my signature as indicated. It illustrates how IndexQry.cc may be used in a form
with a datamodule. When the form opens rightclick on the grid and select the desired index from the
listbox that opens. Is that what you are looking for?

Ivar B. Jessen

//--- Save as IdxQFish.wfm -----
** END HEADER -- do not remove this line
//
// Generated on 08-12-2008
//
parameter bModal
local f
f = new IdxQFishForm()
if (bModal)
f.mdi = false // ensure not MDI
f.readModal()
else
f.open()
endif

class IdxQFishForm of FORM
set procedure to Idxq.dmd additive
with (this)
height = 7.6818
left = 24.0
top = 10.4091
width = 91.4286
text = ""
endwith

this.IDXQDATAMODULE1 = new IDXQDATAMODULE()
this.IDXQDATAMODULE1.parent = this
with (this.IDXQDATAMODULE1)
left = 4.0
top = 1.5
endwith

this.GRID1 = new GRID(this)
with (this.GRID1)
onRightMouseDown = class::GRID1_ONRIGHTMOUSEDOWN
dataLink = form.idxqdatamodule1.fish1.rowset
height = 6.5
left = 2.0
top = 1.0
width = 88.0
endwith

this.rowset = this.idxqdatamodule1.fish1.rowset

function GRID1_onRightMouseDown(flags, col, row)
form.IDXQDATAMODULE1.Fish1.selIndex()
return
endclass
//-----

//----- Save as IdxQ.dmd -----
** END HEADER -- do not remove this line
//
// Generated on 07-12-2008
//
class IdxqDATAMODULE of DATAMODULE
set proc to :duflp:IndexQry.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 IndexQry()
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 = "Name"
endwith

endclass
//-----
unknown
2008-12-08 19:25:13 UTC
Permalink
On Mon, 08 Dec 2008 13:26:42 -0500 kees van rooijen
Sender: kees van rooijen <***@home.nl>
wrote the following in:
Newsgroup: dbase.getting-started
This second set of solutions does not work on my system either, i am very sorry to say.
Although the form loads with a filled grid,
Ok, so the form opens and dispays a filled grid.
cliking the grid results in the message "there are no indexes for this table" The riddle continues.
The message comes from a messagebox in IndexQry and is clear. You have no indexes in your table :-)

When I run the code with a table which has no indexes I get the same message.

Try the following commands from the command pane,

use :dbasesamples:Fish
display status

Please let us know how many index tags you see.

In my setup I see four index tags.


Ivar B. Jessen
unknown
2008-12-08 22:30:37 UTC
Permalink
On Mon, 08 Dec 2008 17:02:44 -0500 kees van rooijen
Sender: kees van rooijen <***@home.nl>
wrote the following in:
Newsgroup: dbase.getting-started
Ivar, my fish table has - like yours 4 index tags. Only indexqry still does not finds them and report no indexes for this database. It it not a question of an indexless table. Wish that was my stupidity but it is not
Kees,

Try adding the line indicated below to the code of IdxQFish.wfm.

function GRID1_onRightMouseDown(flags, col, row)
form.IDXQDATAMODULE1.Fish1.selIndex()
? "Number of indexes = ", ""+form.IDXQDATAMODULE1.Fish1.t.indexes.size // <--- Add line
return

With an indexless table the output is,

Number of indexes = 0 and with the Fish table the output is: Number of indexes = 4

It would be interesting to see if you get a zero or maybe just blank space.

Please also confirm that the result was created with IndexQry.cc in original condition, i.e. no
debugging code added.


Ivar B. Jessen
kees van rooijen
2008-12-08 22:02:44 UTC
Permalink
Post by unknown
On Mon, 08 Dec 2008 13:26:42 -0500 kees van rooijen
Newsgroup: dbase.getting-started
This second set of solutions does not work on my system either, i am very sorry to say.
Although the form loads with a filled grid,
Ok, so the form opens and dispays a filled grid.
cliking the grid results in the message "there are no indexes for this table" The riddle continues.
The message comes from a messagebox in IndexQry and is clear. You have no indexes in your table :-)
When I run the code with a table which has no indexes I get the same message.
Try the following commands from the command pane,
use :dbasesamples:Fish
display status
Please let us know how many index tags you see.
In my setup I see four index tags.
Ivar B. Jessen
Ivar, my fish table has - like yours 4 index tags. Only indexqry still does not finds them and report no indexes for this database. It it not a question of an indexless table. Wish that was my stupidity but it is not

Kees
kees van rooijen
2008-12-08 18:26:42 UTC
Permalink
Post by unknown
On Sun, 07 Dec 2008 09:41:00 -0500 kees van rooijen
Newsgroup: dbase.getting-started
Post by kees van rooijen
Hello Ivar and Geoff
Thanks for your replies. I tried Ivar program below. Same problem with this program, it does not run.
Kees,
What does it mean that it does not run? Do you get an error message, and if Yes, what is it.
Post by kees van rooijen
In order to explain and to meet Geoff's request, consider that ivars program is mine. I have added msgboxes to indexqry.cc to assist in detecting the problem.
Don't use message boxes for debugging. When you press Ok, the message is gone and you have to write
it down in order to report it here. It is better to print results to the results pane. For example
replace the line,
Post by kees van rooijen
msgbox( "cName is "+cName )
with the line,
? "cName is " + cName
Save the code below my signature as indicated. It illustrates how IndexQry.cc may be used in a form
with a datamodule. When the form opens rightclick on the grid and select the desired index from the
listbox that opens. Is that what you are looking for?
Ivar B. Jessen
//--- Save as IdxQFish.wfm -----
** END HEADER -- do not remove this line
//
// Generated on 08-12-2008
//
parameter bModal
local f
f = new IdxQFishForm()
if (bModal)
f.mdi = false // ensure not MDI
f.readModal()
else
f.open()
endif
class IdxQFishForm of FORM
set procedure to Idxq.dmd additive
with (this)
height = 7.6818
left = 24.0
top = 10.4091
width = 91.4286
text = ""
endwith
this.IDXQDATAMODULE1 = new IDXQDATAMODULE()
this.IDXQDATAMODULE1.parent = this
with (this.IDXQDATAMODULE1)
left = 4.0
top = 1.5
endwith
this.GRID1 = new GRID(this)
with (this.GRID1)
onRightMouseDown = class::GRID1_ONRIGHTMOUSEDOWN
dataLink = form.idxqdatamodule1.fish1.rowset
height = 6.5
left = 2.0
top = 1.0
width = 88.0
endwith
this.rowset = this.idxqdatamodule1.fish1.rowset
function GRID1_onRightMouseDown(flags, col, row)
form.IDXQDATAMODULE1.Fish1.selIndex()
return
endclass
//-----
//----- Save as IdxQ.dmd -----
** END HEADER -- do not remove this line
//
// Generated on 07-12-2008
//
class IdxqDATAMODULE of DATAMODULE
set proc to :duflp:IndexQry.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 IndexQry()
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 = "Name"
endwith
endclass
//-----
Ivar,

This second set of solutions does not work on my system either, i am very sorry to say.

Although the form loads with a filled grid, cliking the grid results in the message "there are no indexes for this table" The riddle continues.

Kees
kees van rooijen
2008-12-08 18:15:42 UTC
Permalink
Ivar,

to be specific when i run your 1-ste program i get the message(s) back "there are no indexes for this table. I get this message twice!

My (still) message boxes return

cName = Fish
this.database = Object
this.t.load() = true
this.rowset.indexFlag = false

then twice the message no indexes


And I get these messages whether or not i have applied the suggested fix by geoff
Post by unknown
On Sat, 06 Dec 2008 13:56:29 -0500 kees van rooijen
Newsgroup: dbase.getting-started
Post by kees van rooijen
I cannot seem to get it right.
I have a form with a datamodule on it referring to the alias and the table and a grid on the form stocked with table data. I try to set the index using indexQry.cc but somehow i dont get it to work.
It (indexQry.cc) does not seem to find my rowset, no matter how I try and whatever value i pass with cTableName. Any assistance is appreciated
KvR
The explanation under Usage in the header of file IndexQry.cc appears to be wrong. The method
selIndex is a method of the object New IndexQry() and not of the rowset.
Try the code below my signature to see a demo.
Ivar B. Jessen
//-----
clear
copyFlag = false
if not file("Fish.dbf")
copy table :dbasesamples:Fish to Fish
copyFlag = true
endif
set procedure to :duflp:IndexQry.cc additive
q = new IndexQry()
q.sql = "select * from Fish"
q.active = true
// Set the index to "Name"
q.selIndex("Name")
? "Name of active index set programmatically = ", q.rowset.indexname
// Select an indexname from the listbox
q.selIndex()
? "Name of active index selected from listbox = ", q.rowset.indexname
q.active = false
release object q; release q
if copyFlag
drop table Fish
endif
//-----
Loading...