Solved

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

Posted on 2003-11-10
3
223 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Creating a bat file fo Note.ini 4 234
Lotus notes "Estimate" form to Quickbooks invoice 2 366
Lotus Notes Mail Database issues 2 977
Lotus Notes: Email Delivery Failure 5 199
  In today’s Arena we can’t imagine our lives without Internet as we are highly used to of it. If we consider our life style just for only 2 min we found that face to face communication is swapped by e-communication.  Every Where from Works place to…
Lack of Storage capacity is a common problem that exists in every field of life. Here we are taking the case of Lotus Notes Emails, as we all know that we are totally depend on e-communication i.e. Emails. This article is fully dedicated to resolvin…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

756 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