Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Cecil Champenois
  Where is Cecil Champenois?
 Little Elm
 Texas - United States
 Cecil Champenois
 To: David Mustakim
  Where is David Mustakim?
 Jakarta
 Indonesia
 David Mustakim
 Tags
Subject: RE: FPUTS()
Thread ID: 394213 Message ID: 394215 # Views: 58 # Ratings: 0
Version: Visual FoxPro 9 SP2 Category: Databases, Tables and SQL Server
Date: Tuesday, December 31, 2013 6:52:29 PM         
   


> why not just add a line near it - something like "WAIT allt(str(recno()))+' - '+ xxxx WINDOW NOWAIT NOCLEAR" so you know exactly what (xxxx) it is writing while it is writing it...
>
> .
>
> > I am using FCREATE(), and FPUTS() to write to a TEXT file, which I open in NOTEPAD. The program (FPUTS() appears to be writing the same record repeatedly, although the program does not do that. And records are not beginning all at column 1 as they should. I've never seen this before. These records are each over 600 characters long. If this were not private data, I'd show an image of it so you could see what it is doing. This is very odd.
> >
> > SET STEP ON
> > * Get the total of all premiums).
> > SELECT tmpData2
> > SUM EE_DEDUCT TO lnPremiumsTotal
> > 
> > ***************************
> > * Set up output file name.
> > ***************************
> > lcFileName="Seminole_" +runDate + ".TXT"
> > outputFileName=exportPath + lcFileName
> > * Create the FILE name.
> > fileHandle=FCREATE(outputFileName, 0)
> > IF fileHandle > 0	&& File creation succeeded.
> > 	**************************
> > 	* Make the HEADER ROW now.
> > 	**************************
> > 	lcHeaderRowType="01"
> > 	lcPayLogixOrgID="  6635"
> > 	lcCvgPerEndDate=DTOC(ldEndOfCurrentMonth)
> > 	lcAcctID=SPACE(15) + "SEM01"
> > 	lcHeaderRowFiller=SPACE(638)
> > 	lcHeaderRow=lcHeaderRowType + lcPayLogixOrgID + lcCvgPerEndDate + lcAcctID + lcHeaderRowFiller
> > 	lnNumberOfBytesWrittenToHeader=FPUTS(fileHandle, lcHeaderRow)
> > 	
> > 	**************************
> > 	* Make the DETAIL ROW now.
> > 	**************************
> > 	SELECT tmpData2
> > 	LOCATE
> > 	lc=""
> > 	* Loop through the data.
> > 	SCAN
> > 		lc = lc + tmpData2.RowType    && Columns   1-  2 Row Type             - Length:   2
> > 		lc = lc + LastName            && Columns   3- 52 LastName             - Length:  50
> > 		lc = lc + FirstName           && Columns  53-102 FirstName            - Length:  50
> > 		lc = lc + SSN                 && Columns 103-113 Social Security #    - Length:  11
> > 		lc = lc + Branch              && Columns 114-133 Branch               - Length:  20
> > 		lc = lc + EmployeeID          && Columns 134-158 Employee ID          - Length:  25
> > 		lc = lc + Address             && Columns 159-308 Address              - Length: 150
> > 		lc = lc + City                && Columns 309-333 City                 - Length:  25
> > 		lc = lc + State               && Columns 334-335 State                - Length:   2 XX
> > 		lc = lc + Zip                 && Columns 336-345 Zip                  - Length:  10
> > 		lc = lc + Home_Phone          && Columns 346-365 Telephone            - Length:  20
> > 		lc = lc + Email               && Columns 366-440 Email                - Length:  75
> > 		lc = lc + Gender              && Columns 441-441 Gender               - Length:   1 M=Male, F=Female
> > 		lcBaseSalary=PADL(LTRIM(TRANSFORM(BaseSalary, "9999999.99")), 10, "0")
> > 		lc = lc + lcBaseSalary        && Columns 442-451 Base Salary          - Length:  10 9999999.99
> > 		lcOtherComp=PADL(LTRIM(TRANSFORM(Other_Comp, "9999999.99")), 10, "0")
> > 		lc = lc + lcOtherComp         && Columns 452-461 Other Compensation   - Length:  10 9999999.99
> > 		lc = lc + DTOC(DOB)           && Columns 462-469 Date of Birth        - Length:   8 MM/DD/CCYY
> > 		lc = lc + DTOC(Hire_Date)     && Columns 470-477 Hire Date            - Length:   8 MM/DD/CCYY
> > 		lc = lc + JobTitle            && Columns 478-517 Job Title            - Length:  40
> > 		lc = lc + EmpStatus           && Columns 518-518 Employment Status    - Length:   1 A=Active, R=Retired, T=Terminated, L=?
> > 		lc = lc + DTOC(TermDate)      && Columns 519-526 Termination Date     - Length:   8 MM/DD/CCYY Retirement/Termination Date
> > 		lc = lc + TypeEmp             && Columns 527-528 Type of Employment   - Length:   2 FT=Full Time, PT=Part TIme
> > 		lc = lc + Temp_Emp            && Columns 529-529 Temporary Employment - Length:   1 1=Temp, 0=Permanent
> > 		lc = lc + Prem_Mode           && Columns 530-531 Premium Mode         - Length:   2 99 (Number of Billing Periods per Year)
> > 		lc = lc + PolicyNo            && Columns 532-556 Policy Number        - Length:  25
> > 		lc = lc + DTOC(Period_End)    && Columns 557-566 Period Ending        - Length:  10 MM/DD/CCYY
> > 		lc = lc + DTOC(Eff_Date)      && Columns 567-576 Effective Date       - Length:  10 MM/DD/CCYY
> > 		lc = lc + DTOC(Stop_Date)     && Columns 577-586 Stop Date of Coverage- Length:  10 MM/DD/CCYY PTD if C or L, if no Term Date.
> > 		lcCashValue=PADL(LTRIM(TRANSFORM(Cash_Value, "9999999999.99")), 13, "0")
> > 		lc = lc + lcCashValue         && Columns 587-599 Cash Value           - Length:  13 9999999999.99
> > 		lc = lc + DTOC(PTD)           && Columns 600-607 Paid To Date         - Length:  10 MM/DD/CCYY
> > 		lc = lc + ProductID           && Columns 608-627 Product ID           - Length:  20
> > 		lcEE_DEDUCT=PADL(LTRIM(TRANSFORM(EE_DEDUCT, "9999999999.99")), 13, "0")
> > 		lc = lc + lcEE_Deduct         && Columns 628-640 Employee Deduction   - Length:  13 9999999999.99
> > 		lcER_DEDUCT=PADL(LTRIM(TRANSFORM(ER_DEDUCT, "9999999999.99")), 13, "0")
> > 		lc = lc + lcER_Deduct         && Columns 641-653 Employer Deduction   - Length:  13 9999999999.99
> > 		lc = lc + Pre_Tax             && Columns 654-654 Pre-Tax              - Length:   2 1=Pre-Tax, 0=Post-Tax
> > 		lc = lc + Subscript           && Columns 655-655 Subscription Status  - Length:   1 A=Active, C=Cancelled, D=Direct Bill, P=Paid in Full
> > 		lc = lc + Tier                && Columns 656-658 Tier                 - Length:   3 EEO=Employee Only, EE1=Employee + 1, EES=Employe + Spouse
> > 		lcPolCvgAmt=PADL(LTRIM(TRANSFORM(PolCvgAmt, "9999999999.99")), 13, "0")
> > 		lc = lc + lcPolCvgAmt         && Columns 659-671 Policy Coverage Amt  - Length:  13 9999999999.99
> > 		lc = lc + Filler1             && Columns 672-680 Filler               - Length:   9 Spaces
> > 		
> > 		* Write the record to the file now.
> > 		SET STEP ON
> > 		lnNumberOfBytesWrittenToDetail=FPUTS(fileHandle, lc)
> > 	ENDSCAN
> > 	
> > 	**************************
> > 	* Make the FOOTER ROW now.
> > 	**************************
> > 	SET STEP ON
> > 	lcFooterRowType="99"
> > 	lcRecordCount=PADL(ALLTRIM(STR(RECCOUNT("tmpData2"))),6,"0")
> > 	lcTotalDeductionAmount=PADL(LTRIM(TRANSFORM(lnPremiumsTotal), "9999999999.99"),13,"00")
> > 	lcFooterRowFiller=SPACE(653)
> > 	lcFooterRow=lcFooterRowType + lcRecordCount + lcTotalDeductionAmount + lcFooterRowFiller
> > 	lnNumberOfBytesWrittenToFooter=FPUTS(fileHandle, lcFooterRow)
> > 	
> > 	* Close the file now.
> > 	FCLOSE(fileHandle)
> > 	FLUSH	&& Force the data to the disk now.
> > ENDIF	
> > SET STEP ON
> > RETURN
> > 

