Discussion:
text file
(too old to reply)
Wilson Thomas
2004-11-29 22:45:08 UTC
Permalink
Dear friends,

Following is the code I used to create a low-level tex file. It always add a
blank line at the top and start appending from second line onward. Is there
is anyway to avoid that blank line?

SELECT bankrep
GO TOP
SET TEXTMERG ON
DO WHILE !EOF()
TEXT
<<bankrep.names>>
ENDTEXT
SELECT bankrep
SKIP
ENDDO
SET TEXTMERG OFF


rgds

Wilson Thomas
Rick Bean
2004-11-29 23:24:37 UTC
Permalink
Wilson,
What version of VFP are you using?
If it's VFP 6.0 SP3 or higher, you could use:
SELECT bankrep
lcTmp = ""
SCAN
lcTmp = lcTmp + alltrim(bankrep.names) + chr(13) +chr(10)
ENDSCAN
=strtofile(lcTmp, "YourFile.Txt")
lcTmp = "" && release the string data

Rick
Post by Wilson Thomas
Dear friends,
Following is the code I used to create a low-level tex file. It always add a
blank line at the top and start appending from second line onward. Is there
is anyway to avoid that blank line?
SELECT bankrep
GO TOP
SET TEXTMERG ON
DO WHILE !EOF()
TEXT
<<bankrep.names>>
ENDTEXT
SELECT bankrep
SKIP
ENDDO
SET TEXTMERG OFF
rgds
Wilson Thomas
Sietse Wijnker
2004-11-30 08:33:39 UTC
Permalink
Hi Rick, Wilson

If the BankRep table is very large, this is not the best way because of the
amount of memory VFP has to allocate for the lcTmp variable.
I would still use a textmerge:
Select Bankrep
LOCAL llFirstRecordPassed
SET TEXTMERGE ON TO File.txt
SCAN
IF NOT llFirstRecordPassed
*- Make sure the 1st line is filled with data, using the \\ command
llFirstRecordPassed = .T.
\\<<BankRep.Names>>
ELSE
\<<BankRep.Names>>
ENDIF
ENDSCAN
SET TEXTMERGE TO
SET TEXTMERGE OFF

HTH,
Sietse Wijnker

"Rick Bean" <***@unrealmelange-inc.com> wrote in message news:%***@TK2MSFTNGP11.phx.gbl...
Wilson,
What version of VFP are you using?
If it's VFP 6.0 SP3 or higher, you could use:
SELECT bankrep
lcTmp = ""
SCAN
lcTmp = lcTmp + alltrim(bankrep.names) + chr(13) +chr(10)
ENDSCAN
=strtofile(lcTmp, "YourFile.Txt")
lcTmp = "" && release the string data

Rick
<rest snipped>
Rick Bean
2004-11-30 13:56:07 UTC
Permalink
Sietse,
Good idea. Sometimes I write so much test code, that I forget that in the "real" world data can get real big. On the other hand if the data doesn't have a huge number of records, and the workstations aren't severly crippled with minimal available RAM, then my code may be easier to understand.

Rick
Post by Sietse Wijnker
Hi Rick, Wilson
If the BankRep table is very large, this is not the best way because of the
amount of memory VFP has to allocate for the lcTmp variable.
Select Bankrep
LOCAL llFirstRecordPassed
SET TEXTMERGE ON TO File.txt
SCAN
IF NOT llFirstRecordPassed
*- Make sure the 1st line is filled with data, using the \\ command
llFirstRecordPassed = .T.
\\<<BankRep.Names>>
ELSE
\<<BankRep.Names>>
ENDIF
ENDSCAN
SET TEXTMERGE TO
SET TEXTMERGE OFF
HTH,
Sietse Wijnker
Wilson,
What version of VFP are you using?
SELECT bankrep
lcTmp = ""
SCAN
lcTmp = lcTmp + alltrim(bankrep.names) + chr(13) +chr(10)
ENDSCAN
=strtofile(lcTmp, "YourFile.Txt")
lcTmp = "" && release the string data
Rick
<rest snipped>
Wilson Thomas
2004-11-30 23:10:16 UTC
Permalink
Thanks friends, it worked!!

Wilson

"Rick Bean" <***@unrealmelange-inc.com> wrote in message news:***@TK2MSFTNGP09.phx.gbl...
Sietse,
Good idea. Sometimes I write so much test code, that I forget that in the
"real" world data can get real big. On the other hand if the data doesn't
have a huge number of records, and the workstations aren't severly crippled
with minimal available RAM, then my code may be easier to understand.

Rick
Post by Sietse Wijnker
Hi Rick, Wilson
If the BankRep table is very large, this is not the best way because of the
amount of memory VFP has to allocate for the lcTmp variable.
Select Bankrep
LOCAL llFirstRecordPassed
SET TEXTMERGE ON TO File.txt
SCAN
IF NOT llFirstRecordPassed
*- Make sure the 1st line is filled with data, using the \\ command
llFirstRecordPassed = .T.
\\<<BankRep.Names>>
ELSE
\<<BankRep.Names>>
ENDIF
ENDSCAN
SET TEXTMERGE TO
SET TEXTMERGE OFF
HTH,
Sietse Wijnker
Wilson,
What version of VFP are you using?
SELECT bankrep
lcTmp = ""
SCAN
lcTmp = lcTmp + alltrim(bankrep.names) + chr(13) +chr(10)
ENDSCAN
=strtofile(lcTmp, "YourFile.Txt")
lcTmp = "" && release the string data
Rick
<rest snipped>
Sietse Wijnker
2004-11-30 23:31:53 UTC
Permalink
Sounds as yet another 'It depends' issue ;-)

Sietse

"Rick Bean" <***@unrealmelange-inc.com> wrote in message news:***@TK2MSFTNGP09.phx.gbl...
Sietse,
Good idea. Sometimes I write so much test code, that I forget that in the
"real" world data can get real big. On the other hand if the data doesn't
have a huge number of records, and the workstations aren't severly crippled
with minimal available RAM, then my code may be easier to understand.

Rick

<rest snipped>

Loading...