So I went and created the $CHAR wrapper utility function and got it to work; It wasn't *quite* as simple as I thought it would be (couldn't simply pass the whole string parameter through to $C, and need to remember to pass the param as a single quoted string) so I thought I would share in case someone else wanted to go this route :)
As before, review the instructions for Defining Custom Utility Functions and ensure the class extends Ens.Rule.FunctionSet
/// Wrapper to built-in objectscript function $CHAR./// Intended use = linebreaks ($C(13,10)) in routing rules (trace) where CRLF not easily accessible.ClassMethod Char(pCharString As%String) As%String
{
#dim outString,thisChar As%String = ""#dim numChars As%Integers numChars = $L(pCharString, ",")
//q:(numChars<2) $C(pCharString)if (numChars<2){ s outString = $C(pCharString) }
// more than one char, iterate over them to call $C and build outStringelse{
for n=1:1:numChars {
s thisCharCode = $P(pCharString, ",", n)
s outString = outString_$C(thisCharCode)
}
}
q outString
}I originally had the post-conditional quit for the single-char cases, but felt assigning and using outString was slightly better since it was more consistent coding. Though I wonder if the post-conditional is slightly more efficient... (very outside of my wheelhouse)
Then make sure to pass a single quoted string in the Routing Rule, but otherwise it's just like calling $C:
.png)
- Log in to post comments
.png)
.png)