FoxPro table didn't open in X# FoxPro Console

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

FoxProMatt

FoxPro table didn't open in X# FoxPro Console

Post by FoxProMatt »

Okay, they can test your sample.

In the mean time, for further progress, use a DBF with no index file.
FFF
Posts: 1580
Joined: Fri Sep 25, 2015 4:52 pm
Location: Germany

FoxPro table didn't open in X# FoxPro Console

Post by FFF »

Cecil,
* started VS17 community,
* selected FoxPro Console app,
* run, it showed the Hello World.

* Replaced in Start the default code with "your" code
* replaced your path with mine
* replaced your dbf, index and field name with mine from a simple dbf/cdx (no memo)
ADDED "wait" at the end of the code before the return
CTRL-F5 - showed 3 lines with my field contents.

As you post in "public" could it be you are not in FOX? I use the actual 2.08. build, but this should be ident to the current public one. Running at W8.1/64, didn't change or edit anything in VS.
Regards
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
User avatar
Chris
Posts: 4909
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

FoxPro table didn't open in X# FoxPro Console

Post by Chris »

Hi Cecil,
cecilchamp wrote:Okay, now I am starting to get somewhere, sort of.

Found the Language properties under the application. These were set already to the below values. Still have an issue with the USE command.

Memory Variables
Enable Memvar Support - TRUE
Enable Undeclared Variables support - TRUE

I will do the other things you mentioned with SET DEFAULT. Still need to determine why USE won't open the table.
Thanks Chris!

My entire code follows:

Code: Select all

USING System
USING System.Collections.Generic
USING System.Linq
USING System.Text

#command SET DEFAULT TO <path> => SetDefault(<path>)
#command USE <(db)>                                                     ;
             [VIA <rdd>]                                                ;
             [ALIAS <a>]                                                ;
             [<new: NEW>]                                               ;
             [<ex: EXCLUSIVE>]                                          ;
             [<sh: SHARED>]                                             ;
             [<ro: READONLY,NOUPDATE>]                                  ;
             [INDEX <(index1)> [, <(indexn)>]]                          ;
                                                                        ;
      => dbUseArea(                                                     ;
                    <.new.>, <rdd>, <(db)>, <(a)>,                      ;
                    if(<.sh.> .or. <.ex.>, !<.ex.>, NIL), <.ro.>        ;
                  )                                                     ;
                                                                        ;
      [; dbSetIndex( <(index1)> )]                                      ;

FUNCTION Start() AS VOID STRICT
    LOCAL i AS INT
    Field LastName
    
    SET DEFAULT TO "C:addrdata"
        
    SELECT 0
    USE address Index lfname
    FOR i = 1 to 3
        ? LastName    
    ENDFOR
	RETURN	
I tried your code "as is" (only changed the path and dbf filename) and it worked in the first go! I also removed the FIELD declaration and it still works fine. (although I am running a newer, yet unreleased, version of X#, which might be making the difference).

What error are you getting? Do you get an error when building/compiling? Or is there an error when you run the test app? Could you please zip and send the complete solution folder so we can have a look? Maybe there's some other setting in the project that gets in the way...
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
User avatar
Chris
Posts: 4909
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

FoxPro table didn't open in X# FoxPro Console

Post by Chris »

Oh, ignore the above, I had not seen the posts of the previous minutes, as I was typing mine :)
Indeed, as the guys say it has probably to do with the dbf file or the index file itself, something that x# is not handling. Can you please post those two files? You can delete the data and leave only a couple dummy records in it. If you prefer, you can also send them directly to me or to Robert.
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
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 »

I will do a COPY STRUCTURE WITH CDX and send that. I will also send the NAMES table I just created a few minutes ago which has no indexes. I suppose I can just use the Attachments button below? Give me a couple minutes.
Attachments
Names.zip
(255 Bytes) Downloaded 81 times
Address.zip
(1.71 KiB) Downloaded 86 times
Karl-Heinz
Posts: 774
Joined: Wed May 17, 2017 8:50 am
Location: Germany

FoxPro table didn't open in X# FoxPro Console

Post by Karl-Heinz »

cecilchamp wrote:Karl, did you mean for me to use that as a Function in the program? If yes, I got nothing back. Otherwise, I am not sure how to check which driver is being used.

Application under Properties shows:
Dialect - FoxPro
Output Type - Console Application
Hi Cecil,

can´t believe that RddSetDefault() always returns an empty string ??? This function is used to set or retrieve the required DBF driver.. If you want to open VFP -DBFs with specific VFP - fields the default driver must be "DBFVFP" !

regards
Karl-Heinz
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 »

Okay, so what I meant when I used RddSetDefault() was that I used it as follows in the XSharp FoxPro console app:
?RddSetDefault() then hit enter. I thought that would tell me which driver was being used. I will try again now that the program is working.

Later,...

It returned 'DBFVFP'.
Attachments
X# RddSetDefault 2019-11-24_8-05-21.jpg
X# RddSetDefault 2019-11-24_8-05-21.jpg (19.44 KiB) Viewed 539 times
Karl-Heinz
Posts: 774
Joined: Wed May 17, 2017 8:50 am
Location: Germany

FoxPro table didn't open in X# FoxPro Console

Post by Karl-Heinz »

ok,

i deleted my answer, because Cecil got RddSetDefault() running in the meantime..

regards
Karl-Heinz
User avatar
robert
Posts: 4520
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

FoxPro table didn't open in X# FoxPro Console

Post by robert »

Karl Heinz,

When you include a reference to the XSharp.VFP assembly we are setting the default driver to DBFVFP and not DBFNTX.

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
User avatar
robert
Posts: 4520
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

FoxPro table didn't open in X# FoxPro Console

Post by robert »

Cecil,
If you change the UDC for SET DEFAULT to

#command SET DEFAULT TO <(path)> => SetDefault(<(path)>)

Then you can use the following code without the string delimiters around the path

SET DEFAULT TO C:addrdata

Just like the filename in the USE command.

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
Post Reply