LotusScript Dir Command on iSeries

I try to use the dir command in a background agentto see all files in a directory. I never see anything:

Here is my code:

Sub importDocs(folderName As String)

On Error Goto Errorhandler 



 'Searching database for new docs or updates 

Print "$Import =>> Searching folder " + folderName 



Dim tmpFileName As String 

Dim fileName() As String 

Dim i As Integer 

Dim j As Integer 



Dim file As String 



tmpFileName = Dir$(folderName,0) 

i = 0



'Alle fileNamen in Liste einlesen

Do While tmpFileName <> "" 

	Redim Preserve fileName(i) 

	fileName(i) = tmpFileName

	

	Print tmpFileName

	

	i = i + 1 

	tmpFileName = Dir 

Loop 



'über alle files in Liste loopen

j = 0 

Do While j < i 

	

	file = folderName + fileName(j) 

	

	'Keine Directories importieren, werden im else case behandelt

	If Getfileattr(file) < 16 Or (Getfileattr(file) >= 32 And Getfileattr(file) < 54) Then 

		

           'Neue Dokumente erstellen

		Call createDocument(file)

		

		'files aus directory löschen

		'Kill file

		

	'Falls SubFolder, funkrion rekursiv aufrufen	

	Elseif  (Getfileattr(file) >= 16 And Getfileattr(file) < 32) Then

		'in windows immer diese zwei files auslassen

		If fileName(j) <> "." And fileName(j)  <> ".."  Then

			'rekursiver aufruf

			Call importDocs(file + "\") 

		End If

	End If 

nextFile:

'Step in here after Error

	j = j + 1 

Loop 

ExitSub:

Exit Sub 

Errorhandler:

Print "Error in $Import =>> " + Error() + " : " + file + "; File Attribut: " + Cstr(Getfileattr(file))

Resume nextFile 

End Sub

is this an iSeries problem or is something in my code wrong?

Thanks in advance

Tonio

Subject: LotusScript Dir Command on iSeries

Read this thread:http://www-10.lotus.com/ldd/46dom.nsf/DateAllThreadedweb/977373b6e8a66b0485256c0200465929?OpenDocument

It describes quite well why Dir$() isn’t working in a background or scheduled agent.

Subject: RE: LotusScript Dir Command on iSeries

The original poster is working on an iSeries (AS/400).

The link is describing the problem of drive shares not being available to the SYSTEM account on a Windows system, so it doesn’t apply at all to the problem of the poster.

Other than that: it is useful to keep that particular problem in mind for windows peeps :slight_smile:

cheers,

Bram

Subject: LotusScript Dir Command on iSeries

You might try…

Set directory = New notesdbdirectory ( Inputbox$(“What is the Server Name?”))

 Set db = directory.getfirstdatabase(database)

YOUR CODE

Set db = directory.getnextdatabase

Use Messagebox throughout your code and see if the dir & database is found.

Subject: LotusScript Dir Command on iSeries

You’re not using Dir in a good way: it only works in the current active directory – so you have to go there first with ChDir.

in stead of :

tmpFileName = Dir$(folderName,0) 

i = 0

you should use:

ChDir folderName

tmpFileName = Dir$("*.*",0) 	'Note: I don't know anything of filemasks on OS/400

i = 0					'so please use the correct mask for 'all files'

cheers,

Bram