fbpx
Welcome, Guest
Username: Password: Remember me
This public forum is meant for questions and discussions about Visual FoxPro
  • Page:
  • 1

TOPIC:

Record order incorrect using Scan on a DBF with no Index/Order... 29 Jul 2020 18:29 #15357

  • FoxProMatt's Avatar

  • FoxProMatt

  • Topic Author


  • Posts: 400
  • When I USE a DBF and do not set an index or order tag, then I use the SCAN command to iterate over it and print certain records, the order that X# displays the records does not match the order that VFP displays the records.

    See screenshot which compares VFP output to X# output.

    DBF and CDX attached for testing (in a zip file) Note, the CDX is not used in my code, but I sent it because it is present in the folder.

    Here's the code:
    Function TestUseWithScan()
    	
    	Local lnX As Int	
    	Set Default To "C:\Work\LM5\AppData"
    	
    	Field cParent, cFilename
    	
    	Set Exclusive Off
    		
    	If !USED("WA1")
    		Select 0
    		Use  "wwBusinessObjects" Alias "WA1"
    	Endif
    
    	Select WA1
    	
    	Scan For Deleted() and !Empty(cFilename)
    	   ? cFilename
    	Endscan
    	
    
    End Function


    Screenshot:

    Attachments:

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

    Last edit: by FoxProMatt.

    Record order incorrect using Scan on a DBF with no Index/Order... 29 Jul 2020 20:12 #15360

  • Chris's Avatar

  • Chris


  • Posts: 2039
  • Hi Matt,

    Thanks, so apparently VFP does not automatically open index files, as VO does, we need to change that. For now, you can instruct X# to not automatically open them, by adding this in the beginning of your code:

    RddInfo(_SET_AUTOOPEN ,FALSE)
    XSharp Development Team
    chris(at)xsharp.eu

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

    Record order incorrect using Scan on a DBF with no Index/Order... 29 Jul 2020 20:16 #15361

  • FoxProMatt's Avatar

  • FoxProMatt

  • Topic Author


  • Posts: 400
  • So besides just *opening* the CDX, does it by default also begin using the first index tag or something??

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

    Record order incorrect using Scan on a DBF with no Index/Order... 29 Jul 2020 20:26 #15362

  • Chris's Avatar

  • Chris


  • Posts: 2039
  • Yes!
    XSharp Development Team
    chris(at)xsharp.eu

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

    Record order incorrect using Scan on a DBF with no Index/Order... 29 Jul 2020 20:27 #15363

  • FoxProMatt's Avatar

  • FoxProMatt

  • Topic Author


  • Posts: 400
  • Chris - why does this code have to go "...in the beginning of your code" ??

    Indeed, I found that it has to be pretty early in the Start() function, before my test method is called, and that if I try to place that code within my test function, it has no affect.

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

    Last edit: by FoxProMatt.

    Record order incorrect using Scan on a DBF with no Index/Order... 29 Jul 2020 20:32 #15364

  • Chris's Avatar

  • Chris


  • Posts: 2039
  • Hi Matt,

    It just has to be called before you open the dbf, because if you open it, by default the RDD automatically opens the index file as well. Unless you tell it not to, with the said function call.
    XSharp Development Team
    chris(at)xsharp.eu

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

    Record order incorrect using Scan on a DBF with no Index/Order... 30 Jul 2020 00:02 #15372

  • Karl-Heinz's Avatar

  • Karl-Heinz


  • Posts: 585
  • Chris wrote: Hi Matt,

    Thanks, so apparently VFP does not automatically open index files, as VO does, we need to change that. For now, you can instruct X# to not automatically open them, by adding this in the beginning of your code:

    RddInfo(_SET_AUTOOPEN ,FALSE)


    Hi Chris,

    My FP does auto open a structural CDX. My FP even complains when i open a DBF and such a created CDX is not available, saying that the strutural flag will be removed. My FP is too old, so i can´t test Matts wwBusinessObjects.dbf

    it seems the strutural flag has been removed from Matts wwBusinessObjects.dbf. That would explain why VFP does not auto open the wwBusinessObjects.cdx, while X# ignores the missing flag and auto opens the wwBusinessObjects.cdx ?

    regards
    Karl-Heinz

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

    Record order incorrect using Scan on a DBF with no Index/Order... 30 Jul 2020 07:01 #15376

  • FoxProMatt's Avatar

  • FoxProMatt

  • Topic Author


  • Posts: 400
  • It seems the structural flag has been removed from Matts wwBusinessObjects.dbf.


    Well, if something is missing, it was not intentional on my part to remove it. Years ago when I created that DBF I simply used the VFP IDE to create the table structure and the 3 indexes that are in the CDX. I have not tinkered with it beyond that.

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

    Record order incorrect using Scan on a DBF with no Index/Order... 30 Jul 2020 10:22 #15383

  • robert's Avatar

  • robert


  • Posts: 1793
  • Matt,

    I think you should not use
    RddInfo(_SET_AUTOOPEN ,FALSE)

    but

    RddInfo(_SET_AUTOORDER ,0)

    This tells the runtime to open the production index but not select the first tag in the index.

    Robert
    XSharp Development Team
    The Netherlands

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

    Record order incorrect using Scan on a DBF with no Index/Order... 30 Jul 2020 15:49 #15393

  • FoxProMatt's Avatar

  • FoxProMatt

  • Topic Author


  • Posts: 400
  • Understand, but, consider making this the default behavior in FoxPro dialect, because that existing programs don’t want an order set it and we shouldn’t have to add new code to our old programs to achieve that.

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

    Record order incorrect using Scan on a DBF with no Index/Order... 30 Jul 2020 16:42 #15394

  • robert's Avatar

  • robert


  • Posts: 1793
  • Matt,
    I checked this with FoxPro and you are right (of course).
    I will add that. Should not be too difficult.
    Robert
    XSharp Development Team
    The Netherlands

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

    • Page:
    • 1