Pseudocode Built-in functions
In each function, if the function call is not properly formed, the function returns an error.
MODULUS(x : INTEGER, y : INTEGER) RETURNS INTEGER
returns the remainder when x is divided by y using integer arithmetic.
Example: MODULUS(5, 2) returns 1
INT(x : REAL) RETURNS INTEGER
returns the integer part of x.
Example: INT(27.5415) returns 27
LENGTH(ThisString : STRING) RETURNS INTEGER
returns the integer value representing the length of string ThisString.
Example: LENGTH("Happy Days") returns 10
LEFT(ThisString : STRING, x : INTEGER) RETURNS STRING
returns leftmost x characters from ThisString.
Example: LEFT("ABCDEFGH", 3) returns string "ABC"
RIGHT(ThisString: STRING, x : INTEGER) RETURNS STRING
returns rightmost x characters from ThisString.
Example: RIGHT("ABCDEFGH", 3) returns string "FGH"
TONUM(ThisString : STRING) RETURNS INTEGER
returns a numeric value equivalent to ThisString.
Example: TONUM("1201") returns integer value 1201
MID(ThisString : STRING, x : INTEGER, y : INTEGER) RETURNS STRING
returns string of length y starting at position x from ThisString.
Example: MID("ABCDEFGH", 2, 3) returns string "BCD"
LCASE(ThisChar : CHAR) RETURNS CHAR
returns the character value representing the lower case equivalent of ThisChar.
If ThisChar is not an upper-case alphabetic character then it is returned unchanged.
Example: LCASE('W') returns 'w'
1
MOD(ThisNum : INTEGER, ThisDiv : INTEGER) RETURNS INTEGER
returns the integer value representing the remainder when ThisNum is divided by ThisDiv.
Example: MOD(10,3) returns 1
DIV(ThisNum : INTEGER, ThisDiv : INTEGER) RETURNS INTEGER
returns the integer value representing the whole number part of the result when ThisNum is divided
by ThisDiv.
Example: DIV(10,3) returns 3
ONECHAR(ThisString : STRING, Position : INTEGER) RETURNS CHAR
returns the single character at position Position (counting from the start of the string with
value 1) from the string ThisString.
For example: ONECHAR("New York", 5) returns 'Y'
CHARACTERCOUNT(ThisString : STRING) RETURNS INTEGER
returns the number of characters in ThisString.
For example: CHARACTERCOUNT("New York") returns 8
ASC(ThisCharacter : CHAR) RETURNS INTEGER
returns an integer which is the ASCII character code for the character ThisCharacter.
For example: ASC('A') returns integer 65
SUBSTR(ThisString : STRING, Value1 : INTEGER, Value2 : INTEGER) RETURNS
STRING
returns a sub-string from within ThisString.
Value1 is the start index position (counting from the left, starting with 1).
Value2 is the final index position.
For example: SUBSTR("art nouveau", 5, 11) returns "nouveau"
TONUM(ThisString : STRING) RETURNS INTEGER or REAL
returns the integer or real equivalent of the string ThisString.
For example: TONUM("502") returns the integer 502
TONUM("56.36") returns the real number 56.36
2
CHR(Value : INTEGER) RETURNS CHAR
returns the character that ASCII code number Value represents.
For example: CHR(65) returns 'A'
RND() RETURNS REAL
returns a random number in the range 0 to 0.99999
For example: RND() returns 0.67351
UCASE(ThisChar : CHAR) RETURNS CHAR
returns the character value representing the upper case equivalent of ThisChar.
If ThisChar is not a lower case alphabetic character then it is returned unchanged.
Example: UCASE('h') returns 'H'
Errors
For any function, if the program calls the function incorrectly, the function returns an error.
Operators (pseudocode)
Operator Description
Concatenates (joins) two strings.
&
Example: "Summer" & " " & "Pudding" produces "Summer Pudding"
Performs a logical AND on two Boolean values.
AND
Example: TRUE AND FALSE produces FALSE
Performs a logical OR on two Boolean values.
OR
Example: TRUE OR FALSE produces TRUE
Concatenation operator
& – Concatenates two expressions of STRING or CHAR data type.
For example: "South" & " " & "Pole" produces "South Pole"
'B' & "000654" produces "B000654"