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
robert
Posts: 4518
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

FoxPro table didn't open in X# FoxPro Console

Post by robert »

Cecil,

X# has a problem with the indexes in your example because they contain an expression such as "UPPER(ALLTRIM(contact))"
When X# opens the index file it evaluates the index expressions and tries to calculate the length of the index key. An index expression that contains ALLTRIM() will return a length of 0 with evaluated for a record that has an empty contact name.

In most XBase dialects this is not allowed. We would always add a PADR() or something like that to make sure that the index expression has a fixed length.

I am really surprised that FoxPro allows this. I will research how FoxPro determines the correct length of this expression

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
User avatar
Chris
Posts: 4898
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

FoxPro table didn't open in X# FoxPro Console

Post by Chris »

Robert,
robert wrote: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
Unfortunately this doesn't work, compiler reports a parser error when using it. I will log this.
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 reindex that field, CONTACT without ALLTRIM().

I created this table a long time ago and still used it but never paid attention to the indexes. I removed ALLTRIM from other index expressions also.

So, I put my ADDRESS table back with the USE command in the code and the CDX file seems to still be an issue after I removed the ALLTRIM() function. Is it having a problem with the UPPER() function still in the index expressions?

XSharp.RDD.RddError
HResult=0x80131500
Message=Exception of type 'XSharp.RDD.RddError' was thrown.
Source=XSharp.RT
StackTrace:
at XSharp.RDD.DBF._dbfError(Exception ex, UInt32 iSubCode, UInt32 iGenCode, String strFunction, String strMessage, UInt32 iSeverity)
at XSharp.RDD.CDX.CdxTag.EvaluateExpressions()
at XSharp.RDD.CDX.CdxTag.Open()
at XSharp.RDD.CDX.CdxTag..ctor(CdxOrderBag oBag, Int32 nPage, String cName)
at XSharp.RDD.CDX.CdxTagList.ReadTags()
at XSharp.RDD.CDX.CdxOrderBag.Open(DbOrderInfo info)
at XSharp.RDD.CDX.CdxOrderBagList.Add(DbOrderInfo info, Boolean lStructural)
at XSharp.RDD.DBFCDX.Open(DbOpenInfo info)
at XSharp.CoreDb.<>c__DisplayClass111_0.<UseArea>b__0()
at XSharp.CoreDb.Do[T](Func`1 action)
at XSharp.CoreDb.UseArea(Boolean lNew, Type rddType, String cName, String cAlias, Boolean lShare, Boolean lReadOnly)
at XSharp.CoreDb.<>c__DisplayClass109_0.<UseArea>b__0()
at XSharp.CoreDb.Do[T](Func`1 action)
at XSharp.CoreDb.UseArea(Boolean lNew, _RddList rddList, String cName, String cAlias, Boolean lShare, Boolean lReadOnly)
at XSharp.RT.Functions.DbUseArea(__Usual[] Xs$Args)
at ConsoleApplication4.Exe.Functions.Start() in C:UserscecilsourcereposConsoleApplication4Program.prg:line 15

LINE 15 is the USE command. Here's the code:

FUNCTION Start() AS VOID STRICT
LOCAL i AS INT
Field LastName

SET DEFAULT TO "C:addrdata"

SELECT 0
USE Address
SCAN for LastName = "Champenois"
? LastName, FirstName, City, Country
ENDSCAN
WAIT
? RddSetDefault()
WAIT
SELECT Names
USE
RETURN
User avatar
Chris
Posts: 4898
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

FoxPro table didn't open in X# FoxPro Console

Post by Chris »

Hi Cecil,

Can you please post again the new files (.dbf, .cdx and .fpt) that you are testing with now?
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 »

Here is the zipped file.

Oh man, I just spotted one ALLTRIM() remaining. I will remove it. It was in the STATE index.
Attachments
Address.zip
(1.3 KiB) Downloaded 58 times
User avatar
Chris
Posts: 4898
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

FoxPro table didn't open in X# FoxPro Console

Post by Chris »

Thanks! I see there's still an AllTrim(), in the "STATE" order, most likely this causes the problem.
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 removed the ALLTRIM() but the program still errs out.

Here is the error mesasge.

