xsharp.eu • AppendDelimited
Page 1 of 1

AppendDelimited

Posted: Fri Jul 19, 2019 9:58 pm
by boonnam
I see there was a question regarding AppendDelimited under XSharp over a year ago. The thread is https://www.xsharp.eu/forum/public-prod ... mited#3554.

I got my code to compile, but my dbf is empty. Here is my code:

Code: Select all

METHOD CreateTempTable2(cImportFile)
	LOCAL aNew			AS ARRAY
	LOCAL oNetTemp 		AS DBServer

	aNew := {}
	
	IF !File(SELF:cTempTable)
		AAdd( aNew, { "MPOLICY", "C", 12, 0, "MPOLICY" } )
		AAdd( aNew, { "MCLAIM", "C", 15, 0, "MCLAIM" } )
		AAdd( aNew, { "MSVCPHASE", "C", 5, 0, "MSVCPHASE" } )
		AAdd( aNew, { "MTYPE", "C", 5, 0, "MTYPE" } )
		AAdd( aNew, { "MDATE", "C", 15, 0, "MDATE" } )
		AAdd( aNew, { "MTIME", "C", 3, 0, "MTIME" } )
		AAdd( aNew, { "MUSERID", "C", 25, 0, "MUSERID" } )
		AAdd( aNew, { "MMEMO", "C", 100, 0, "MMEMO" } )
		AAdd( aNew, { "MAPPLIED", "C", 1, 0, "MAPPLIED" } )

        if !DBCREATE(self:cTempTable, aNew, "DBFNTX")
            MessageBox:Show("Unable to create temporary table for import", "Error", MessageBoxButtons:OK)
            return false
        endif
	ENDIF
	
	oNetTemp := DBServer{SELF:cTempTable}
	oNetTemp:Zap()

	oNetTemp:AppendDelimited(cImportFile, "',")	

	oNetTemp:Close()
	oNetTemp := NULL_OBJECT
				
	RETURN TRUE
This code run and create the dbf, but the appenddelimited method isn't putting any data in the table. My reference has System, VORDDClasses, VOSystemClasses, XSharp.Core, XSharp.RT. I am using the latest release (Bandol RC3). Is AppendDelimited still not implemented for XSharp?

Thanks,

Boonnam

AppendDelimited

Posted: Sat Jul 20, 2019 6:29 am
by Jamal
I don't have RC3, but AFAIK, the delimiter should be one character. You have two characters ', in:

Code: Select all

oNetTemp:AppendDelimited(cImportFile, "',")	
It should be:

Code: Select all

oNetTemp:AppendDelimited(cImportFile, ",")	
That's most likely the issue.

Jamal

AppendDelimited

Posted: Sat Jul 20, 2019 7:50 am
by robert
Boonnam,

I am sorry but the Delim and SDF RDD are still missing. I had totally forgotten about these.
I think they were also missing from Vulcan ?

The problem with the Delim RDD is that there are very many delimited file formats available. We can emulate the old Clipper/VO delim RDD but that will most likely not be able to import real CSV or Tab delimited files.
Will put this on the todo list.
So what should the Delim RDD support ?

Robert

AppendDelimited

Posted: Mon Jul 22, 2019 11:58 am
by Sherlock
snip[ So what should the Delim RDD support ? ]

oServer:Appenddelimited( cTestfile | oFSinfile ) // ----- Comma delimited or fixed length
oServer:Appenddelimited( cTestfile | oFSinfile, "/" ) // backslash
oServer:Appenddelimited( cTestfile | oFSinfile, CR ) // ----- _CHR(13)

Looking at some of old code COMMA, BACKSLASH, CR.. not sure if TAB

But should let you know what I found common..

Phil

AppendDelimited

Posted: Mon Jul 22, 2019 1:02 pm
by FFF
Better, make it configurable, as most Importroutines do: "AppendDelim(oFile, iHeaderlines,cFieldsep, cTextmarker, cLineEnd)

Karl

AppendDelimited

Posted: Mon Jul 22, 2019 1:15 pm
by Sherlock
Karl / Robert

Maybe you have Clipper/Vo syntax with is path+FILE or FILESPEC and default COMMA been working that way for 20+ years.. if nothing passed beyond oFiles comma separated work fine with appendDelitmited( File )

Why not as Karl says where a big more programmable use say Syntax ;
AppendDeliim( oFile, Headerline, cFieldSpec, cTextMarker, CLineend )

Obviously there is a backward compattibility and say power users.
I mainly use it Bankfiles that fall into 3 or 4 deiimiter categories.. and older concept works fine.
Design a databases with fixed field lengths and AppendDelimited*( oFile ) to it.
Simple and works.. Imagine if only extra parameters, unknown breaks old code.