Solved

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

Posted on 2003-11-10
3
213 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

For Desktop Techs: How to retain a user's Notes configuration data when swapping out the end user's computer. (Assuming that you are not upgrading to a completely different version of Notes client) All you need to do is: 1) install Notes o…
This is an old article, please see an updated version of this article, located here: http://www.experts-exchange.com/articles/23619/Notes-8-5x-Windows-7-Notes-info-and-tips.html
This video discusses moving either the default database or any database to a new volume.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

705 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

16 Experts available now in Live!

Get 1:1 Help Now