Home > Archive > Clipper > October 2005 > subindex trouble (clipper 5.2e, Six 3.02)
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
subindex trouble (clipper 5.2e, Six 3.02)
|
|
| suv2@mail.ru 2005-10-13, 6:55 pm |
| Trouble: on first iteration index contains 1 key, but on seconds
iteration index contains 10 key. Entry conditions (recno(),ordkey(),
index-create command) are identical in both cases (in (i==1)-case and
(i==2)-case)
-------- test.prg ----------
#define TestRDD SIXCDX // change manually for SIXNSX
#include "sixcdx.ch" // change manually for SIXNSX
#xtranslate StringResult(<X> ) => <"X">
request TestRDD
Field F1
proc main()
local i
CreateDB()
?"RDD:",StringResult(TestRDD)
for i:=1 to 2
use test new via StringResult(TestRDD) excl
set order to 1
if i == 2
go top
end
?"-------------"
?"loop:"+ltrim(str(i))
?"create index,recno()="+ltrim(str(recno()))+;
" ordkey()="+ordkey()
index on F1 to a1 while .T. subindex rest
?"key(s) in index: "+ltrim(str(sx_KeyCount()))
use
next
return
proc CreateDB()
local i
dbCreate("test.dbf",{{"F1","C",10,0}},StringResult(TestRDD))
use test new via StringResult(TestRDD) excl
index on F1 tag F1
for i:=1 to 10
append blank
F1 := chr(64+i)
next
use
return
-------- test.prg ----------
===================== output ===========
RDD: SIXCDX
-------------
loop:1
create index,recno()=1 ordkey()=F1
key(s) in index: 1
-------------
loop:2
create index,recno()=1 ordkey()=F1
key(s) in index: 10
===================== output ===========
| |
| Stephen Quinn 2005-10-14, 3:55 am |
| > index on F1 to a1 while .T. subindex rest
Try it without the WHILE & REST in there
Eg
> index on F1 to a1 subindex
HTH
Steve
| |
| suv2@mail.ru 2005-10-18, 3:55 am |
|
Stephen Quinn wrote:
> Try it without the WHILE & REST in there
This is the sample. I NEED to use in real program these clauses (while,
rest). My code:
dbs (FirstKey)
index on F1 to a1 while <cond> subindex rest
Problem: if recno()==1 after dbS (), then subindex+while+rest work
incorrectly.
| |
| Stephen Quinn 2005-10-18, 9:55 pm |
|
Use a scope instead - no need for a subindex at all
SET SCOPE TO FirstKey
DBGoTop()
IF Sx_KeyCount() > 0
// Process the suckers
ENDIF
CLEAR SCOPE
DBGoTop()
HTH
Steve
|
|
|
|
|