Author | Topic: See numeric values of DELDBE like they are character type. | |
---|---|---|
César Calvo | See numeric values of DELDBE like they are character type. on Sat, 26 Nov 2016 21:33:42 +0100 Hello. 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. I suppose changing something in Dbeinfo but I don´t know what. Regards. PROCEDURE PRUEBA LOCAL cDir, cFil, oDat, oTMP1, cDat, aStr LOCAL oSLI, cCon1, oCon1, oCur1, cSQL1, B LOCAL oExcel, oBook, oSheet MenuSelect(ID_MNU_ESPERAR,SDI_VIEW_ESPERAR) DbeSetDefault("DELDBE") //DbeInfo( COMPONENT_DATA, DELDBE_MODE, DELDBE_MULTIFIELD ) DbeInfo( COMPONENT_DATA, DELDBE_FIELD_TOKEN, ";" ) //DbeInfo( COMPONENT_DATA, DELDBE_FIELD_TYPES, "C" ) //DbeInfo( COMPONENT_DATA, DELDBE_DECIMAL_TOKEN, Chr(0) ) //DbeInfo( COMPONENT_DATA, DELDBE_DELIMITER_TOKEN, Chr(0) ) //DbeInfo( COMPONENT_DATA, DELDBE_RECORD_TOKEN, ";" + CHR(13)+CHR(10) ) //DbeInfo( COMPONENT_DATA, DBE_DATATYPES, "C" ) cFil := cDir + "SLIST.csv" USE (cFil) VIA "DELDBE" ALIAS TMP MsgBox(TMP->FIELD2) CLOSE TMP RETURN SLIST.csv | |
Andreas Gehrs-Pahl | 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 | |
César Calvo | Re: See numeric values of DELDBE like they are character type. on Tue, 29 Nov 2016 20:53:43 +0100 Thans Andreas but is very simple. This is the solution: if I want that all fields been type Character, a letter C with all fields there is. DbeInfo( COMPONENT_DATA, DELDBE_FIELD_TYPES, "CCCCCCCCCCCCCCCCCCCCCCCCCC" ) Regards. César. "Andreas Gehrs-Pahl" escribió en el mensaje de noticias:rycunx1cmach$.pwazi1k9wn4r.dlg@40tude.net... 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 |