Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
String manipulation question
Message
 
To
14/05/2011 15:41:36
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:
01510683
Views:
45
>>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...
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform