OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Dir$ turbo?

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
Rory
Power User
Power User


Joined: 04 Nov 2004
Posts: 51
Location: Brasilia DF, Brasil

PostPosted: Thu Nov 04, 2004 6:14 am    Post subject: Dir$ turbo? Reply with quote

HI all,

Im Using the "Dir$" Function to return file names for reading and relocation, the trouble is Im working with 14000 files per folder, and each time "Dir$" is processed in a loop it is taking about 5 seconds, for the 14000 files thats 16 hours, ^Almost^ the same code in Excel/VBA took only 15 minutes per folder, just wondering if there exists a faster way to do this in OOo?


Many thanks in advance
_________________
Rory

/Cries

OOo 1.1.3/4/5 / 2.0 on Win NT/2000/XP(SP1/2)
Back to top
View user's profile Send private message
Cybb20
Super User
Super User


Joined: 02 Mar 2004
Posts: 1569
Location: Frankfurt, Germany

PostPosted: Thu Nov 04, 2004 10:01 am    Post subject: Reply with quote

Why would you wanna do this with a scripting language like Starbasic? This is a task suitable for languages like C++.
However maybe it is faster if you use the ucb layer (getFolderContents()).

Christian
_________________
- Knowledge is Power -
Back to top
View user's profile Send private message Send e-mail
Rory
Power User
Power User


Joined: 04 Nov 2004
Posts: 51
Location: Brasilia DF, Brasil

PostPosted: Thu Nov 04, 2004 10:17 am    Post subject: Reply with quote

Well Im not sure, Im opening each file reading the first line, and depending on this, reading a random number of lines and writing these out to another file.

Im not sure of other easier ways to do this, i am only doing it this way as, my knowledge of macros and scripting grew as my work requirements grew.

I would be interested to know of other ways at looking at this, in regard to new chalenges and things to learn Smile


Thanks again


Rory
_________________
Rory

/Cries

OOo 1.1.3/4/5 / 2.0 on Win NT/2000/XP(SP1/2)
Back to top
View user's profile Send private message
Rory
Power User
Power User


Joined: 04 Nov 2004
Posts: 51
Location: Brasilia DF, Brasil

PostPosted: Thu Nov 04, 2004 11:29 am    Post subject: Reply with quote

Hi again, I think ive figured this out, and you would have no doubht spotted it had I posted the code,

INside the loop i had ****Dir$"folder Path"*** when I changed this for just Dir$ things have speeded up a lot, it is still very slow on the first Dir before the loop but inside the loop its much better yet still slower than excel / VBA, is this to be expected??? Now im curious as to any other options/ ways? I have to do the same thing.



If it would help I could post my macro altho its a bit of a monster, and 99% of the 'notes are in portuguese
_________________
Rory

/Cries

OOo 1.1.3/4/5 / 2.0 on Win NT/2000/XP(SP1/2)
Back to top
View user's profile Send private message
Cybb20
Super User
Super User


Joined: 02 Mar 2004
Posts: 1569
Location: Frankfurt, Germany

PostPosted: Thu Nov 04, 2004 3:40 pm    Post subject: Reply with quote

Great that it works!!
And just as a note: Such things are usually done with shell scripts (on Linux), and that's also just scripting language not too hard to learn.
_________________
- Knowledge is Power -
Back to top
View user's profile Send private message Send e-mail
Rory
Power User
Power User


Joined: 04 Nov 2004
Posts: 51
Location: Brasilia DF, Brasil

PostPosted: Mon Nov 08, 2004 4:17 am    Post subject: Reply with quote

Erk more problems,


on the first time I use dir, prior to the loop i use as follows,

Dir$"filepath"\r_*.dat

now to speed things up a great deal, inside of the loop i only put Dir"this speeded things up by 12 hours only problem is it grabs everything in the file not only the dat files so now is poping up errors everytime it opens the wrong file

any ideas how to fix this without punishing the time


Thanks in advance "again"
_________________
Rory

/Cries

OOo 1.1.3/4/5 / 2.0 on Win NT/2000/XP(SP1/2)
Back to top
View user's profile Send private message
Cybb20
Super User
Super User


Joined: 02 Mar 2004
Posts: 1569
Location: Frankfurt, Germany

PostPosted: Mon Nov 08, 2004 7:45 am    Post subject: Reply with quote

You mean you want to use wildcards? Like "only take every .dat file no other formats"?

Christian
_________________
- Knowledge is Power -
Back to top
View user's profile Send private message Send e-mail
Rory
Power User
Power User


Joined: 04 Nov 2004
Posts: 51
Location: Brasilia DF, Brasil

PostPosted: Mon Nov 08, 2004 9:01 am    Post subject: Reply with quote

yes,

Code:
dim sDirPath as string
Dim nextfile as string

sDirPath = "E:\REPORTS\GERAL\OOo\Dat"

Nextfile = Dir$(SdirPath & "r*.dat)

do untill nextfile = ""
open Nextfile for input as #1
' do my stuff
close #1
nextfile = Dir$
loop


now when I do the dir inside the loop it opens every file in the folder
IF inside the loop I put the whole path Nextfile = Dir$(SdirPath & "r*.dat)
then everytime it reaches that line in the loop it stops for 20 seconds

thanks again



Soreheaded
_________________
Rory

/Cries

OOo 1.1.3/4/5 / 2.0 on Win NT/2000/XP(SP1/2)
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group