FORMULA LANGUAGE
Examples: Locating and extracting substrings
1. (@Contains). This example returns True to R if Substring is anywhere in String. The search is case sensitive.
String := @Prompt([OkCancelEdit]; "String"; "Enter a string"; "");
Substring := @Prompt([OkCancelEdit]; "Substring"; "Enter a beginning substring"; "");
Yes := Substring + " is in " + String;
No := Substring + " is not in " + String;
R := @Contains(String; Substring);
@If(R; @Prompt([Ok]; "Yes"; Yes); @Prompt([Ok]; "No"; No))
2. (@Contains). This Example returns True to R if Substring1 or Substring2 is anywhere in String. The search is case sensitive.
String := @Prompt([OkCancelEdit]; "String"; "Enter a string"; "");
Substring1 := @Prompt([OkCancelEdit]; "Substring"; "Enter substring 1"; "");
Substring2 := @Prompt([OkCancelEdit]; "Substring"; "Enter substring 2"; "");
Yes := Substring1 + " or " + Substring2 + " is in " + String;
No := Substring1 + " and " + Substring2 + " are not in " + String;
R := @Contains(String; Substring1 : Substring2);
@If(R; @Prompt([Ok]; "Yes"; Yes); @Prompt([Ok]; "No"; No))
3. (@Left). This example returns to R the leftmost N characters in String.
String := @Prompt([OkCancelEdit]; "String"; "Enter a string"; "");
Number := @Prompt([OkCancelEdit]; "Number of characters"; "Enter a number of characters"; "");
N := @TextToNumber(Number);
R := @Left(String; N); @Prompt([Ok]; "Leftmost characters"; R)
4. (@Left). This example returns to R the characters left of Substring in String.
String := @Prompt([OkCancelEdit]; "String"; "Enter a string"; "");
Substring := @Prompt([OkCancelEdit]; "Substring"; "Enter a substring"; "");
R := @Left(String; Substring); @Prompt([Ok]; "Characters left of " + Substring; R)
5. (@RightBack, @Left). If the common name in the ComposedBy field is "Judith Woo," this formula calculates "Woo, Judith." @RightBack returns the last name and @Left returns the first name.
@RightBack(@Name([CN]; ComposedBy); " ") + ", " + @Left(@Name([CN]; ComposedBy); " ")
6. (@Middle). This example returns N characters to R from String starting after Substring.
String := @Prompt([OkCancelEdit]; "String"; "Enter a string"; "");
Substring := @Prompt([OkCancelEdit]; "Substring"; "Enter a substring"; "");
Number := @Prompt([OkCancelEdit]; "Number of Characters"; "Enter the number of characters"; "");
N := @TextToNumber(Number);
R := @Middle(String; Substring; N); @Prompt([Ok]; Number + " characters starting after " + Substring; R)
7. (@ReplaceSubstring). This agent example makes three substitutions in the textBody field of the affected documents. The third substitution is in case the second substitution causes a sentence to end with two periods.
FIELD textBody := @ReplaceSubstring(textBody; "Acme" : "mousetrap" : ".." ; "Acme, Inc." : "mouse detention device" : ".");
SELECT @All
8. (@Word). This example extracts word n from string s, using a space as the word separator.
s := @Prompt([OkCancelEdit]; "String"; "Enter a string of words"; "");
n := @Prompt([OkCancelEdit]; "Word"; "Enter the number of the word to extract"; "");
ss := @Word(s; " "; @TextToNumber(n)); @Prompt([Ok]; "Substring"; "Word " + n + " is \"" + ss + "\"")
9. (@FileDir) This example extracts "c:\market\data\" from the specified path name.
@FileDir("c:\market\data\europe.dat")
See Also
Locating and extracting substrings
Glossary
Feedback on
Help
or
Product Usability
?
Help on Help
All Help Contents
Glossary