Clarion Syntax and Formatting
Formatting and Special Functions
ALL
ALL(string, length)
Function: The ALL procedure returns a string containing repetitions of the character sequence string.
-
string - A string expression containing the character sequence to be repeated.
-
length - The length of the return string. If omitted the length of the return string is 255 characters.
Example: ALL('h',10)
Returns: hhhhhhhhhh
SUB
SUB(string,position,length)
Function: Returns a portion of a string.
-
string - A string constant, variable or expression.
-
position - A integer constant, variable, or expression. If positive, it points to a character position relative to the beginning of the string. If negative, it points to the character position relative to the end of the string (i.e., a position value of -3 points to a position 3 characters from the end of the string).
-
length - A numeric constant, variable, or expression of number of characters to return.
Example: To only print the first letter of someone's first name, use the following: SUB(RES:FIRSTNAME,1,1)
Returns: Will print "S" instead of "Samuel"
SQL
SQL(Valid Clarion Formula that evaluates to a valid SQL Statement)
Function: Executes an SQL statement
Example:
SQL('SELECT COUNT(*) FROM RESERVE WHERE CONFNUM = ' & RES:CONFNUM)
For more information, see here.
LEFT
LEFT(string)
Function: The LEFT procedure returns a left justified string. Leading spaces are removed from the string.
- If you want to remove leading spaces from any field used in the database, use the LEFT function. It can be used in combination with any other function.
Example: 'The deposit is ' & LEFT(FORMAT(RES:DEPOSITAMT,@N-11.2))
Returns: "The deposit is $10.00" instead of "The deposit is $10.00"
CLIP
CLIP(string)
Function: Removes trailing spaces.
- The CLIP procedure removes trailing spaces from a string. The return string is a substring with no trailing spaces. CLIP is frequently used with the concatenation operator in string expressions using STRING data types. If you want to remove trailing spaces from any field used in the database, use the CLIP function. It can be used in combination with any other function.
Example: CLIP(RES:CITY) & ', ' & RES:STATE
Returns: "Hartford, CT" instead of "Hartford , CT"
FORMAT
FORMAT(value, picture)
Function: Returns a formatted numeric string.
-
value - A numeric expression for the value to be formatted. (a roomMaster database field)
-
picture - A value containing a value picture token. (see Date, Time and Currency Pictures)
Example: FORMAT(RES:CHECKIN-30,@D04)
Returns: December 28, 2000
Example: FORMAT(RES:CHECKIN-30,@D017)
Returns: Will print the date in the format that you have set in your computer's regional settings
For more information on valid format pictures, click here.
Function Combination
You can mix and match and use all of the functions together like in this example where we suppress all but the remaining 4 numbers in a guests credit card.
Example ALL('X',LEN(CLIP(RES:GTD_NUMBER)) - 4) & SUB(CLIP(RES:GTD_NUMBER),-4,4)
Returns Will return "XXXXXXXXXXXX1234"