Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Creating Comma-Delimited Files without Quotation Marks
Message
From
16/06/2000 10:14:42
 
 
To
15/06/2000 15:30:20
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00380950
Message ID:
00381356
Views:
17
>I have been striving to create a comma-delimited file that does not put double quotes around the text fields from a cursor in FoxPro. I don't want anything that identifies whether the field is character or numeric. I watched someone do it once with the COPY TO command (which is what I intend to use), but I have misplaced my notes of the syntax.


here is one example, field1 and field2 would represent your field names:
var2char() is a function to change the field type to character string

* begin example
SELECT 0
USE myfile
SET PRINTER TO junk.txt
SET DEVICE TO PRINTER
@ 0,0 SAY '' FONT 'courier new',12
DO WHILE ! EOF()
@ PROW()+1,0 SAY var2char(field1)+','+var2char(field2) FONT 'courier new',12
SKIP
ENDDO
SET PRINTER TO
SET DEVICE TO
RETURN
* end of example
************************** function var2chr()
* transform any datatype into character data type
* syntax: Var2Chr(FieldName)
* example: lcString=Var2Chr(Name) &&..returns 'Raezer Rezear'

FUNCTION var2chr
PARAM tcInvar
PRIVATE lnNumString,lcPicString
DO CASE
CASE TYPE(tcInvar)="C"
RETURN &tcInvar
CASE TYPE(tcInvar)="M"
RETURN ''
CASE TYPE(tcInvar)="D"
RETURN DTOC(&tcInvar)
CASE TYPE(tcInvar)="N"
lnNumString = STR(&tcInvar)
IF "." $ lnNumString
lcPicString=REPLICATE("9", AT(".", lnNumString) - 1) + "."
lcPicString=lcPicString + REPLICATE("9", LEN(lnNumString) - LEN(lcPicString))
ELSE
lcPicString=REPLICATE("9", LEN(lnNumString))
ENDIF
RETURN TRAN(&tcInvar,lcPicString)
CASE TYPE(tcInvar)="L"
RETURN IIF(&tcInvar,".T.",".F.")
ENDCASE
ENDFUNC
* eofunc: var2chr()

see if this helps

raezer
Previous
Reply
Map
View

Click here to load this message in the networking platform