General information
Category:
Coding, syntax & commands
>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
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only