I 've coded a subroutine to create a text file (in this case a xml file)
which sometimes holds a size of 500 - 900 KB. While the subroutine works
efficiently for small file size (up to 50 KB) I noted a worse efficiency in
case of large file size (up to 10 minutes of calculation time).

This is the routine :

Set fso = CreateObject("Scripting.FileSystemObject")
Set xmlFile = fso.CreateTextFile(FilePath, True)

DO
xmlFile.Write "some text" & vbCrLf

LOOP UNTIL ..

xmlFile.Close

While debugging I've noted that the execution of line : xmlFile.Write ...
takes more and more time as the text file has grown lager.

Is there a more efficient way to create the text file ?

Regards,
Oscar

Re: How can I create a large text file is an efficient way? by Jezebel

Jezebel
Tue Mar 14 03:13:24 CST 2006

1. Don't use the Scripting object. The native file commands are simpler,
quicker, and more reliable.
2. Construct the file in memory then write it in one operation:

Dim pFileNum as long
Dim pFileText as string

Do
pFileText = pFileText & "sometext" & vbCr
Loop until ...

pFileNum = freefile
open FilePath for output as pFileNum
Print #pFileNum, pFileText
Close #pFileNum






"Oscar" <oku@xs4all.nl> wrote in message
news:e9%236TR0RGHA.336@TK2MSFTNGP12.phx.gbl...
>I 've coded a subroutine to create a text file (in this case a xml file)
>which sometimes holds a size of 500 - 900 KB. While the subroutine works
>efficiently for small file size (up to 50 KB) I noted a worse efficiency in
>case of large file size (up to 10 minutes of calculation time).
>
> This is the routine :
>
> Set fso = CreateObject("Scripting.FileSystemObject")
> Set xmlFile = fso.CreateTextFile(FilePath, True)
>
> DO
> xmlFile.Write "some text" & vbCrLf
>
> LOOP UNTIL ..
>
> xmlFile.Close
>
> While debugging I've noted that the execution of line : xmlFile.Write ...
> takes more and more time as the text file has grown lager.
>
> Is there a more efficient way to create the text file ?
>
> Regards,
> Oscar
>
>



Re: How can I create a large text file is an efficient way? by Oscar

Oscar
Tue Mar 14 07:44:21 CST 2006

Hi Jezebel,

I've done that but the performance didn't improve at all.

Oscar


"Jezebel" <warcrimes@whitehouse.gov> schreef in bericht
news:usuNee0RGHA.4608@tk2msftngp13.phx.gbl...
> 1. Don't use the Scripting object. The native file commands are simpler,
> quicker, and more reliable.
> 2. Construct the file in memory then write it in one operation:
>
> Dim pFileNum as long
> Dim pFileText as string
>
> Do
> pFileText = pFileText & "sometext" & vbCr
> Loop until ...
>
> pFileNum = freefile
> open FilePath for output as pFileNum
> Print #pFileNum, pFileText
> Close #pFileNum
>
>
>
>
>
>
> "Oscar" <oku@xs4all.nl> wrote in message
> news:e9%236TR0RGHA.336@TK2MSFTNGP12.phx.gbl...
>>I 've coded a subroutine to create a text file (in this case a xml file)
>>which sometimes holds a size of 500 - 900 KB. While the subroutine works
>>efficiently for small file size (up to 50 KB) I noted a worse efficiency
>>in case of large file size (up to 10 minutes of calculation time).
>>
>> This is the routine :
>>
>> Set fso = CreateObject("Scripting.FileSystemObject")
>> Set xmlFile = fso.CreateTextFile(FilePath, True)
>>
>> DO
>> xmlFile.Write "some text" & vbCrLf
>>
>> LOOP UNTIL ..
>>
>> xmlFile.Close
>>
>> While debugging I've noted that the execution of line : xmlFile.Write
>> ... takes more and more time as the text file has grown lager.
>>
>> Is there a more efficient way to create the text file ?
>>
>> Regards,
>> Oscar
>>
>>
>
>



Re: How can I create a large text file is an efficient way? by Karl

Karl
Tue Mar 14 11:58:29 CST 2006

Oscar wrote:
> I 've coded a subroutine to create a text file (in this case a xml
> file) which sometimes holds a size of 500 - 900 KB. While the
> subroutine works efficiently for small file size (up to 50 KB) I
> noted a worse efficiency in case of large file size (up to 10 minutes
> of calculation time).

This multipost was answered, very well, elsewhere... <sigh>
--
Working without a .NET?
http://classicvb.org/