Text Functions

Top  Previous  Next

Fathom Reference > Fathom Operators, Functions, and Units > Text Functions

beginsWith(stringToLookIn,

stringToFind)

Takes two arguments and returns true if the first begins with the second. For example, beginsWith(LastName, "Mc") will return true for “McBride” and false for “Binker.”

charToNum(aString)

Returns the ASCII code for the first character in the string argument. For example, charToNum("Hello") is 72 because the letter H has the ASCII code of 72. Note that even numeric arguments will return something for this function because the numeric result is first converted to a string. For example, charToNum(1/2) is 48 because 48 is the ASCII code for the 0 of 0.5.

concat(string1, string2,

... string10)

Takes up to ten arguments and returns a string. For example, if a case has the value “Denise” for the attribute Name and the value “likes dogs” for the attribute Hobby, then concat(Name, " ", Hobby) gives “Denise likes dogs.” The arguments can be numeric or strings.

Note: You have to include an argument for the space to get a space in the caption.

endsWith(stringToLookIn,

stringToFind)

Takes two arguments and returns true if the first ends with the second. For example, endsWith(LastName, "er") returns true for “Binker” and false for “McBride.”

findString(stringToLookIn,

stringToFind, start)

Takes three arguments, returning the position of stringToFind in stringToFind starting from start. The first character of stringToLookIn is numbered 1. Returns 0 if stringToFind is not found.

The third argument need not be present and defaults to 1.

Example: findString("mathematics", "the") returns 1, but findString("mathematics", "the", 2) returns 6.

includes(stringToLookIn,

stringToFind)

Takes two arguments and returns true if the second argument is a substring of the first (also treated as a string): includes("the", "he") returns true; includes("dancing", "joy") returns false; includes(1234, 23) returns true.

leftString(aString, numChars)

Takes two arguments, the first treated as a string with the second an integer ≥ 0. Returns a string made of the first numChars characters of the string.

Example: leftString("Fathom this", 6) returns “Fathom”.

lowerCase(aString)

Returns the string that results from converting each character of its string argument to lower case.

Example: lowerCase("John Doe") returns "john doe".

midString(aString,

start, numChars)

Takes three arguments, the first treated as a string, with the remaining two integers ≥ 0. Returns a string made of the numChars characters starting at start. If the third argument is missing, the result will be the characters from start to the end of the string.

Example: midString("thermometer", 5, 3) returns “mom” and midString("thermometer", 7) returns “meter”.

numToChar(aNumber)

Takes an integer between 0 and 255 treated as an ASCII code and returns the letter corresponding to that code for the computer on which Fathom is running.

Examples: numToChar(65) returns “A” and numToChar(126) returns “~”.

repeatString(aString,

numRepetitions)

Takes two arguments, the first a string and the second an integer ≥ 0. Returns the result of concatenating aString numRepetitions times.

Example: repeatString("#&", 4) returns “#&#&#&#&”.

replaceChars(aString,

start, numChars, substituteString)

Takes four arguments. The first is the original string. The second is an integer > 0 specifying the starting location for the substitution. The third is the number of characters to be replaced, and the last is the string that is to be substituted. If numChars is 0, substituteString is inserted.

Example: replaceChars("computer", 3, 4, "nfus") gives “confuser”.

replaceString(aString,

stringToFind, substituteString)

Takes three string arguments and substitutes the third for all occurrences of the second in the first.

Example:
replaceString("12:30:45", ":", " and ") returns “12 and 30 and 45”.

rightString(aString, numChars)

The first argument is a string, and the second is an integer ≥ 0. Returns the rightmost numChars characters of aString.

Example: rightString("football", 4) returns “ball”.

stringLength(aString)

Returns the number of characters in the string representation of the argument.

Examples: stringLength("Fathom") gives 6. stringLength(321) gives 3.

stringToNumber(aString)

Returns the first number in the given string representation.

Example: stringToNumber("Jen is 18 years old") gives 18.

upperCase(aString)

Returns the string that results from converting each character of its string argument to upper case.

Example: upperCase("Jane Doe") returns "JANE DOE".