Alaska Software Inc. - Re: See numeric values of DELDBE like they are character type.
Username: Password:
AuthorTopic: Re: See numeric values of DELDBE like they are character type.
Andreas Gehrs-Pahl

View the complete thread for this message in:

Re: See numeric values of DELDBE like they are character type.
on Tue, 29 Nov 2016 05:53:25 -0500
César,

>How could I get for see the content of the FIELD2 of the SLIST.csv?
>I mean that when I open the file, the value of second field is considered 
>numeric but I should want it must be character type.

The following program will show you how to do this:

#include "DelDbe.ch"

Procedure Main()
LOCAL cColumns := "CCNDL" + Replicate("C", 21)
LOCAL nField   := 0
   DbeInfo(COMPONENT_DATA, DELDBE_FIELD_TYPES,  cColumns)
   USE "SLIST.csv" VIA "DELDBE" ALIAS TMP
   for nField := 1 to FCount()
      ? nField, ValType(FieldGet(nField)), FieldGet(nField)
   next nField
return

Procedure DbeSys()
   DbeLoad("DELDBE", .f.)
   DbeSetDefault("DELDBE")
   DbeInfo(COMPONENT_DATA, DELDBE_MODE,         DELDBE_AUTOFIELD)
   DbeInfo(COMPONENT_DATA, DELDBE_FIELD_TOKEN,  ";")
   DbeInfo(COMPONENT_DATA, DELDBE_RECORD_TOKEN, ";" + chr(13) + chr(10))
return

Assuming that you want all 26 fields to be treated as character fields, use 
the following:

cColumns := Replicate("C", 26)
DbeInfo(COMPONENT_DATA, DELDBE_FIELD_TYPES, cColumns)

If you use DELDBE_AUTOFIELD, you can specify "C", "D", "L", or "N", for each 
of the columns, and you must set a value for each column. So if the third 
column should be treated as a Number, the fourth as a Date, the fifth as a 
Logical value and all others as Character strings, you would use this:

cColumns := "CCNDL" + Replicate("C", 21)
DbeInfo(COMPONENT_DATA, DELDBE_FIELD_TYPES, cColumns)

You must set the DELDBE_FIELD_TYPES setting before opening the database. To 
reset the value, and have the DBE select the value based on the first row, 
use an empty string:

DbeInfo(COMPONENT_DATA, DELDBE_FIELD_TYPES, "")

Finally, using the following line makes no sense at all, as this is a 
Read-Only value, which will always return "CDLN" and can't be set or 
changed:

DbeInfo(COMPONENT_DATA, DBE_DATATYPES, "C")

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