FoxPro table didn't open in X# FoxPro Console

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

User avatar
cecilchamp
Posts: 49
Joined: Wed Jun 12, 2019 1:44 pm

FoxPro table didn't open in X# FoxPro Console

Post 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.
FoxProMatt

FoxPro table didn't open in X# Foxo Console

Post 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.
User avatar
cecilchamp
Posts: 49
Joined: Wed Jun 12, 2019 1:44 pm

FoxPro table didn't open in X# FoxPro Console

Post 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	
User avatar
Chris
Posts: 4562
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

FoxPro table didn't open in X# Foxo Console

Post 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.
Chris Pyrgas

XSharp Development Team test
chris(at)xsharp.eu
FoxProMatt

FoxPro table didn't open in X# Foxo Console

Post by FoxProMatt »

Use

Code: Select all

FIELD LastName

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.
User avatar
Chris
Posts: 4562
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

FoxPro table didn't open in X# Foxo Console

Post by Chris »

Hi Matt,
FoxProMatt_MattSlay wrote:Use

Code: Select all

FIELD LastName

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.
Chris Pyrgas

XSharp Development Team test
chris(at)xsharp.eu
FoxProMatt

FoxPro table didn't open in X# Foxo Console

Post by FoxProMatt »

BTW Cecil - I’m pretty sure SCAN/ENDSCAN works also.
User avatar
cecilchamp
Posts: 49
Joined: Wed Jun 12, 2019 1:44 pm

FoxPro table didn't open in X# FoxPro Console

Post by cecilchamp »

Thanks for the explanations, Chris. It helps to know what is going on under the hood and where to look.
User avatar
cecilchamp
Posts: 49
Joined: Wed Jun 12, 2019 1:44 pm

FoxPro table didn't open in X# FoxPro Console

Post 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.
User avatar
cecilchamp
Posts: 49
Joined: Wed Jun 12, 2019 1:44 pm

FoxPro table didn't open in X# Foxo Console

Post 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	
Post Reply