Identifier   |  Description   | 
 Write or Writeln   |  Prints values to the screen with or without a line break   | 
| var X : Integer; begin X := 2; Writeln('Answer to life, ','the universe, and everything = ',4,X); //Output: Answer to life, the universe, and everything = 42 Readln; end.  | |
 Readln   |  Reads in user-input values   | 
| var X : Integer; begin Write('Input an integer: '); Readln(X); //Waits for user input end.  | |
 Length   |  Given a variable, returns the current size of a dynamic variable (like a string)   | 
| var X : Integer; begin Writeln(Length('test')); // Output: 4 Readln; end.  | |
 SizeOf   |  Given a variable, returns the actual size in memory of a variable   | 
| var C : Char; I : Integer; begin Writeln(SizeOf(C)); // Output: 1 // A char variable takes up 1 byte in memory. Writeln(SizeOf(I)); // Output: 4 // An integer variable takes up 4 bytes in memory. Writeln(SizeOf(Char)); // Output: 1 Writeln(SizeOf(Integer)); // Output: 4 Readln; end.  | |
 Chr   |  Given an ASCII code (value between 0 and 255) returns the character represented by that code   | 
| begin Writeln(Chr(65)); // Output: A Writeln(Chr(66)); // Output: B Writeln(Chr(67)); // Output: C Writeln(Chr(48)); // Output: 0 Writeln(Chr(49)); // Output: 1 Writeln(Chr(50)); // Output: 2 Readln; end.  | |
 Ord   |  Returns the ordinal value of an "ordered" type (such as an ASCII character)   | 
| begin Writeln(Ord('A')); // Output: 65 Writeln(Ord('B')); // Output: 66 Writeln(Ord('C')); // Output: 67 Writeln(Ord('0')); // Output: 48 Writeln(Ord('1')); // Output: 49 Writeln(Ord('2')); // Output: 50 Readln; end.  | |
 Random or Random(X)   |  Random returns a random real number between 0 and 1. Random(X) returns a random integer from 0 to X. Both random numbers are drawn from a uniform distribution.   | 
| begin Randomize; Writeln(Random); // Output: Who knows... it's random (though it will be between 0 and 1) Writeln(Random(10)); // Output will be an integer between 0 and 10 Writeln(Random(100)); // Output will be an integer between 0 and 100 Writeln(20+Random(10)); // Output will be an integer between 20 and 30 Readln; end.  | |
 Subroutine   |  Description   | 
 Format   |  Formats any number of values into a string according to format specifiers given in FormatStr.   | 
| {$APPTYPE CONSOLE} program Workspace; uses SysUtils; var X : Real; begin X := 3.14159; Writeln(X); // Output: 3.14159000000000E+000 Writeln(Format('%.5f',[X])); // Output: 3.14159 // The percent sign % is called a format specifier. %.5f means a fixed number // of 5 decimal places. Writeln(Format('PI = %.5g',[X])); // Output: PI = 3.14159 // Format strings can be composed of any combination of format specifiers and // regular characters. Writeln(Format('%d%%',[50])); // Output: 50% // %d is the integer format specifier. Double percent %% escapes the format // specifier and returns a single percent sign. Write(Format('%5d',[52])); Writeln(Format('%5d',[4])); Write(Format('%5g',[11.7])); Writeln(Format('%5d',[12])); // Output: 52 5 // Output: 11.7 12 // Any number without a decimal point between the % and some letter is // considered a width specifier and ensures that numbers with fewer // digits than the specified width are padded with spaces Writeln(Format('%.5d',[50])); // Output: 00050 // Since integers cannot have decimals, the .5 in this expression is a padding // specifier. It ensures that there are 5 digits in the output by padding // the output with 0's. Writeln(Format('%.5g',[X])); // Output: 3.1415 // %.5g means general formatting with 5 significant figures. Note the // difference in %.5g and %.5f. 3.14159 has 6 significant figures and 5 // digits after the decimal point. %.5g drops the last digit because only 5 // significant figures were requested. Writeln(Format('%.5g %.3d %s',[X,5,'somestr'])); // Output: 3.1415 005 somestr // Any number of values can be combined using format strings but the format // specifier must be appropriate for the type of the value used. For // example, the string formatter %s is not appropriate for the variable X // since it is a number. Readln; end.  | |
 CompareStr, Copy, Delete, Insert, Lowercase, Uppercase, Pos, StringOfChar   |  String handling routines (see example for more info).   | 
