Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: tushar Kanvinde
  Where is tushar Kanvinde?
 Kolhapur, Maharastra
 India
 tushar Kanvinde
 To: DEREK DODOO
  Where is DEREK DODOO?
 READING, UK
 United Kingdom
 DEREK DODOO
 Tags
Subject: RE: text file programming with CR LF
Thread ID: 143523 Message ID: 143526 # Views: 2 # Ratings: 0
Version: Visual FoxPro 6 Category: General VFP Topics
Date: Wednesday, August 29, 2007 3:14:16 PM         
   


> Dear All,
>
> I'd like to program the Carriage Return & the Line Feed, in generating a text file from a cursor as depicted below.
>
> I have problem exporting the text file when I created it with 'SDF' extension, hence this approach
>
>
>
>
> *****************************************************************
> The creation of the cursor and the textfile are as follows:
>
>
create cursor SALARY_PAY;
> 	(TRN_TYPE C(4), DEB_AC_NUM C(12), DEB_CURR C(3), DEB_AMT N(13,2), DEB_DATE 	D, CR_AcC_NUM C(12),;
> 	ORDER_CUST C(3), PROF_CENT C(4), DEB_REF C(14), CED_REF C(14))
> 	
> 
> 	select * from vpayroll where vpayroll.PERIOD=?bb_period and vpayroll.YEAR1=?	cc_year ;
> 	into cursor salary_hold
> 
> 	SELECT salary_hold.*, vpaymast11.sssno;
> 	FROM salary_hold;					
> 	LEFT OUTER JOIN vpaymast11  ON salary_hold.idno ==vpaymast11.idno  into 	CURSOR fin_rep
> 						
> 
> 	SELECT fin_rep.*, vdept.cost_center;
> 	FROM fin_rep;					
> 	LEFT OUTER JOIN vdept  ON fin_rep.dept ==vdept.dep_no  into CURSOR fin_rep1
> 		
> 	
> 	******************************creating the accounts 
> 	
> 						
> 	select fin_Rep1
> 	go top
> 		
> 	XXX=THISFORM.DIRM1.VALUE	
> 		
> 		
> 	SCAN
> 		
> 		
> 		select salary_pay
> *****************************************1		
> 		append blank
> 		replace trn_type with "ACSP"
> 		replace deb_ac_num with "PL64401"
> 		replace deb_curr with "ASD"
> 		replace deb_amt with FIN_REP1.BASICSAL
> 		replace deb_Date with DATE()
> 		replace cr_Acc_num with "ABC000000002"
> 		replace order_cust with "TRIAL"
> 		replace prof_cent with FIN_REP1.COST_CENTER
> 		replace deb_ref with "BASIC SALARY"
> 		replace ced_ref with "BASIC SALARY"
> ******************************************2	
> 		append blank
> 		replace trn_type with "ACSP"
> 		replace deb_ac_num with "PL44431"
> 		replace deb_curr with "ASD"
> 		replace deb_amt with FIN_REP1.SSFPLER
> 		replace deb_Date with DATE()
> 		replace cr_Acc_num with "UKA77770002"
> 		replace order_cust with "ASD"
> 		replace prof_cent with FIN_REP1.COST_CENTER
> 		replace deb_ref with "SSF EMPLOYER"
> 		replace ced_ref with "SSF EMPLOYER"
> ******************************************3			
> 		append blank
> 		replace trn_type with "ACSP"
> 		replace deb_ac_num with "PL66641"
> 		replace deb_curr with "UKA"
> 		replace deb_amt with FIN_REP1.PROVDER
> 		replace deb_Date with DATE()
> 		replace cr_Acc_num with "UKA333330002"
> 		replace order_cust with "ASD"
> 		replace prof_cent with FIN_rEP1.COST_CENTER
> 		replace deb_ref with "SSS EMPLOYER"
> 		replace ced_ref with "SSS EMPLOYER"
> 		
> 		select fin_rep1
> 		
> 		
> *******************************************************************
> *******************************************************************	
> ENDSCAN
> 
> 
> 
> ********************************
> *********exporting file******(this approach is creating problems in importing system)
> ********************************
> SELECT SALARY_PAY
> 
> 	<B>COPY TO ABC  TYPE  SDF
> 	lcContents =FILETOSTR("ABC.TXT")
> 	STRTOFILE(CHRTRAN(lcContents,CHR(13)+CHR(10),""),"ABC.TXT")
> 	</B>	 
> MODIFY FILE ABC.TXT

>
>
>
>
> I'd not like to use the 'SDF' extension.
>
> I'd like ASSISTANCE in the creation of the ABC.TXT file using CR & LF instead of the immediate above
>
> Thanks

Derek

Could you upload a sample of what actually works. The COPY TO command puts a CR LF at the end of every record. It does not put a EOF at the end. Sometime you need an EOF at the end of the file. For that you have to give
STRTOFILE(lcContents+chr(26),'abc.txt')

Sometimes you want only CR and not CRLF. For that you give
STRTOFILE(CHRTRAN(lcContents,CHR(10),""),"ABC.TXT")
This is mainly used by unix based OS.

Or you may need to remove the LF and add the EOF.

What you have given is a fixed length without anything at the end of record. I last saw that in the late 80s when it was used by COBOL.

Regards
Tushar

ENTIRE THREAD

text file programming with CR LF Posted by DEREK DODOO @ 8/29/2007 3:03:31 PM
RE: text file programming with CR LF Posted by tushar @ 8/29/2007 3:14:16 PM
RE: text file programming with CR LF Posted by DEREK DODOO @ 8/29/2007 3:54:56 PM
RE: text file programming with CR LF Posted by tushar @ 8/29/2007 4:14:36 PM
RE: text file programming with CR LF Posted by Cetin Basoz @ 8/29/2007 5:01:46 PM
RE: text file programming with CR LF Posted by Ilya Rabyy @ 8/29/2007 5:10:45 PM