I’m attempting to have an agent read a .txt file and create individual documents based on the content of the file. I use code similar to this without fail on a regular basis, but now I’m having an odd problem.
Here’s my code:
While x < b
stream.Position = x
content = stream.ReadText(EOL_CRLF)
Set dedoc = New NotesDocument(db)
dedoc.Form = “DE”
dedoc.UploadString = Trim(Right$(Left$(content, 1269), 1269))
Call dedoc.Save(True, True)
x = x + 1269
Wend
One of two things consistently occurs when I run this:
-
The agent runs successfully but after the 60th record, 20 documents are created with no content. It’s always after the 60th and it’s always 20 documents. After that 20, the remaining documents are created appropriately.
-
Notes crashes.
I’ve changed the source data for the .txt file thinking that the content might be causing the issue, but the exact same thing happens.
Any and all help is appreciated.
Subject: Here’s what I’d do
I’d add a counter, and add an if statement. If hat counter is 60, then I would have a debug break point inside that if and then step through the code and see what values are when it crashes.
Subject: Already ahead of you…
I was in the process of doing this when I read your suggestion.
Here’s what happens:
x, which is used to set the position in the stream, accurately sets for all 100 records. I also monitored how long the content string was with each re-set of x, and this works fine up to the 61st record. But for some reason when it hits that 61st record, the remaining content number nearly doubles. When it gets to the 81st record, the content drops back down to where it was supposed to be!
Sorry if this is confusion, but WTF?
Subject: What type is X? Integer, long?
Subject: X integer is long
Correct…it is long.
Sorry, didn’t share all my dims for sake of keeping this short.
Subject: Ooops…I mean, X is long.
Sorry about that…fat fingers.