Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
String manipulation question
Message
From
15/05/2011 03:22:48
Al Doman (Online)
M3 Enterprises Inc.
North Vancouver, British Columbia, Canada
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Miscellaneous
Thread ID:
01510681
Message ID:
01510693
Views:
47
>>>I'm using a list of keywords/bookmarks to update content in HTML and DOC files. Most of the keywords represent a single piece of data like a name or a value. However there are a few that are multiline values such as addresses which contain CHR(13) values.
>>>
>>>Spinning thru the list of bookmarks, the text substitution is performed using something like ....
>>>
>>>lcFindText = ALLTRIM(bookmarks.markname)
>>>lcReplaceText = EVALUATE(bookmarks.cField)
>>>ln = thisform.TXTextControl1.Find("&lcFindText",0,16)
>>>IF ln > 0
>>>     thisform.TXTextControl1.setfocus()
>>>     thisform.TXTextControl1.SelText="&lcReplaceText"
>>>ENDIF
>>>
>>>
>>>All is fine unless a value with a carriage return is contained in the replacement text. Have tried using [lcReplaceText] but it too errors (with "Command contains unrecognized phrase/keyword").
>>>
>>>Using the following avoids the error but those multi-line values are shown on a single line. Was trying to maintain those multiline bookmark values.
>>>
>>>thisform.TXTextControl1.SelText=(lcReplaceText)
>>>or...
>>>thisform.TXTextControl1.SelText=lcReplaceText
>>>
>>
>>Can you give typical examples of bookmarks.markname and bookmarks.cfield so we can more easily follow your logic?
>>
>>One potential workaround: if lcReplaceText contains CHR( 13 )s, temporarily STRTRAN() them to some other character (such as a high ASCII value), then STRTRAN() the text control back when the replacement is complete.
>
>The problematic, multi-line bookmarks evaluate a function call store in field CFIELD. Something like....
>
>MARKNAME = "CLIENTADDRESS"
>CFIELD = "FADDRESSCLIENT()"
>
>Function fAddressClient builds a multiline address value using CHR(13) after STREET and after CITY+", "+STATE
>
>Its odd in that using an older method where an HTML file is written to a string and then manipulated using something like "&lcReplaceText" works fine - it does not error and it honors the carriage returns. But i cannot use the FILETOSTR method in this case because it would result in losing all the formatting in the document (using it against RTF, DOC, and HTML files). Its starting to look like single mulitline bookmarks will have to be replaced with a STREET bookmark, and a CITYSTATE bookmark etc...

What kind of control is TXTextControl1? You're calling a .Find() method on it, the base VFP TextBox control does not have one (nor does a base EditBox). Does the control perhaps expect CRLF i.e. CHR( 13 ) + CHR( 10 ) instead of just CHR( 13 )?

Also, forgive me for having to ask, but are you 100% sure your lcReplaceText value you're getting back from the function call actually includes the CHR( 13 )s you expect? You could just pop up a MESSAGEBOX() displaying it, if they're there, the string will be broken across multiple lines.
Regards. Al

"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov

Neither a despot, nor a doormat, be

Every app wants to be a database app when it grows up
Previous
Reply
Map
View

Click here to load this message in the networking platform