Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Tidying Code 2

Status
Not open for further replies.

audiopro

Programmer
Apr 1, 2004
3,165
GB
I am tidying code again and wondered if there was an easy way to tidy this up.
I would rather not select * as listing the fields makes it more readable.
The part I would like to tidy up is the declaration of the 'L' var.
I could do it in a loop if the fields were all the same but there is a mixture of text and integers in there so the format code for the items will differ.
Code:
SELECT TABLENAME,FEELD,CAPSHUN,FIELDTYPE,SHOWTYPE,REQDTYPE,FFORMAT,FCHECK FROM CAPTIONS INTO ARRAY CAPLIST
C=FCREATE(CAPNAME,0)
FOR X = 1 TO ALEN(CAPLIST) STEP 8
	L = ALLTRIM(CAPLIST[x])+","+ALLTRIM(CAPLIST[x+1])+","+ALLTRIM(CAPLIST[x+2])+","+ALLTRIM(STR(CAPLIST[x+3]))+","+ALLTRIM(STR(CAPLIST[x+4]))+","+ALLTRIM(STR(CAPLIST[x+5]))+","+ALLTRIM(STR(CAPLIST[x+6]))+","+ALLTRIM(STR(CAPLIST[x+7]))+","+CHR(13)+CHR(10)
	W=FWRITE(C,L)
NEXT
CL = FCLOSE(C)

Keith
 
DELIMITED WITH "" does not work, you must delimit the string fields with something, as the values might contain the separator. COPY TO has no means of having no stinrg delimiter.

Bye, Olaf.
 
OK, the point is VFP errors, if you specify an empty value for the delimiter. You can't force it.

Do you really need the output file without a string delimiter? You will use that output as input somewhere else, and if that other application/tool whatever understands csv the main point is comma separation, string delimiters will not harm, normally. So simply skip that clause to get the standard double quotation marks and use

Code:
COPY TO c:\work\junk.txt TYPE DELIMITED

Bye, Olaf.
 
audiopro said:
where the speech marks are easily removed and the file works a treat.
Ah, I see, so forget my last post, you already figured it out.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top