> > Cecil Champenois, Jr.

I put in some additional code to get the Record Number and also display the string (lc) in the Wait Window but I think the wait window can only hold so many characters. I got an error stating "String is too long to fit". I cannot overload the WAIT WINDOW, obviously.
The code was as follows:
WAIT WINDOW ALLTRIM(STR(RECNO()))+ lc NOCLEAR


Cecil Champenois, Jr.

ENTIRE THREAD

FPUTS() Posted by Cecil Champenois @ 12/31/2013 6:28:59 PM
RE: FPUTS() Posted by David Mustakim @ 12/31/2013 6:38:02 PM
RE: FPUTS() Posted by Cecil Champenois @ 12/31/2013 6:52:29 PM
RE: FPUTS() Posted by David Mustakim @ 12/31/2013 6:55:05 PM
RE: FPUTS() Posted by Cecil Champenois @ 12/31/2013 6:57:04 PM
RE: FPUTS() Posted by David Mustakim @ 12/31/2013 7:00:17 PM
RE: FPUTS() Posted by Cecil Champenois @ 12/31/2013 7:27:15 PM
RE: FPUTS() Posted by David Mustakim @ 12/31/2013 7:33:52 PM
RE: FPUTS() Posted by Cecil Champenois @ 12/31/2013 7:39:00 PM
RE: FPUTS() Posted by Russell Hill @ 12/31/2013 9:52:03 PM
RE: FPUTS() Posted by Cecil Champenois @ 12/31/2013 9:57:52 PM
RE: FPUTS() Posted by Tamar Granor @ 1/2/2014 11:08:07 PM
RE: FPUTS() Posted by David Mustakim @ 1/2/2014 11:10:00 PM
RE: FPUTS() Posted by Vilhelm-Ion Praisach @ 1/3/2014 2:26:46 AM
RE: FPUTS() Posted by Tore Bleken @ 1/1/2014 1:25:19 PM
RE: FPUTS() Posted by Cecil Champenois @ 1/1/2014 4:49:36 PM
RE: FPUTS() Posted by Cetin Basoz @ 1/3/2014 3:40:52 PM
RE: FPUTS() Posted by luca bellagamba @ 1/3/2014 4:07:20 PM