Problems with reindexing with NTX; record pointer at wrong record

Public support forum for peer to peer support with related to the Visual Objects and Vulcan.NET products
Post Reply
ThomasWYale
Posts: 43
Joined: Thu Jun 20, 2019 5:19 pm

Problems with reindexing with NTX; record pointer at wrong record

Post by ThomasWYale »

There's no relevant changes to my code, or the DBF tables and associated NTX files they're indexed with, but a few changes to my environment. Within the last few months I used Acronis True Image to copy the contents of my old drive to my new one, as well as install XIDE and VS. At no point during that time did I need to reindex a DBF file.

When I did reindex one DBF last night, I ran my code as usual, but the record pointer kept going to the wrong record. I even hard-coded what I wanted it to find at that point, DbSeek("m*an"), and it kept going to either the record with the field "sitter*" or "*eat" (those asterisks in the words are necessary to indicate to my application at which point to inflect English words with associated codes, e.g. "eat" -> "ate", "man" -> "men").

By process of elimination, certainly one of the changes in the environment had affected my app's ability to create NTX files, especially if nothing about the tables, indices or relevant code to search for records have changed. Is there any way I can attempt to repair this, perhaps through ODBC? Has anyone else had this problem?
User avatar
Chris
Posts: 4907
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Problems with reindexing with NTX; record pointer at wrong record

Post by Chris »

Hi Thomas,

Can you post the dbf and ntx files, together with the code you use to reindex them, so we can have a look?

.
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
ThomasWYale
Posts: 43
Joined: Thu Jun 20, 2019 5:19 pm

Problems with reindexing with NTX; record pointer at wrong record

Post by ThomasWYale »

The dbf and ntx file are attached, and the only lines of code used to index are:

DBUSEAREA(FALSE,"DBFNTX","c:DiscoveryOLDdbfsROOT.dbf")
DBCREATEINDEX("c:DiscoveryOLDdbfsroot1","Literal")
ThomasWYale
Posts: 43
Joined: Thu Jun 20, 2019 5:19 pm

Problems with reindexing with NTX; record pointer at wrong record

Post by ThomasWYale »

The files didn't go through. Trying it again.
ThomasWYale
Posts: 43
Joined: Thu Jun 20, 2019 5:19 pm

Problems with reindexing with NTX; record pointer at wrong record

Post by ThomasWYale »

Still didn't go through. I attached the files themselves, and when that didn't work, put them in a zip file and included that. Not sure how to send them to you. Trying it again.
ROOT.zip
(2.6 MiB) Downloaded 138 times
User avatar
Chris
Posts: 4907
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Problems with reindexing with NTX; record pointer at wrong record

Post by Chris »

Hi Thomas,

Thanks! And can you also post some code that reproduces the problem with seek?

I tried here this simple code and this seems to work fine (without recreating the index, just using the one you posted), so there must be something different in your code:

Code: Select all

FUNCTION Start() AS VOID
LOCAL cFolder AS STRING
cFolder := "C:.......ROOT"
? DbUseArea(,"DBFNTX",cFolder + "ROOT")
? DbSetIndex(cFolder + "ROOT1.NTX")
? DbSeek("m*an") // true
? FieldGet(1) // "m*an"
? DbCloseArea()
.
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
ThomasWYale
Posts: 43
Joined: Thu Jun 20, 2019 5:19 pm

Problems with reindexing with NTX; record pointer at wrong record

Post by ThomasWYale »

But I changed nothing in the code. The problem occurred when I edited a field in one record and reindexed, and nothing else was affected. That's why I figured that something changed in my PC environment, more likely my upgrade from Windows 7 to 10, less likely the disk imaging from my old hard drive to my current one. Anyway, here's the code for opening the table:

Code: Select all

DBUSEAREA(TRUE,"DBFNTX","c:DiscoveryOLDdbfsROOT.dbf")
DbSetIndex("c:DiscoveryOLDdbfsroot1")
Searching for a value:

Code: Select all

 FOR y:=0 UPTO SLen(ocWord:cLiteral)
  DbSeek(Left(ocWord:cLiteral,SLen(ocWord:cLiteral)-y)+"*")
  IF!Left(ocWord:cLiteral,SLen(ocWord:cLiteral)-y)+"*"==Left(literal,SLen(ocWord:cLiteral)-y+1)
   LOOP
  ENDIF
  WHILE Left(ocWord:cLiteral,SLen(ocWord:cLiteral)-y)+"*"==Left(literal,SLen(ocWord:cLiteral)-y+1)
   DbSelectArea("WRDNFLCT")
   DbGoto(Integer(Root->(wrdnflct)))
   SELF:rootFound(ocWord)
   DbSelectArea("ROOT")
   DBSKIP()
  ENDDO
  IF lExit
   EXIT
  ENDIF
 NEXT
The code for this literally hasn't changed for decades. A good indication of this is that I downloaded DBF Manager, which enables me to create and reindex an NTX file for a DBF. When I reindex from my application, it fails. When I reindex using DBF Manager, there's no problem. That definitely suggests something in the environment.
User avatar
robert
Posts: 4520
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

Problems with reindexing with NTX; record pointer at wrong record

Post by robert »

Thomas,
If your code uses SetCollation(#Windows) then a change in the OS might cause the problem.
Especially if you change from a US version to a German version or vice versa.
If you want to be independent on the OS cultural settings, then use SetAppLocaleID() to set the locale to use when sorting:

// To use the standard German Language in Phone Book sorting mode:

Code: Select all

SetAppLocaleId(MAKELCID(MAKELANGID(LANG_GERMAN, SUBLANG_GERMAN), ;
       SORT_GERMAN_PHONE_BOOK))


// To use the Swiss German Language in Default sorting mode

Code: Select all

SetAppLocaleId(MAKELCID(MAKELANGID(LANG_GERMAN, SUBLANG_GERMAN_SWISS),;
 SORT_DEFAULT))


// To use the Norwegian Bokmal language, default sorting mode

Code: Select all

SetAppLocaleId(MAKELCID(MAKELANGID(LANG_NORWEGIAN,SUBLANG_NORWEGIAN_BOKMAL),;
 SORT_DEFAULT))


// To use language independent sorting

Code: Select all

SetAppLocaleId(MAKELCID(MAKELANGID(LANG_NEUTRAL,SUBLANG_NEUTRAL), ;
 SORT_DEFAULT))
Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
ThomasWYale
Posts: 43
Joined: Thu Jun 20, 2019 5:19 pm

Problems with reindexing with NTX; record pointer at wrong record

Post by ThomasWYale »

Robert,
I think you may be on to something. My app doesn't use SetCollocation(#WINDOWS) but it does use SetCollocation(#CLIPPER). Perhaps it would be possible that using #CLIPPER as the argument would change the behavior after an OS update. I'll follow up on this and alternate between settings using SetAppLocaleId() to see whether this resolves the problem. Thank you for your prompt reply!
ThomasWYale
Posts: 43
Joined: Thu Jun 20, 2019 5:19 pm

Problems with reindexing with NTX; record pointer at wrong record

Post by ThomasWYale »

Robert, thanks to you, I found the reason for the problem! I had SetCollocation(#CLIPPER) only after my dialog I use to reindex the DBF's I use in my app. In that case, the NTX was created with #WINDOWS, which is the default. When I inserted SetCollocation(#CLIPPER) before that dialog comes up, it solved the problem! Thank you, sir!
Post Reply