Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Weird-Record Pointer
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01507019
Message ID:
01507068
Views:
41
It will not be good performance wise, but for moderate tables the peformance may not be critical. I'd suggest to apply Thomas suggestion, though, and construct lc only once in the SCAN or better not use lc at all and do fputs of this expression.

>Here's how the code ended up, and it works just fine. I did not use FoxPro's TextMerge. I removed the "m." preceding the field names.:
>
>
>* Build the transmittal file now. Create a text file and FPUTS() the data
>* into it row by row.
>SELECT tmpData
>SET ORDER TO ID
>
>outputFileName=outputPath + SUBSTR(DTOS(RunDate), 5) + "_" + "GUMP.TXT"
>ERASE (outputFileName)
>fh=FCREATE(outputFileName)	&& Default is Read/Write in FCREATE().
>IF fh > 0
>	* File creation succeeded!
>	* Set up the Header data.
>	RecordType         = PADR("HDR", 13, " ")
>	SenderCompany      = PADR("Gump (555) 555-1602", 30, " ")
>	SenderContact      = PADR("forrest.gump@gump.com", 30, " ")
>	CreateDate         = CHRTRAN(DTOC(DATE()),"/","")
>	CreateTime         = CHRTRAN(TIME(),":","")
>	EnrollmentEntityID = SPACE(15)
>	JobType            = "ENR"
>	FullFileIndicator  = "Y"
>
>	* Put together the string for the Header record/line.
>	LcHeader = RecordType + SenderCompany + SenderContact + CreateDate + CreateTime + ;
>		EnrollmentEntityID + JobType + FullFileIndicator
>	* Now, write the header to the text file.
>	=FPUTS(fh, lcHeader)
>	GO TOP
>	SCAN
>		* Assemble the text data.
>		lc = GrpID
>		lc = lc + GrpNum
>		lc = lc + PADR(FirstName, 15)
>		lc = lc + IIF(EMPTY(Initial), " ", Initial)
>		lc = lc + PADR(LastName, 20)
>		lc = lc + PADR(Addr1, 30)
>		lc = lc + PADR(Addr2, 30)
>		lc = lc + PADR(City, 20)
>		lc = lc + PADR(State, 2)
>		lc = lc + PADR(Zip, 9, "0")
>		lc = lc + IIF(EMPTY(DOB),"00000000",DTOS(DOB))
>		lc = lc + "LEV1"				&& Benefit Option
>		lc = lc + SPACE(10)				&& DivCode
>		lc = lc + SPACE(15)				&& Pri_Sub_ID
>		lc = lc + PADR(SSN, 9)
>		lc = lc + PADR(HomePhone, 10)
>		lc = lc + IIF(EMPTY(Gender), "U", Gender)
>		lc = lc + SPACE(8)				&& EYE_MED_USE
>		lc = lc + DTOS(Eff_Date)
>		lc = lc + IIF(EMPTY(TermDate), "00000000", DTOS(TermDate))
>		lc = lc + PADR(Mbr_Type, 1)
>		lc = lc + PADR(RelateCD, 1)
>		lc = lc + PADR(Bill_Tier, 2)
>		lc = lc + SPACE(1)				&& Update Action
>		lc = lc + PADR(NoDep, 2)		&& Number of Dependents
>		lc = lc + SPACE(100)			&& Filler
>		lc = lc + SPACE(3)				&& Written Language
>		lc = lc + SPACE(3)				&& Spoken Language
>		lc = lc + SPACE(13)				&& Ethnicity
>		lc = lc + SPACE(13)				&& Race
>		lc = lc + PADR(Dom_State, 2)	&& Domiciled State (by Group)
>		* Write the string for the one record and continue in loop (SCAN..ENDSCAN).
>		=FPUTS(fh, lc)
>	ENDSCAN
>	* The text file has been written, now close the text file.
>	=FCLOSE(fh)
>	FLUSH		&& Force the data to disk now.
>	CLOSE ALL	&& Close all the open tables.
>ENDIF
>
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform