![]() ![]() |
|
Help for Process Engine Reference | |
Search | Index | |
![]() |
|
![]() |
![]() |
![]() |
String functionsFollowing are brief descriptions of the functions that apply to string values. For more detailed information about a specific function (such as usage and syntax), click the function name.
hexThis function translates a string literal of hexadecimal character codes into an ASCII string. The hex function can express any character, although you generally use it for characters that do not have ASCII representations, such as tabs. Every two hex digits represent one character in the resulting string. An odd number of hex characters in the string literal results in an error. Use the following syntax: hex (hex_codes) where hex_codes is a string literal containing the hex code for a character or a series of characters. The following example returns the string "abc" because 61, 62, and 63 are the hexadecimal codes for those characters. hex ("616263") translateThis function creates a new string by replacing the characters in one string with the characters you specify. The translate function is useful for encoding characters. Use the following syntax: translate (source_string, search_string, replace_string)
The search-and-replace occurs on a per-character basis. If the search string is "abc" and the replace string is "def", the function translates "a" to "d", "b" to "e", and "c" to "f" in the newly created string. For example, with the following values, source_string contains "*123-#44-!999" search_string contains "#*!-" replace_string contains "XYZ&" the function outputs the following new string: Y123&X44&Z999 Note that the contents of the source string, the search string, and the replace string do not change. TIP To search for and replace an entire substring rather than individual characters, use the substitute function. The following example uses the translate function to convert a string from European number format to American number format. translate (str, ".,", ",.") lower, upperThese functions convert all the characters in a string to lower- or upper- case, respectively. Use the following syntax: lower (string_exp) upper (string_exp) where string_exp is the string expression to convert.
in_setThis function compares two strings, returning a boolean value of true if every character in the first string is contained somewhere in the second string. If the first string contains at least one character that is not also contained in the second string, the function returns a value of false. The characters need not appear in the same order in both strings; also, the second string can contain additional characters. Use the following syntax: in_set (subset_string, superset_string)
In the following example, in_set (name, "abcdefghijklmnopqrstuvwxyz") the function returns true if name = "jim" but false if name = "Fido" or name = "a.b". lenThis function computes the actual (not the declared) length of a string expression. It gives the total number of characters, including spaces, in the expression. Use the following syntax: len (string_expr) where string_expr is a string expression whose length is to be calculated. In the following example, the length returned is 15. Note that the enclosing quotes are not counted as characters. len ("Hamilton Burger") repeatThis function creates a string by repeating a given string a specified number of times. Use the following syntax: repeat (string_expr, repeat_num)
The following example outputs the string abcdabcdabcdabcdabcd. repeat ("abcd", 5) strlocA substring is a part of a source string; it can be less than or equal to the length of the source string. For example, "Good", "Morn", "od Morni," and "Good Morni" are all substrings of "Good Morning". Use the strloc function to find out where a particular substring occurs in a source string. This function returns the starting character position of the substring in the source string. If the substring can be found in the source string more than once, the function returns the starting position of its first occurrence. If the substring is not found, or if the substring is longer than the source string, the function returns zero. Use the following syntax: strloc (source_string, sub_string)
This example returns the value 6, because the substring begins in position 6 of the source string. strloc ("Good Morning", "Morning") substrThis function extracts a substring from a source string, thereby creating a new string. You specify the source string and the character position where the extraction begins. In addition, you can optionally supply the number of characters to be extracted; if you do not provide this information, the extraction stops at the end of the source string. Use the following syntax: substr (source_string, start_pos {, length})
The following example returns the string "Morning". Note that the enclosing quotes do not count as part of the string. substr ("Good Morning!", 6, 7) This function can also extract zero-length strings (strings with no characters between the quotes, for example,"") at a position of one more than the length of a string. This usage is helpful for algorithms which have zero-length strings as an edge condition. You can extract characters from positions 1 through the last character of the string +1; so, positions 1 and the length of the string +1 are edge conditions. Runtime errors occur if:
strinsThis function inserts one string into another string, thereby creating a new string. The values of the source string and insertion string do not change. Use the following syntax: strins (source_string, insert_string, start_pos)
In the example below, let’s say that insert_str = "Mr. Jones, " and that source_str = "Good morning, what a lovely day." strins (source_str, insert_str, 15) With the above-specified values, the function returns the following string: Good morning, Mr. Jones, what a lovely day. substituteThis function creates a new string by replacing one substring with another inside a specified source string. Use the following syntax: substitute (source_string, unwanted_string, replacement_string)
In the following example, every occurrence of "abc" within TestString is replaced with "wxyz". The replacement occurs left-to-right. substitute (TestString, "abc", "wxyz") If TestString = "abcdabcd", the function returns the following new string: wxyzdwxyzd Note that the contents of the source string, the unwanted string, and the replacement string do not change. TIP To search for and replace individual characters rather than a substring, use the translate function. ltrim, rtrim, and trimThese functions create a new string by copying an existing source string and deleting blanks or specified characters from the beginning (ltrim), end (rtrim), or both ends (trim) of the new string. In all cases, the source string remains unchanged. Use the following syntax for all three functions: ltrim (string_expr{, trim_char}opt) rtrim (string_expr{, trim_char}opt) trim (string_expr{, trim_char}opt)
The following example deletes all leading blanks from LastName. In the example, LastName = " Smith" and the returned new string is "Smith". ltrim (LastName) The example below deletes the character "&" from the end of the string called Status. If Status = "OpenXY&Z&&&&", the returned new string is "OpenXY&Z". rtrim (Status, "&") The following example deletes all trailing digits from AccountName. rtrim (AccountName, "0123456789") is_numberThis function determines whether the specified string expression evaluates to a float or integer value. The is_number function returns the boolean value true if the entire string (not just a substring) evaluates to a float or integer and false otherwise. Use the following syntax: is_number (expr) where expr is a string expression. The following three examples return true, false, and false, respectively. is_number ("123.4") is_number ("no") is_number ("abc63j") is_timeThis function determines whether the specified string expression evaluates to a time value of a specified format. The is_time function returns the boolean value true if the entire string (not just a substring) evaluates to a time that is formatted as specified; otherwise, the function returns a value of false. Use the following syntax: is_time (str_expr, date_time_mask)
Following are two examples—the first example returns false, the second example returns true. In both examples, the convert function is used to convert the string expressions to the time data type so that the is_time function can be evaluated. is_time ("nov121995", "mm/dd/yyyy") is_time ("11/12/1995", "mm/dd/yyyy") timetostringThis function converts a time expression to a string expression, using the format you specify. Use the following syntax: timetostring (time_expr, date_time_mask)
The following example converts the system time to a string. The string is formatted using the specified date/time mask. timetostring (systemtime(), "mm/dd/yyyy hh:tt:ss am") In the above example, if systemtime() is equivalent to July 1, 1985 at 6 seconds past 12:45 p.m., the string output is: 7/1/1985 12:45:06 pm See information about the systemtime() function. stringtotimeThis function converts strings to times, using the format you specify. Use the following syntax: stringtotime (string_expr, date_time_mask)
In the following example, HostTime is a string variable. stringtotime (HostTime, "mon. dd, yyyy hh:mm:ss am") If HostTime = "Jul. 1, 1985 12:45:06 pm", then the resulting output is the time value equivalent to July 1, 1985 at 6 seconds past 12:45 p.m.
|
![]() |
|
![]() |
|