[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
BYTE Byte Variable pp 41
Define: A subrange of type Integer in the range of 0..255.
Purpose: Numeric variable that saves memory over type Integer.
Notes: A variable of type Byte occupies one byte in memory, whereas
an Integer occupies two. Whenever a Byte value is expected
an Integer value may be specified, and vice versa except when
passed as parameters. Bytes and Integers may be intermixed in
expressions and Byte variables may be assigned Integer values.
The only difference between Byte and Char is what the
compiler will allow you to do with them.
----------------------------------------------------------------------------
Usage:
VAR
ByteVar : Byte ; { Define ByteVar as type Byte }
IntVar : Integer ; { Define IntVar as type Integer }
CONST
A : Byte = 65 ; { Define constant 'A' as type Byte }
BEGIN
ByteVar := 65 ; { Assign decimal 65 to ByteVar }
ByteVar := Ord('A') ; { Assign ordianl of 'A' to ByteVar }
IntVar := ByteVar ; { Integer := Byte is always possible }
ByteVar := IntVar ; { Byte := Integer is value dependent }
{$R+} { Set range checking on }
IntVar := 1000 ; { Too big for byte value }
ByteVar := IntVar ; { Run time Error 91 }
{$R-} { Set range checking off }
IntVar := 1000 ; { Too big for byte value }
ByteVar := IntVar ; { No error is detected }
END.
See Also:
Char
Chr
Const
String
Var
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson