Welcome, Guest
Username: Password: Remember me
Visual Objects

Please use this forum to post questions about Visual Objects and Vulcan.NET
  • Page:
  • 1

TOPIC:

Problems with reindexing with NTX; record pointer at wrong record 19 May 2022 14:07 #22546

  • ThomasWYale


  • Posts: 42
  • 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?

    Please Log in or Create an account to join the conversation.

    Last edit: by ThomasWYale.

    Problems with reindexing with NTX; record pointer at wrong record 20 May 2022 00:20 #22557

    • Chris
    • Chris's Avatar


  • Posts: 3288
  • 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?

    .
    XSharp Development Team
    chris(at)xsharp.eu

    Please Log in or Create an account to join the conversation.

    Problems with reindexing with NTX; record pointer at wrong record 20 May 2022 01:35 #22558

    • ThomasWYale


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

    DBUSEAREA(FALSE,"DBFNTX","c:\DiscoveryOLD\dbfs\ROOT.dbf")
    DBCREATEINDEX("c:\DiscoveryOLD\dbfs\root1","Literal")

    Please Log in or Create an account to join the conversation.

    Problems with reindexing with NTX; record pointer at wrong record 20 May 2022 01:37 #22559

    • ThomasWYale


  • Posts: 42
  • The files didn't go through. Trying it again.

    Please Log in or Create an account to join the conversation.

    Last edit: by ThomasWYale.

    Problems with reindexing with NTX; record pointer at wrong record 20 May 2022 01:40 #22560

    • ThomasWYale


  • Posts: 42
  • 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.

    File Attachment:

    File Name: ROOT.zip
    File Size:2,665 KB
    Attachments:

    Please Log in or Create an account to join the conversation.

    Last edit: by ThomasWYale.

    Problems with reindexing with NTX; record pointer at wrong record 20 May 2022 09:08 #22561

    • Chris
    • Chris's Avatar


  • Posts: 3288
  • 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:

    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()

    .
    XSharp Development Team
    chris(at)xsharp.eu

    Please Log in or Create an account to join the conversation.

    Last edit: by Chris.

    Problems with reindexing with NTX; record pointer at wrong record 20 May 2022 13:58 #22564

    • ThomasWYale


  • Posts: 42
  • 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:

    DBUSEAREA(TRUE,"DBFNTX","c:\DiscoveryOLD\dbfs\ROOT.dbf")
    DbSetIndex("c:\DiscoveryOLD\dbfs\root1")
    Searching for a value:
    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.

    Please Log in or Create an account to join the conversation.

    Last edit: by ThomasWYale.

    Problems with reindexing with NTX; record pointer at wrong record 20 May 2022 14:08 #22565

    • robert
    • robert's Avatar


  • Posts: 2874
  • 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:
    SetAppLocaleId(MAKELCID(MAKELANGID(LANG_GERMAN, SUBLANG_GERMAN), ;
           SORT_GERMAN_PHONE_BOOK))


    // To use the Swiss German Language in Default sorting mode
    SetAppLocaleId(MAKELCID(MAKELANGID(LANG_GERMAN, SUBLANG_GERMAN_SWISS),;
     SORT_DEFAULT))


    // To use the Norwegian Bokmal language, default sorting mode
    SetAppLocaleId(MAKELCID(MAKELANGID(LANG_NORWEGIAN,SUBLANG_NORWEGIAN_BOKMAL),;
     SORT_DEFAULT))


    // To use language independent sorting
    SetAppLocaleId(MAKELCID(MAKELANGID(LANG_NEUTRAL,SUBLANG_NEUTRAL), ;
     SORT_DEFAULT))

    Robert
    XSharp Development Team
    The Netherlands

    Please Log in or Create an account to join the conversation.

    Problems with reindexing with NTX; record pointer at wrong record 21 May 2022 00:46 #22567

    • ThomasWYale


  • Posts: 42
  • 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!

    Please Log in or Create an account to join the conversation.

    Problems with reindexing with NTX; record pointer at wrong record 21 May 2022 10:53 #22568

    • ThomasWYale


  • Posts: 42
  • 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!

    Please Log in or Create an account to join the conversation.

    • Page:
    • 1