xsharp.eu • USE not looking in the right spot
Page 1 of 1

USE not looking in the right spot

Posted: Fri Aug 07, 2020 11:33 pm
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

USE not looking in the right spot

Posted: Sat Aug 08, 2020 7:16 am
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?

USE not looking in the right spot

Posted: Sat Aug 08, 2020 6:31 pm
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?

USE not looking in the right spot

Posted: Sat Aug 08, 2020 9:54 pm
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!

USE not looking in the right spot

Posted: Sat Aug 08, 2020 10:07 pm
by Eric Selje
Just checked. VFP throws an error if you try to SET DEFAULT TO a nonexistent folder.