Text Functions

Previous  Terms  Next

TinkerPlots_logoV2-rgb


Text Functions

beginsWith

beginsWith(stringToLookIn, stringToFind) takes two arguments and returns true if the first begins with the second.

Example: beginsWith(LastName, "Mc") will return true for "McBride" and false for "Binker."

charToNum

charToNum(aString) returns the ASCII code for the first character in the string argument.

Example: charToNum("Hello") is 72 because the letter H has the ASCII code of 72.

Note: 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

concat(string1, string2, ... string10) takes up to ten arguments and returns a string.

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

endsWith(stringToLookIn, stringToFind) takes two arguments and returns true if the first ends with the second.

Example: endsWith(LastName, "er") returns true for "Binker" and false for "McBride."

findString

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

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

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".

midString

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

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 TinkerPlots is running.

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

repeatString

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

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

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

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

stringLength(aString) returns the number of characters in the string representation of the argument.

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

stringToNumber

stringToNumber(aString) returns the first number in the given string representation.

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

 


TinkerPlots Help

© 2012 Clifford Konold and Craig D. Miller