Creating and writing sequence files

hello,i need some help in order to create dynamically a text file from an agent. This text file will include values from fields that are in the form by which the agent will be called.

Here is what i have done till now but i always get the message : " Unable to open file"

Sub Initialize

On Error Goto ProcessError	





Dim db As NotesDatabase

Dim dbAgent As NotesDatabase

Dim dc As NotesDocumentCollection

Dim doc As NotesDocument

Dim subj As Variant

Dim curDoc As NotesDocument



    Set session = New NotesSession

Set db = session.CurrentDatabase

Set dbAgent = New NotesDatabase("", "webagent.nsf")

Set dc = db.UnprocessedDocuments

Set doc = dc.GetFirstDocument

Set curDoc = session.DocumentContext



    subj1 = doc.GetItemValue( "Assurance_surname" )

subj2=curDoc.Assurance_surname



    Dim fileNum As Integer, text As String

fileNum% = Freefile()

    Dim pathname as String

    pathname=d:\ioanna\File.txt"

Open pathname For Append Access Write As fileNum%

Print #fileNum%,  subj1

Print #fileNum%,  subj2

Close fileNum%

End Sub

Subject: creating and writing sequence files

George,Does the directory ‘ioanna’ actually exist on your d: drive?

nwilkins@hmi.co.uk

Subject: RE: creating and writing sequence files

Yes it exists and if i run it separatelly from the application and instead of GetitemValue put a string it cerates it. but when i run it from my application it keeps telling me Unable to open file

Subject: creating and writing sequence files

I can see a few problems here.

subj1 = doc.GetItemValue( “Assurance_surname” )

GetItemValue returns an array, not a string. You’ll need to use subj1(0) to get a value.

subj2=curDoc.Assurance_surname

You’ll want to use GetItemValue here as well.

pathname=d:\ioanna\File.txt"

Missing an initial quotation mark here. Follow along in the debugger and make sure that pathname is getting set to the value you think it is.

Open pathname For Append Access Write As fileNum%

Probably more elaborate than it needs to be. I’d just use something like this:

Open pathname For Append As fileNum%