XSharp.RDD.RddError
HResult=0x80131500
Message=Exception of type 'XSharp.RDD.RddError' was thrown.
Source=XSharp.RT
StackTrace:
at XSharp.RDD.DBF._dbfError(Exception ex, UInt32 iSubCode, UInt32 iGenCode, String strFunction, String strMessage, UInt32 iSeverity)
at XSharp.RDD.CDX.CdxTag.EvaluateExpressions()
at XSharp.RDD.CDX.CdxTag.Open()
at XSharp.RDD.CDX.CdxTag..ctor(CdxOrderBag oBag, Int32 nPage, String cName)
at XSharp.RDD.CDX.CdxTagList.ReadTags()
at XSharp.RDD.CDX.CdxOrderBag.Open(DbOrderInfo info)
at XSharp.RDD.CDX.CdxOrderBagList.Add(DbOrderInfo info, Boolean lStructural)
at XSharp.RDD.DBFCDX.Open(DbOpenInfo info)
at XSharp.CoreDb.<>c__DisplayClass111_0.<UseArea>b__0()
at XSharp.CoreDb.Do[T](Func`1 action)
at XSharp.CoreDb.UseArea(Boolean lNew, Type rddType, String cName, String cAlias, Boolean lShare, Boolean lReadOnly)
at XSharp.CoreDb.<>c__DisplayClass109_0.<UseArea>b__0()
at XSharp.CoreDb.Do[T](Func`1 action)
at XSharp.CoreDb.UseArea(Boolean lNew, _RddList rddList, String cName, String cAlias, Boolean lShare, Boolean lReadOnly)
at XSharp.RT.Functions.DbUseArea(__Usual[] Xs$Args)
at ConsoleApplication4.Exe.Functions.Start() in C:UserscecilsourcereposConsoleApplication4Program.prg:line 15
User avatar
Chris
Posts: 4898
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

FoxPro table didn't open in X# FoxPro Console

Post by Chris »

Thanks again, problem seems to be related with the "ID" order, for some reason it does not like using the "ID" field in it. Not sure why, will leave it to Robert to tell use.

Till then, please try removing this order from the .cdx, or change it to somthing different, that does not use the ID field. Does it open correctly now?

Edit: Oh, it must probably be the index length thing again. Try using Pad(ID,10) in the index expression and this should work as well. But I think this is a bug, I am sure even in VO I had many numeric indexes without padding, I assume the length can be obtained from the field width. Will let Robert comment on this though, before logging it as a bug.
Chris Pyrgas

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

robert wrote:Karl Heinz,

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

Robert
Aaaah ! Yes, when i add a XSharp.VFP reference the default setting is no longer "DBFNTX"

When a XSharp.VFP reference is added the dialect default drivers are:

Code: Select all

<VO>		DBFVFP   
<Foxpro>	DBFVFP
<Harbour>	DBFVFP
<xbase++> 	DBFNTX
just wondering why the <xbase++> default setting is still "DBFNTX"?

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 »

I removed the Index for ID and it still has an exception:

XSharp.RDD.RddError
HResult=0x80131500
Message=Exception of type 'XSharp.RDD.RddError' was thrown.
Source=XSharp.RT
StackTrace:
at XSharp.RDD.DBF._dbfError(Exception ex, UInt32 iSubCode, UInt32 iGenCode, String strFunction, String strMessage, UInt32 iSeverity)
at XSharp.RDD.CDX.CdxTag.EvaluateExpressions()
at XSharp.RDD.CDX.CdxTag.Open()
at XSharp.RDD.CDX.CdxTag..ctor(CdxOrderBag oBag, Int32 nPage, String cName)
at XSharp.RDD.CDX.CdxTagList.ReadTags()
at XSharp.RDD.CDX.CdxOrderBag.Open(DbOrderInfo info)
at XSharp.RDD.CDX.CdxOrderBagList.Add(DbOrderInfo info, Boolean lStructural)
at XSharp.RDD.DBFCDX.Open(DbOpenInfo info)
at XSharp.CoreDb.<>c__DisplayClass111_0.<UseArea>b__0()
at XSharp.CoreDb.Do[T](Func`1 action)
at XSharp.CoreDb.UseArea(Boolean lNew, Type rddType, String cName, String cAlias, Boolean lShare, Boolean lReadOnly)
at XSharp.CoreDb.<>c__DisplayClass109_0.<UseArea>b__0()
at XSharp.CoreDb.Do[T](Func`1 action)
at XSharp.CoreDb.UseArea(Boolean lNew, _RddList rddList, String cName, String cAlias, Boolean lShare, Boolean lReadOnly)
at XSharp.RT.Functions.DbUseArea(__Usual[] Xs$Args)
at ConsoleApplication4.Exe.Functions.Start() in C:UserscecilsourcereposConsoleApplication4Program.prg:line 15
Post Reply