Alaska Software Inc. - Re: DbInfo() return value complementation
Username: Password:
AuthorTopic: Re: DbInfo() return value complementation
Andreas Gehrs-Pahl

View the complete thread for this message in:

Re: DbInfo() return value complementation
on Sat, 26 Nov 2016 13:13:53 -0500
Carlos,

>I made a correction in the TestInfo.prg (attached) and it is working fine.

As Jim already mentioned, you didn't attach any updated program.

>Here is what I read in the documentation of DBFDBE (DATA component):
>a) it defines that the DBInfo() returns the settings of the DbfDbe that 
>opened the current work area

That is (partially) correct, but your (original) program doesn't load the 
DBFDBE and doesn't open any files with it, so you can't use any DBFDBE-
specific DBFDBO_* define constants, only generic DBO_* and FOXDBE-specific 
FOXDBO_* define constants.

>b) it defines too that DbInfo() must to use #defines begin with DBFDBO_

That is incorrect. The DbInfo() function can use generic define constants 
that begin with DBO_ (as can be found in the "dmlb.ch" header file), as well 
as DBE-specific define constants, starting with ADSDBO_, DBFDBO_, FOXDBO_, 
etc. (as can be found in the corresponding "*dbe.ch" files).

In file "dbfdbe.ch", you can find:
#define DBFDBO_ANSI            DBE_USER+7

In file "foxdbe.ch", you can find:
#define FOXDBO_CODEPAGE        DBE_USER+7

So, if you open a database with the FOXDBE (as you do in your program) and 
then use the DBFDBO_ANSI define constant with DbInfo() on that database, you 
are actually using the FOXDBO_CODEPAGE define constant!

>c) it informs that the return value of DbInfo(DBFDBO_ANSI) is .T. or .F. 

This is also correct, but as you are using the FOXDBE, the DBFDBO_ANSI isn't 
appropriate, and what you actually use is the FOXDBO_CODEPAGE constant. And 
the return value for the FOXDBO_CODEPAGE constant is a numerical value that 
indicates the Code Page, as the name of the define constant implies.

>Here is my problem:
>b) when debuging TestInfo.prg the result of DbInfo(DBFDBO_ANSI) is the 
>number 1252, disaccording to the documentation

Actually, this is exactly as documented. The return value for DbInfo(1007) 
in a workarea with a database that was opened with the FOXDBE is a numerical 
Code Page value, which in your case is 1252.

>c) opening another old DOS database DbInfo(DBFDBO_ANSI) returns 0

If you open a non-VFP database with the FOXDBE, the DBE won't be able to 
determine the Code Page, as it isn't saved in non-VFP database headers, so 
it will always return 0 (Zero).

>d) please, how is the correct way for to know the result of 
>f0002->DbInfo(DBFDBO_ANSI)?

The only way to get a "correct" result is to open the database with the 
DBFDBE instead of the FOXDBE. But as this is a VFP database, you probably 
should open it with the FOXDBE, as you do.

The FOXDBE doesn't have an OEM/ANSI setting, but you can use the Code Page 
setting (FOXDBO_CODEPAGE) to determine the ANSI/OEM setting indirectly. If 
the used Code Page is reported as 437 -- the IBM PC OEM Code Page -- then 
the OEM character set is used. If the reported Code Page is between 1250 
and 1258, then the Windows ANSI character set is used.

There are also several other OEM and ANSI code page values possible, most 
of which are listed here: https://en.wikipedia.org/wiki/Code_page

Hope that helps,

Andreas

Andreas Gehrs-Pahl
Absolute Software, LLC

phone: (989) 723-9927
email: Andreas@AbsoluteSoftwareLLC.com
web:   http://www.AbsoluteSoftwareLLC.com
[F]:   https://www.facebook.com/AbsoluteSoftwareLLC