Forum

HomeHomeCoreCoreGeneralGeneralFORMATTING: replace characters in ACTION variableFORMATTING: replace characters in ACTION variable
Previous
 
Next
New Post
4/19/2012 10:31 AM
 

Hi,

 

I have an action variable [PDFoutput,ACTION] that contains some HTML output (as a result from multiple queries).

There are some characters that I need to replace to get a correct output. This is the sequence of actions that tried without success:

 

- assignment: [PDFoutput,ACTION] = ... HTML content ... (generated by multiple queries)

- assignment: [PDFoutput,ACTION] = [FORMAT, [PDFoutput,ACTION], {REPLACE:x,y}]

 

This just prepends "[FORMAT," and appends ',{REPLACE:x,y}]' to the content of the [PDFoutput,ACTION] variable, instead of applying the formatter.

 

All suggestions welcome!

 

Thanks,

Ken

New Post
4/19/2012 11:12 AM
 

Ken,

 

You might try the replace as a COALESCE.. and quotes around your replace

 

[COALESCE,PDFoutput,ACTION,{REPLACE:"x","y"}]

 

New Post
4/19/2012 12:20 PM
 

Hi Brad,

 

thanks for your suggestion. Unfortunately, the COALESCE tag seems to have no effect at all, whatever I try.

The only plus is that the COALESCE tag is not prepended / appended as it did with the FORMAT code. So it seems to read the COALESCE tag correctly, it just does not executes the REPLACE formatter.

I tried double quotes, no quotes, ascii codes CHAR(xxx) etc, but they all have zero effect

 

New ideas welcome!

 

Thanks,

Ken

New Post
4/19/2012 12:42 PM
 

One of the problems with [FORMAT, [PDFoutput,ACTION], {REPLACE:x,y}] is that OWS evaluates tags inside out.  That means that first it evaluates the [PDFoutput,Action] and then stuffs the results back into the FORMAT tag and tries to evaluate that again.  If your action contains commas, double quotes, unclosed square brackets or unclosed curly braces it will break the FORMAT tag.  For example, if the PDFoutput Action contains "one, two, three" without quotes, OWS turns the above expression into: [FORMAT, one, two, three , {REPLACE:x,y}] which OWS then tries to evaluate and fails because there are too many commas.

 

Instead, try this:  [FORMAT, PDFoutput, ACTION, {REPLACE:x,y}] - note that we dropped the extra square brackets.

 

Now, about COALESCE: the problem with the REPLACE formatter and COALESCE is that it, by nature, contains a comma.  This also confuses OWS because COALESCE sees [COALESCE,PDFoutput,ACTION,{REPLACE:"x","y"}] as a COALESCE tag with 4 arguments:

  • PDFoutput
  • ACTION
  • {REPLACE:"x"
  • "y"}

note how it splits the replace formatter into two arguments.  The key is to wrap the entire REPLACE formatter in double quotes (and I'd drop the quotes around X and Y because, in this case, they will only cause trouble.

 

This makes the workable expression:  [COALESCE,PDFoutput,ACTION,"{REPLACE:x,y}"]

 

Either way should work fine UNLESS your X or Y above contains one of the "special" OWS characters like a comma, double quote, square bracket or curly brace.

 

Also: I always ALWAYS ALWAYS use a firewall character (vertical pipe character) just inside the square bracket.  Without this, if your PDFoutput happens to contain a valid / unescaped OWS expression, it will evaluate the expression when it renders.  (If your data contains [ModuleID,System] for instance, you will see the number on the screen rather than the expression.)  This makes our completed and firewalled expressions either:

[|FORMAT, PDFoutput, ACTION, {REPLACE:x,y}]

or

[|COALESCE,PDFoutput,ACTION,"{REPLACE:x,y}"]

 

Hope this helps.

New Post
4/19/2012 12:43 PM
 

Hi again,

 

I found this old topic about the REPLACE formatter withing COALESCE:

http://openwebstudio.com/Community/Forums/tabid/55/forumid/1/postid/23510/scope/posts/Default.aspx

 

It was even my own thread!!!

Anyway, when using the REPLACE formatter inside COALESCE, the formatter needs to be inside double quotes like this:

 

[COALESCE,PDFoutput, ACTION,"{REPLACE:x,y}"]

 

Thanks for your patience with me :-)

Ken

Previous
 
Next
HomeHomeCoreCoreGeneralGeneralFORMATTING: replace characters in ACTION variableFORMATTING: replace characters in ACTION variable


 

New York, NY • Baltimore, MD • Vienna, VA • St. Louis, MO • Seattle, WA • info@openwebstudio.com

Bookmark & Share Bookmark and Share