How to preserving XML tag string formats in variables?

Keith Clarke keith.clarke at clarkeandclarke.co.uk
Sat May 21 11:59:02 EDT 2011


...ah, thanks for the insights Jim. I have happily been using the theHTMLText of fields to format text, set imagsource, etc. but hadn't made the connection that fields would automatically interpret any (some) tags. Obvious really - but everything is in hindsight! ;-)

I use TextWrangler but it seems that custom properties are also plain-text compatible - I'm using them to store the XML templates, into which I replace placeholder lines. So, to save having to deal with copy/paste or saving off to files for debugging, I now a cTest custom property on the stack that I set and refresh to check plain text, instead of using put or answer (as answer dialogues show the same 'interpretive' behaviour).

So, problem solved and another gem of wisdom stored away - many thanks!
Keith.. 

 
On 21 May 2011, at 16:08, Jim Ault wrote:

> On May 21, 2011, at 7:12 AM, Keith Clarke wrote:
> 
>> Hi folks,
>> I'm experimenting with scripting the building of a POST message. So, I'm creating a set of lines that take the form "<opening_tag_string>" & tVariable & "</closing_tag_string>" and using a repeat loop to build each component of each lines into a variable tMessage.
>> 
>> When I use 'add return & "opening–tag–string" & tVariable after tMessage' to create a partial XML node statement, I get what I would expect to see in the message box when I put tMessage.
>> 
>> However, when I attempt to 'add return & "opening–tag–string" & tVariable & "closing_tag_string" after tMessage' to create the full statement, the opening and closing tag strings disappear and I'm left with just the list of tVariable in tMessage.
>> 
>> I guess there is some wrapping or encoding that I need to apply to the tag strings to preserve them inside the variable, but I can't seem to find anything in the docs or the lists - I'm obviously using the wrong search terms.
>> 
>> Any clues gratefully received.
> 
> You want to study the page in the dictionary
>    HTMLtext
> 
> There are a limited number of tags that livecode recognizes and thus allows formatting of fields much like the early web pages.
> 
> The message box is simply a field in a stack, and
> when debugging HTML and other code/encoded/decoded strings, the message box is a very poor tool.
> 
> Save yourself some headaches and put the text strings into a good text processor that won't automatically do things like change line endings from Unix to Windows, etc.  I use BBEdit, others use TextWrangler, and a search of the archives will show others.
> 
> Further caution is needed if using UTF8 or uinicode, since character sets across platforms, servers, and software packages can create hard-to-detect bugs.
> 
> 
> Jim Ault
> Las Vegas





More information about the use-livecode mailing list