AppendDelimited

This forum is meant for questions and discussions about the X# language and tools
Post Reply
boonnam
Posts: 88
Joined: Mon May 08, 2017 6:42 pm
Location: USA

AppendDelimited

Post 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
Jamal
Posts: 314
Joined: Mon Jul 03, 2017 7:02 pm

AppendDelimited

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

AppendDelimited

Post 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
XSharp Development Team
The Netherlands
robert@xsharp.eu
Sherlock
Posts: 60
Joined: Mon Sep 28, 2015 1:37 pm
Location: Australia mate... fare dikkum

AppendDelimited

Post 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
Phil McGuinness
FFF
Posts: 1521
Joined: Fri Sep 25, 2015 4:52 pm
Location: Germany

AppendDelimited

Post by FFF »

Better, make it configurable, as most Importroutines do: "AppendDelim(oFile, iHeaderlines,cFieldsep, cTextmarker, cLineEnd)

Karl
Regards
Karl
(on Win8.1/64, Xide32 2.19, X#2.19.0.2.)
Sherlock
Posts: 60
Joined: Mon Sep 28, 2015 1:37 pm
Location: Australia mate... fare dikkum

AppendDelimited

Post 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.
Phil McGuinness
Post Reply