Home > Archive > Clipper > March 2005 > index On in a loop
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 |
index On in a loop
|
|
| Alan Secker 2005-03-07, 3:55 pm |
| Has anyone succeeded in putting 'index on' into a for next loop, acting
om passed parameters? I've been toying with passing a two-dimensional
array (Field Name / Tag name) and (Alias) to a routine to do it but it
doesn't work. Can it be done?
Alan Secker
| |
| Ray Marron 2005-03-07, 3:55 pm |
| "Alan Secker" <alan@asandco.co.uk> wrote in message
news:d0ct04$c0k$1@news.freedom2surf.net...
> Has anyone succeeded in putting 'index on' into a for next loop, acting
> om passed parameters? I've been toying with passing a two-dimensional
> array (Field Name / Tag name) and (Alias) to a routine to do it but it
> doesn't work. Can it be done?
I use the following commands in a loop after deleting the existing index &
opening the file exclusively (from a custom data dictionary/array-based
reindexing routine):
ordCondSet(cFor, bFor, nil, bWhile, bEvery, ;
nEvery, nil, nil, nil, nil, lDescending, nil, ;
lAdditive, lUseCurrent, lCustom, .F.)
ordCreate(cBag, cTag, cKey, bKey, lUnique)
--
Ray Marron
| |
| AUGE_OHR 2005-03-08, 8:55 am |
| hi,
> for n = 1 to len (tag_stru)
> index on (cFilename)->(tag_stru[n][1]) TAG ;
> (tag_stru[n][2]) to (cXfile)
CLOSE INDEX
> next
greetings by OHR
Jimmy
| |
| Stephen Quinn 2005-03-08, 8:55 am |
| Alan
You said it doesn't work
- can you tell us what part doesn't work??
- file not created
- tag not created
- ??
> local cFileName := "dummy"
> index on (cFilename)->(tag_stru[n][1]) TAG ;
> (tag_stru[n][2]) to (cXfile)
I suggest you NOT embed the ALIAS into your index expression.
You also don't need
to (cXfile)
when using DBFCDX as it defaults to the 'DBFName.CDX' when omitted
You might try changing the code to something like below and see what the
parameters are in the debugger.
FUNCTION makecdx ( cXfile, tag_stru, cFilename)
local n, j, cTag, cExpr, nArea
nArea := select()
// Make sure your in the right work area
select cFileName
j := len ( tag_stru )
for n := 1 to j
cExpr := tag_stru[n][1]
cTag := tag_stru[n][2]
index on cExpr TAG cTag to (cXfile)
next
select nArea
return NIL
--
HTH
Steve
| |
| Joe Wright 2005-03-08, 3:55 pm |
| Alan Secker wrote:
> Has anyone succeeded in putting 'index on' into a for next loop, acting
> om passed parameters? I've been toying with passing a two-dimensional
> array (Field Name / Tag name) and (Alias) to a routine to do it but it
> doesn't work. Can it be done?
Probably. Show us what you've tried. I'm particularly interested how you
group (Field/Tag) names together logically.
--
Joe Wright mailto:joewwright@comcast.net
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---
| |
| Thomas Braun 2005-03-09, 8:55 am |
| On Sun, 06 Mar 2005 19:24:42 +0000, Alan Secker wrote:
> Here it is passed to the following function:
>
> ****************************************
************************************
> FUNCTION makecdx ( cXfile, tag_stru, cFilename)
> ****************************************
************************************
> local n
>
> for n = 1 to len (tag_stru)
> index on (cFilename)->(tag_stru[n][1]) TAG ;
> (tag_stru[n][2]) to (cXfile)
Do not use the ALIAS with the index expression, this is not needed, and use
Ordcreate() instead to avoid problems with the preprocessor:
(cFilename)->( Ordcreate(cXfile, tagStru[n,1], tagStru[n,2] ) )
If you need to specify additional options like FOR or WHILE clauses,
use the OrdCondSet() function before the Ordcreate() call.
HTH
Thomas
| |
| Thomas Braun 2005-03-11, 8:55 pm |
| On Sun, 06 Mar 2005 19:24:42 +0000, Alan Secker wrote:
> Here it is passed to the following function:
>
> ****************************************
************************************
> FUNCTION makecdx ( cXfile, tag_stru, cFilename)
> ****************************************
************************************
> local n
>
> for n = 1 to len (tag_stru)
> index on (cFilename)->(tag_stru[n][1]) TAG ;
> (tag_stru[n][2]) to (cXfile)
Do not use the ALIAS with the index expression, this is not needed, and use
Ordcreate() instead to avoid problems with the preprocessor:
(cFilename)->( Ordcreate(cXfile, tagStru[n,1], tagStru[n,2] ) )
If you need to specify additional options like FOR or WHILE clauses,
use the OrdCondSet() function before the Ordcreate() call.
HTH
Thomas
|
|
|
|
|