Solved

I know this is difficult to understand but this AGENT thing is causing me to go grey.

Posted on 2003-11-10
3
217 Views
Last Modified: 2013-12-18
I have a text document that comes into an e-mail account.
An agent parses the text file and puts the contents into a Notes 5 DB document.
Everything works fine except for 1 field (not unlike all the others). It seems that if
  the incoming string is 73 characters or less, everthing is fine. If I go even 1 char
  over 73 the entire string is eliminated and appears to be blank in the document.

Here is the section of Lotus Script that utilizes the parsing function:
-----------------------------------
For i = 1 To collection.Count
            Set doc = collection.GetNthDocument( i )
            Set odoc = Sampdb.CreateDocument
            odoc.Form = "samporder"
            Set eMailBody = doc.GetFirstItem( "Body" )  
            plainText = eMailBody.GetFormattedText(True, 0 )
            odoc.so_name   = ExtractTextValue("name:")
            odoc.so_shipto   = ExtractTextValue("company:")
            odoc.so_contact   = ExtractTextValue("contname:")
            odoc.so_contphone = ExtractTextValue("contphone:")
            odoc.so_name   = ExtractTextValue("name:")
            odoc.so_salesrep = ExtractTextValue("salesrep:")          
            odoc.so_addr     = ExtractTextValue("address1:")
            odoc.so_city       = ExtractTextValue("city:")
            odoc.so_today     = Now
            odoc.so_time      = Time$
            odoc.so_state               = ExtractTextValue("state:")
            odoc.so_zip                   = ExtractTextValue("zip:")
            odoc.so_country              = ExtractTextValue("country:")
            odoc.so_email                   = ExtractTextValue("from:")
            odoc.so_wanted   = ExtractTextValue("wanted:")
            odoc.so_instruct_1   = ExtractTextValue("text1:")
            odoc.so_taken                  = ExtractTextValue("taken:")
            odoc.so_ship   = ExtractTextValue("shipping:")
            odoc.so_email = ExtractTextValue("from:")
            odoc.so_auth = ExtractTextValue("password1:")
            odoc.so_phone = ExtractTextValue("phone:")
            odoc.so_urgent= ExtractTextValue("urgent:")
            For x = 1 To 25
                  fldname = "so_it_" & Trim(Cstr(x))
                  tstr = "item" & Trim(Cstr(x)) & ":"
                  tstr = ExtractTextValue(tstr)
                  If Len(Trim(tstr)) = 0 Then
                        Goto Saveit
                  End If
                  Set docItem = odoc.ReplaceItemValue(fldname, tstr)
                  fldname = "so_descr_" & Trim(Cstr(x))
                  tstr = "descr" & Trim(Cstr(x)) & ":"
                  Set docItem = odoc.ReplaceItemValue(fldname, ExtractTextValue(tstr))
                  fldname = "so_um_" & Trim(Cstr(x))
                  tstr = "um" & Trim(Cstr(x)) & ":"
                  Set docItem = odoc.ReplaceItemValue(fldname, ExtractTextValue(tstr))
                  fldname = "so_qty_" & Trim(Cstr(x))
                  tstr = "qty" & Trim(Cstr(x)) & ":"
                  Set docItem = odoc.ReplaceItemValue(fldname, ExtractTextValue(tstr))
            Next-

-----------------------------------


Here is the section of the above code that isn't working right:
------------------------------------
odoc.so_instruct_1   = ExtractTextValue("text1:")
------------------------------------

Here is the fuction that reads them in:
-------------------------------------
Function ExtractTextValue(fldname As String) As String
      Dim x, y, z                                    As Integer
      
      x = Instr(1, plainText, fldname, 5)
      If x = 0 Then
            ExtractTextValue = ""
            Exit Function
      End If
      z = x + Len(fldname) + 1
      y = Instr(z, plainText, Chr(13), 5)
      If y > 0 Then
            ExtractTextValue = Mid(plainText, z, y - z)
            Exit Function
      End If
      y = Instr(z, plainText, "  ", 5)
      If y > 0 Then
            ExtractTextValue = Mid(plainText, z, y - z)
            Exit Function
      End If
      ExtractTextValue = " "
      
End Function
-------------------------------------

I didn't write this code and frankly have some trouble understanding some of it.
If anyone has a suggestion I'll try it, but please be specific.
0
Comment
Question by:rbender
3 Comments
 
LVL 31

Accepted Solution

by:
qwaletee earned 50 total points
ID: 9717847
Change it to teh following, and let us know what it prints out

Function ExtractTextValue(fldname As String) As String
     Dim x, y, z                              As Integer
     
     x = Instr(1, plainText, fldname, 5)
     If x = 0 Then
print "Field name not found, setting blank"
          ExtractTextValue = ""
          Exit Function
     End If
     z = x + Len(fldname) + 1
     y = Instr(z, plainText, Chr(13), 5)
     If y > 0 Then
Print "Found a carriage return, extracting from" z x "field name to CR" y
          ExtractTextValue = Mid(plainText, z, y - z)
          Exit Function
     End If
     y = Instr(z, plainText, "  ", 5)
     If y > 0 Then
Print "Found double space, extracting from" z x "field name to SP" y
          ExtractTextValue = Mid(plainText, z, y - z)
          Exit Function
     End If
Print "Found no carriage return, no double-space, returning blank!"

     ExtractTextValue = " "
     
End Function
0
 

Author Comment

by:rbender
ID: 9718417
Here is what has been found on this end.
Seems the text file on that particular field has a CR/LF in the "middle" of the line.
Must be being put there during the construct of the file.
Now that I know the issue I can address it.
Thanks for your help.
Take the points.
0
 
LVL 9

Expert Comment

by:Arunkumar
ID: 9721893
Thanks!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For users on the Lotus Notes 8 Standard client, this article provides information on checking the Java Heap size and adjusting it to half of your system RAM in attempt to get the Lotus Notes 8.x Standard client to run faster.  I've had to exercise t…
I thought it will be a good idea to make a post as it will help in case someone else faces these issues. I trust this gives an idea how each entry in Notes.ini can mean a lot for the Domino Server to be functioning properly. This article discusses t…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now