My last article developed the idea of conditional behaviour and compound statements. In this article, I will have another look at Strings, regular expressions and other objects.
A String is a sequence of letters and numbers. And this supports the use of Unicode.
Strings are indicated by using 'quotation characters'
‘And Single Quotes’
You can nesting quotes in strings. Below is a typical example being defined. This is a 'where clause' that would be passed to the database from within a script in Sage CRM.
strArg = “comp_type=‘Competitor’”;
Note: The order of the nesting of the strings is important because SQL allows strings only to be in single quotes.
Consider the examples below
Escapes (use \ in a string to change the meaning of character)
\’ = Apostrophe doesn’t end string e.g. O’clock
\”= Double quote doesn’t end string
\\= Allows single backslash character in pathnames etc.
+ symbol add strings together
A regular expression is an object that describes a pattern of characters.
Regular expressions are used to perform pattern-matching and "search-and-replace" functions on text.
Below is a script example that could be used in a Case Summary screen within Sage CRM.
A variable strDescription has been created. This is the value of the case description field. I have used the client side API here to read the value.
I then created a Create regular expression object using the first syntax
I then found a match within the string, which is returned and if there is a result (so the result is not null and is implicitly true) then I can write a message on the screen using the API.
My next article will finish this series by looking at Arrays, Functions, and techniques for processing objects.
The links to the other articles in the series are listed below
- The syntax of the language and the different objects available.
- The objects that are available within the Browser.
- Binding a script to an event.
- Conditional behaviour and compound statements.
- Another look at Strings, regular expressions and other objects.
- Arrays, Functions, and techniques for processing objects.