rtecall("escstr") function

A RAD function that precedes special characters in a string with an escape character. This function is rarely needed. The only situation in which a string needs the escape characters added is when that string is to be fed back into ITSMA Service Management. Service Management treats any data between quotes as a string. If the data contains a quote, then that quote must be escaped with a backslash escape character (\) to ensure that the quote is treated as data instead of the end of the string. Since the backslash is used as the escape character, any occurrence of a backslash in the data must also be escaped.

An example of when this function might be needed is when a RAD program is constructing a query to retrieve a record based on data from another record. In this case, the contact name in an incident retrieves the contact information from the contacts table. The RAD program might construct a query as follows:

$L.query = "name="+contact.name in $file

This query will not function properly if the contact.name from $file contains a quote or a backslash character because these characters are not properly escaped and will cause the parse of the query to end prematurely. The correct example is as follows:

 $L.temp = contact.name in $file
 $L.ret = rtecall("escstr",$L.rc,$L.temp)
 $L.query="name="+$L.temp

Function

rtecall("escstr")

Format

rtecall($L.fnc.name, $L.rc, $L.str)

Parameters

The following parameters are valid for the rtecall("escstr") function:

Parameter Data type Description
$L.fnc.name String Name of the sub-function to call, in this case "escstr".
$L.rc Number Provides a more detailed return code.
$L.str String The string to be modified.

Example

Before the call to "escstr", $L.str contains c:\dir\sub.

$L.rc=0
$L.ret=rtecall("escstr", $L.rc, $L.str)

After the rtecall, $L.str contains the following string: c:\\dir\\sub. The backslash escape character (\) is now inserted in front of the existing backslash.