Page 1 of 6
FoxPro table didn't open in X# FoxPro Console
Posted: Sat Nov 23, 2019 9:34 pm
by cecilchamp
FUNCTION Start() AS VOID STRICT
set default to C:addrdata
use address order lfname
locate for lastname = 'FORD'
Browse
RETURN
X# didn't know what to do with the set default command. Then it didn't know how to open a table with the USE command. Anyone want to point out what I may have missed? I even added the table to the project.
FoxPro table didn't open in X# Foxo Console
Posted: Sat Nov 23, 2019 10:32 pm
by FoxProMatt
Maybe try this, for now:
Code: Select all
Select 0
Use “C:addrdataaddress.dbf” Order “lfname”
Maybe wrapping those things in quotes will help at work. For now, many things are requiring some tweaks or adjustments but the X# team will be able to clean everything up.
Plus, when you are posting code samples, it’s easier to read if you will use the toolbar to mark up the text as code so it stands out differently from your message text.
FoxPro table didn't open in X# FoxPro Console
Posted: Sat Nov 23, 2019 10:42 pm
by cecilchamp
Thanks. I wasn't aware of that CODE tool button. Even the below failed, says "
lastname has not been declared". LastName is a field. Do I need to declare a field?
Code: Select all
FUNCTION Start() AS VOID STRICT
local i as int
Select 0
use address
for i = 1 to 3
? LastName
ENDFOR
RETURN
FoxPro table didn't open in X# Foxo Console
Posted: Sat Nov 23, 2019 11:41 pm
by Chris
Please check the file dbcmd.xh located in the <XSharp>Include folder, this contains the dbf-related commands that have been implemented so far. You will see an entry for "USE" which is implemented, but it does not support yet the "ORDER" clause, this is marked as "todo" in a few lines below, so it will be added in the (near) future.Same goes for SET DEFAULT TO, it's not implemented either yet. But for example this already works:
USE address INDEX indexfile
and also your LOCATE command works as well.
To explain a bit more how this works, the DBF and other runtime functionality has been already implemented inside functions and classes defined inside the X# runtime dlls and are ready to use, also from VFP programs. For VO programmers this is already absolutely enough, because almost all VO programs have been using procedural/object oriented approach to using dbf files and everything else.
But VFP (and other xBase dialects) programmers are used to using commands instead, so what we are doing in X# is to create preprocessor #command directives which translate commands like USE and SET DEFAULT to function calls that are being used under the hood. So a lot of the functionality is already implemented (including support for the more "exotic" data types that VFP supports in dbfs), it's just a matter of exposing it also via preprocessor commands, which is the easier part.
That's for the part of the runtime that has been already implemented, being part also of the necessary support for VO (and other dialects in part) that we already fully support. For FoxPro there's a lot of extra things we will need to implement in the runtime, and one of those things is the BROWSE command that you mentioned, we will need to implement this functionality. That's what we will be working on in the coming months.
FoxPro table didn't open in X# Foxo Console
Posted: Sat Nov 23, 2019 11:44 pm
by FoxProMatt
Use
Just like you do for LOCAL
This is because the X# compiler requires everything referred to in your code to be identified.
You can turn this off with a compiler option if you want to use non-declared variables.
FoxPro table didn't open in X# Foxo Console
Posted: Sat Nov 23, 2019 11:50 pm
by Chris
Hi Matt,
FoxProMatt_MattSlay wrote:Use
Just like you do for LOCAL
This is because the X# compiler requires everything referred to in your code to be identified.
You can turn this off with a compiler option if you want to use non-declared variables.
You just need to enable the options "Enable Memvar Support" and "Enable Undeclared variables support" (in the Language page of the Project options) and then the compiler will allow using it also undeclared. It will still report a warning though, just in case you did that accidentally in code, so make sure you do not have "warnings as errors" also enabled, because this will turn the warning into an error.
FoxPro table didn't open in X# Foxo Console
Posted: Sun Nov 24, 2019 12:00 am
by FoxProMatt
BTW Cecil - I’m pretty sure SCAN/ENDSCAN works also.
FoxPro table didn't open in X# FoxPro Console
Posted: Sun Nov 24, 2019 1:20 am
by cecilchamp
Thanks for the explanations, Chris. It helps to know what is going on under the hood and where to look.
FoxPro table didn't open in X# FoxPro Console
Posted: Sun Nov 24, 2019 1:21 am
by cecilchamp
Yep, I saw SCAN/ENDSCAN in one of the demo videos. I just didn't want to display over 5,000 records on screen.
FoxPro table didn't open in X# Foxo Console
Posted: Sun Nov 24, 2019 1:24 am
by cecilchamp
Well, I am still getting an exception error on the USE command. I added Field LastName which took care of that one issue.
Code: Select all
FUNCTION Start() AS VOID STRICT
local i as int
Field LastName
Select 0
use address Index lfname
for i = 1 to 3
? LastName
ENDFOR
RETURN