Solved

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

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

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

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

Notes Document Link used by IBM Notes is a link file which aids in the sharing of links to documents in email and webpages. The posts describe the importance and steps to create a Lotus Notes NDL file in brief.
This article covers general Notes 8.5 troubleshooting information including recreating the Notes\Data folder.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

635 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