| {$APPTYPE CONSOLE} program Workspace; uses SysUtils; var Str : String; begin // Note that these string-handling routines are almost universal in all // programming languages, but they often go by slightly different names // depending on the language. // Usage: CompareStr(Str1,Str2) Writeln(CompareStr('test','test2')); // Output: 0 // CompareStr returns -1 if the first string is less than the second (in terms // of alphabetical order), 0 if they are equal, or 1 if the first is greater // than the second (Note that you can also use >, =, and < operators // on strings // Usage: Copy(Str,Index,Count) Writeln(Copy('test',2,2)); // Output: es // Copy copies characters from a string starting with Index and continuing for // Count characters. Strings in Object Pascal are 1-indexed which means 1 is // the first character, 2 is the second, and so on // Usage: Delete(Str,Index,Count) Str := 'test'; Delete(Str,2,2); Writeln(Str); // Output: tt // Delete removes characters from a string (it performs the operation on the // actual variable and does not create a new string like copy) // Usage: Insert(NewStr,Str,Index) Insert('es',Str,2); Writeln(Str); // Output: test // Insert places the string NewStr into Str at a certain position. // Usage: Lowercase(Str) Writeln(Lowercase('Test')); // Output: test // Usage: Uppercase(Str) Writeln(Uppercase('Test')); // Output: TEST // Usage: Pos(SubStr,Str) Writeln(Pos('st','test')); // Output: 3 Writeln(Pos('sa','test')) // Output: 0 // Returns the index of the first substring in a larger string. If the // substring cannot be found it returns 0. // Usage: StringOfChar(SomeChar,Count) Writeln(StringOfChar('A',5)); // Output: AAAAA // Creates a string of repeating characters. Readln; end.  | |
 IntToStr, Val   |  String-number conversion routines   | 
| {$APPTYPE CONSOLE} program Workspace; uses SysUtils; var X,Code : Integer; Num : Real; Str : String; begin X := 5; Str := IntToStr(X)+' = Five'; Writeln(Str); // Output: 5 = Five Str := '42'; Val(Str,X,Code); Writeln(Str+'1'); // Output: 421 Writeln(X+1); // Output: 43 // Val converts string into an integer and stores it in X. // The expression Str+'1' concatenates a string while the expression X+1 is // arithmetic since X is an integer. Str := '4.2'; Val(Str,Num,Code); Readln; end.  | |
 Date, Time, Now, DateTimeToStr, DateToStr, TimeToStr, DayOfWeek, DecodeDate, DecodeTime, EncodeDate, EncodeTime, FormatDateTime  |  Date/time routines   | 
 Subroutine   |  Usage   |  Description   | 
 Abs   |  Abs(X)   |  Returns the absolute value of a number:   .  | 
 Ceil   |  Ceil(X)   |  Rounds X up toward positive infinity:   .  | 
 Floor   |  Floor(X)   |  Rounds X down toward negative infinity:   .  | 
 Round   |  Round(X)   |  Rounds X to the nearest whole number.   | 
 Trunc   |  Trunc(X)   |  Truncates the decimal part of a real number.   | 
 Int   |  Int(X)   |  Returns the integer part of a real number (identical to Trunc).   | 
 Frac   |  Frac(X)   |  Returns the decimal part of a real number.   | 
 Sqr   |  Sqr(X)   |  Returns the square of X:     | 
 Sqrt   |  Sqrt(X)   |  Returns the square root of X:     | 
 Exp   |  Exp(X)   |  Returns the exponential of X:     | 
 Power   |  Power(X,N)   |  Raises X to the power N:     | 
 Ln   |  Ln(X)   |  Returns the natural log of X:     | 
 Log10   |  Log10(X)   |  Returns the base-10 log of X:     | 
 Log2   |  Log2(X)   |  Returns the base-2 log of X:     | 
 LogN   |  LogN(X,N)   |  Returns the base-N log of X:     | 
 Sin   |  Sin(Theta)   |  Returns the sine of angle Theta:     | 
 Cos   |  Cos(Theta)   |  Returns the cosine of angle Theta:     | 
 Tan   |  Tan(Theta)   |  Returns the tangent of angle Theta:     | 
 SinCos   |  Tan(Theta)   |  Returns sine and cosine of an angle (using this function is twice as fast as calling Sin or Cos separately for the same angle).   | 
 ArcSin   |  ArcSin(X)   |  Returns the inverse sine of a given number:     | 
 ArcCos   |  ArcCos(X)   |  Returns the inverse cosine of a given number:     | 
 ArcTan   |  ArcTan(X)   |  Returns the inverse tangent of a given number:     | 
 ArcTan2   |  ArcTan2(Y,X)   |  Returns the inverse tangent from two numbers with respect to the proper quadrant of an angle:     | 
 Min   |  Min(X1,X2)   |  Returns the lesser of two numeric values.   | 
 Max   |  Max(X1,X2)   |  Returns the greater of two numeric values.   | 
 RandG   |  RandG(Mean,Std)   |  Returns a random number from a Gaussian distribution given that distributions mean and standard deviation:     |