Have you ever written a TurboIntegrator script and wanted to check the first character of a value to see if it was a number or a letter? Have you ever needed to insert a single or double quote into a string without “breaking” your code? Have you ever wanted to easily convert a lower case letter into an upper case letter? All of this can be done by referencing the ASCII code associated with the character.
ASCII is an abbreviation for American Standard Code for Information Interchange and is used as a standard for electronic communication. ASCII codes represent text for computers. Every key on your keyboard has a defined code number. Tables associated with these codes can be found via a simple Internet search.
There are two functions in IBM Planning Analytics / TM1 that allow you to reference the ASCII code:
- CHAR returns the character associated with a numeric ASCII code. For example, CHAR(76) returns a capital L.
- CODE returns the numeric ASCII code associated with a character. For example, CODE(‘Lee’, 1) returns 67 since the first character is a capital L.
These functions can be used in conjunction with other functions and logic to perform various tasks:
- If the first character of a value has an ASCII code in the range of 48-57, then the value is a number.
- If the first character of a value does not have an ASCII code in the range of 48-57, 65-90, or 97-122 then the value is not a number or a letter.
- ASCII code 39 is a single quote and ASCII code 34 is a double quote.
- All capital and lowercase codes have the same ASCII code value difference, so you can add or subtract 32 to convert between uppercase and lowercase.
These functions allow you to check and manipulate data without having to ignore the rules of TurboIntegrator coding.
IBM Planning Analytics, powered by TM1, is full of new features and functionality. Need advice? Our team here at Revelwood can help. Contact us for more information at firstname.lastname@example.org. We post new Planning Analytics Tips & Tricks weekly in our Knowledge Center and in newsletters.