FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Serious problem with .NTX created with "index on"
Posts: 130
Joined: Fri Jun 30, 2006 02:14 PM
Serious problem with .NTX created with "index on"
Posted: Thu Sep 11, 2008 09:44 AM
I have problems with the "index on" command.
I create my index from inside my procedure with:

USE mydbf 
INDEX ON mydbf->lastname INDEX myntx

If i open the .dbf and .ntx with:
USE mydbf INDEX myntx

all works ok (apparently, but i have problems moving record from my browses, etc.), but if i open the same files with the alias clause:
USE mydbf INDEX myntx ALIAS myalias

i receive a runtime error "Error base 1002/ ALIAS mydbf DOES NOT EXIST" (!?) .
I receive the same error (on the 2nd row) if i try to open the .ntx file with:
USE mydbf ALIAS myalias
SET INDEX TO myntx

If i create the same .ntx file with DBU utility of clipper 5.2, all works ok!

Please help me! There is a bug with the "INDEX ON" command?
Or something wrong or incomplete in my code?
Thank you.
max

FWH 8.04 - XHARBOUR 1.1.0
Posts: 1195
Joined: Mon Oct 17, 2005 05:41 AM
Serious problem with .NTX created with "index on"
Posted: Thu Sep 11, 2008 10:19 AM
You have to use
INDEX ON lastname INDEX myntx

instead of mydbf->lastname
if you want to open the file with
USE mydbf INDEX myntx ALIAS myalias

because the alias 'mydbf' does't exist if you open it with ALIAS myalias

Marc
Regards,

Marc



FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Posts: 130
Joined: Fri Jun 30, 2006 02:14 PM
Serious problem with .NTX created with "index on"
Posted: Thu Sep 11, 2008 10:30 AM

Thank you Marc, but i use the switch /w compiling my .prg, so i can't delete the alias ref. because the harbour compiler stop with "ambigous reference" error in "lastname" variable.
However, if i delete the switch /w and recompiling my .prg, all is right, so your suggest is ok.

A few seconds ago i find the solution for manteining the switch /w and solving the problem.
Reading some .prg in \FWH\SAMPLES directory, i found that i can use the alias "field", like this:

INDEX ON field->lastname to myntx

In this mode, all is ok and (finally!) my xbrowses work fine!
Thank you.
Bye.

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Serious problem with .NTX created with "index on"
Posted: Thu Sep 11, 2008 12:03 PM

>
INDEX ON field->lastname to myntx
>

It is always better not to use alias in index expressions. INDEX ON LASTNAME TO MYNTX is the best and recommended way.

It is desirable that the database understands the expression independant of our program. Even field-> is not necessary and desirable to have just the name of the fields

Regards



G. N. Rao.

Hyderabad, India
Posts: 159
Joined: Wed Mar 28, 2007 01:19 PM
Serious problem with .NTX created with "index on"
Posted: Thu Sep 11, 2008 12:23 PM

Max,
The good old Clipper, behaves the same manner... :-))
Regards,
Euclides

Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Serious problem with .NTX created with "index on"
Posted: Thu Sep 11, 2008 03:09 PM

Max,

>A few seconds ago i find the solution for manteining the switch /w and solving the problem.
>Reading some .prg in \FWH\SAMPLES directory, i found that i can use the alias "field", like this:

You can (and should) also declare all your fieldnames using the FIELD statement like this:

field lastname
...
index on lastname to myntx

Regards,
James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10

Continue the discussion