Solved

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

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Lotus notes forward mail problem 5 416
IBM Enterprise Integrator - ZID File 1 173
LOtusscript Scheduled Agent access to calendar  fails to get entries on 4 151
Lotus Notes 6.5.5 6 222
IBM Notes offer Encryption feature using which the user can secure its NSF emails or entire database easily. In this section we will discuss about the process to Encrypt Incoming and Outgoing Mails in depth.
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.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

790 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