USE not looking in the right spot

This forum is meant for questions about the Visual FoxPro Language support in X#.

Post Reply
User avatar
Eric Selje
Posts: 31
Joined: Sun Sep 22, 2019 3:16 pm

USE not looking in the right spot

Post by Eric Selje »

Here's some weirdness that I can't figure out. Simple function just to open the C:DEV|XSHARPTODOSTODOS.DBF

Code: Select all

PUBLIC FUNCTION openToDos() AS Boolean
        SET DEFAULT TO "C:DEVXSHARPTODOS"
        SELECT 0
	USE "TODOS" ALIAS "ToDos"
	RETURN USED("TODOS")
END FUNCTION
I put a breakpoint after the SET DEFAULT and get this in my Command window:

Code: Select all

>? GetDefault()
"C:DEVXSHARPTODOS"
But when I hit the USE... line I get

XSharp.RDD.RddError: 'Could not find file 'C:Program Files (x86)Microsoft Visual Studio2017ProfessionalCommon7IDETODOS.DBF'.'

Why is it looking there when I just confirmed that the default was C:DEVXSharpToDos?

Thanks,

Eric
User avatar
Chris
Posts: 4978
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

USE not looking in the right spot

Post by Chris »

Hi Eric,

That should work, I checked here with a similar path and it worked fine. Could it be there's a typo in one of the filenames/folders? Or the dbf file not actually being there? Maybe something else goes wrong and the error message is a read herring, what happens if you try to open another dbf from the same folder, same error?

Btw, the dialect for the project is set to FoxPro, correct?
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
User avatar
Eric Selje
Posts: 31
Joined: Sun Sep 22, 2019 3:16 pm

USE not looking in the right spot

Post by Eric Selje »

Aha! The real problem is that SET DEFAULT TO doesn't validate that the folder name you send in is actually a folder name. In my example the actual folder is C:DevXSharpToDo, not XSharpToDos. GetDefault() returned whatever I sent in. I'd expect it to return either an error or throw an exception. Is this something I should file a bug report for? Download the source, fix, and submit a Pull Request?
User avatar
Chris
Posts: 4978
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

USE not looking in the right spot

Post by Chris »

Hi Eric,

Yeah, that would be very nice! That is of course if indeed also VFP behaves like that when you use a non existing folder!
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
User avatar
Eric Selje
Posts: 31
Joined: Sun Sep 22, 2019 3:16 pm

USE not looking in the right spot

Post by Eric Selje »

Just checked. VFP throws an error if you try to SET DEFAULT TO a nonexistent folder.
Post Reply