Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

A problem with extracting data from a memo field 1

Status
Not open for further replies.

keepingbusy

Programmer
Apr 9, 2000
1,470
GB
Can anyone please suggest why this is working correctly?

We have been using part of the following code to automatically extract information that has been copied from the body of an email then pasted into a memo field which then places the appropriate data in to different fields within a table.
Code:
USE mytable
GO mrecno
STORE "" TO lcorder
STORE EMAILBODY TO lcorder  && This is the MEMO FIELD NAME

lnLineCount = ATLINE("Nombre total d'articles : ",lcorder)
lnLine = MLINE(lcorder,lnLineCount)
lcItems = ALLTRIM(STRTRAN(lnLine,"Nombre total d'articles : ",""))
lnItem = VAL(lcItems) * 4
lnLine = ATLINE("Article commandé : ",lcorder)
FOR i = 1 to lnItem
  lcLine = MLINE(lcorder,lnLine+i)
  IF i = 1 then
    lcResult = lcLine
  ELSE
    lcResult = lcResult + CHR(13) + lcLine
  ENDIF
ENDFOR
REPLACE DETAILTEXT WITH ""
REPLACE DETAILTEXT WITH lcResult

The information that arrives from the email looks like this:

Article commandé : A very good album [BONUS] [IMPORT] [CD audio] U2
Réf. offre : 2345R345678
Votre réf.article : 123456789012
Quantité : 1


When the information is extracted from the MEMO field it looks like this:

[CD audio] U2
Réf. offre : 2345R345678
Votre réf.article : 123456789012
Quantité : 1


As you can see the first part A very good album [BONUS] [IMPORT] is missing

I would be grateful for any advice

Many thanks as always

Lee

Visual FoxPro Versions: 6 & 9
Operating System: Windows XP
 
I *THINK* this is a memo width issue.

I suspect that you never get the 'real' line one because you should be starting at line zero in your loop - and you just get the last part of the first line, if you follow me!

Try setting your memowidth to 250 and your loop to be

Code:
for i = 0 to lnItem

Regards

Griff
Keep [Smile]ing
 
Hi Griff

Strange one this. Tried your suggestion but unfortunately I got the same result. This has worked perfectly before when the version was in English (Before I get any complaints, I'm not blaming the French!)

Here is the version we used before (the only difference the 6 has been changed to 4....
Code:
GO mrecno
STORE "" TO lcorder
STORE EMAILBODY TO lcorder

lnLineCount = ATLINE('Total Item Count:',lcorder)
lnLine = MLINE(lcorder,lnLineCount)
lcItems = ALLTRIM(STRTRAN(lnLine,'Total Item Count:',""))

lnItem = VAL(lcItems) * 6

lnLine = ATLINE('PACKING SLIP:',lcorder)
FOR i = 1 to lnItem
  lcLine = MLINE(lcorder,lnLine+i)
    IF i = 1 then
      lcResult = lcLine
    ELSE
      lcResult = lcResult + CHR(13) + lcLine
    ENDIF    
ENDFOR
Any other suggestions?

Many thanks

Lee

Visual FoxPro Versions: 6 & 9
Operating System: Windows XP
 
Lee,

Can you email across a copy of the incoming file (version Francais version svp!)

foxprostuff at finedata dot com

And I'll have a play with it



Regards

Griff
Keep [Smile]ing
 
My thanks to GriffMG for resolving the issue with the following code:
Code:
set memowidth to 255
STORE [b]incoming[/b] TO lcorder && [b]MEMO Field name[/b]
lcResult = ""

lnLineCount = ATLINE("Nombre total d'articles : ",lcorder)

lnLine = MLINE(lcorder,lnLineCount)
lcItems = ALLTRIM(STRTRAN(lnLine,"Nombre total d'articles : ",""))
lnItem = VAL(lcItems) * 4
lnLine = ATLINE("Article commandé : ",lcorder)
FOR i = 0 to lnItem
  lcLine = MLINE(lcorder,lnLine+i)
  IF i = 0 then
    lcResult = lcLine
  ELSE
    lcResult = lcResult + CHR(13) + lcLine
  ENDIF
ENDFOR
REPLACE [b]outbound[/b] WITH ""  &&  [b]Field name[/b]
REPLACE outbound WITH lcResult
I am grateful to you

Kindest regards

Lee

Visual FoxPro Versions: 6 & 9
Operating System: Windows XP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top