Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
COPY TO command
Message
From
18/02/1998 02:43:17
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00079469
Message ID:
00079489
Views:
41
>I am using the "COPY TO TYPE DELIMITED" command to created a comma separated text file for importing into another program. Some of my fields are numeric and are empty OR null in the originating table. They are converted to ZERO in the comma deilimited file. I need them to be nothing, no character, just a place holder. I do not want to bring in the zero value into the new program. In other words I need the file to look like this:
>
>"Good Retest 1 Year",,,,,,,,
>
>not like this:
>
>"Good Retest 1 Year",0,0,0,0,0,0,0,0
>
>However, when there is a zero in the originating field, I do want that one to be there.
>
>I've racked my brain on this one. Help is very much appreciated.
>
>Elgin Rogers
>Epic Solutions
Hi Elgin,
Then I'm afraid you should have your own dumper.prg.
function nullcopy
lparameters cDataFile, cOutput
set century on
set date to dmy
use (cDataFile)
handle=fcreate(cOutPut)
nFields = fcount()
=afields(aStruc)
scan
	cRecord = ""
	for ix = 1 to nFields
		do case
			case type(field(ix)) $ "C"
				cDumpVal = iif(isnull(eval(field(ix))),"",'"'+eval(field(ix))+'"')
			case type(field(ix)) $ "NY"
				cDumpVal = iif(isnull(eval(field(ix))),"",str(eval(field(ix)),aStruc[ix,3],aStruc[ix,4]))
			case type(field(ix)) $ "L"
				cDumpVal = iif(isnull(eval(field(ix))),"",iif(eval(field(ix)),".T.",".F."))
			case type(field(ix)) $ "DT"
				cDumpVal = iif(isnull(eval(field(ix))),"",dtoc(eval(field(ix))))
			otherwise
				loop
		endcase
		cRecord = cRecord + iif(empty(cRecord),"",",")+cDumpVal
	endfor
	=fputs(handle,cRecord)
endscan
=fclose(handle)
use in (cDataFile)
PS:You could trim() the cDumpVal.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform