The primary role of a computer is to process data. Data comes in a variety of forms and is stored in the computer in binary form. The interpretation of this binary data is determined by the program that is being ran at the time. Basically, there are a few types of data that the users of computer languages need to be aware of.
Integers
These are whole numbers and usually range from -32767 to +32768. The range is determined by the number of bytes used to store the number in memory. In this case, 16 bytes are used; one byte for the sign and 15 bytes for the number. Some languages support longer integers by using a larger number of bytes.
Real Numbers
These are numbers that can be fractional. The computer will store them in Scientific or Engineering form such as 1.786543E02. Again, the number of bytes used to store the number determines the range of the numbers available.
Characters
These are the characters on the keyboard as well as some special ones used for controlling devices such as printers. There are 26 letters of the alphabet; with upper and lower case, that makes 52. There are 10 numbers and about 32 other characters. That makes about 94 and the remainder make 128 in total. Alternate character sets for printing, inverse video for highlighting etc account for that number again. Thus 256 characters are accounted for and can be stored in one byte of memory.
String
This is a special case of a more complex data type known as an array (data structure). A string is considered 256 bytes of character data. (or less of so defined).
Programming languages also offer data structures that hold more than one data entity. An examples of a large structures might be the thousands of bytes of data required to store and display an image. A complex data structure might be the information held by a company on the products they sell.
Arrays
A large data structures all of the same simple data type or structure is known as an array. An array of data defines all of the data held in it with the one variable name, but references each data member with some form of index. This index is usually an integer number, but may also be a charater or some other user defined data type.
An example of a simple array is a variable that holds the maximum temperature for each day of the year called MaxTemperature. Thus the data for the maximum temperature for day 33 would be stored and referenced as MaxTemperature(33) where 33 is the index and MaxTemperature is the variable name. MaxTemperature could be defined as Array 1..365 of Integer as there are a maximum 365 days in a normal year.
Records
Records hold complex data. It is complex as it can contain more than one data type or structure. An example might be the data held about a person and could look like this:
Record of Person
Surname - String
Age - Integer
DOB - Record consisting of 3 integers
Gender - Character
Favorite Numbers - Array 1..5 of Integers
End of Record
The major advantage of using a record to keep this data as opposed to having many variables is:
Files
A file of data held on a disk or CD-ROM can also be considered a data structure. A file can contain many instances just one type of simple data that may be read and processed just one instance at a time, or may be read into an Array in the Random Access Memory (RAM) of the computer. The data may also be in the form of stored records either of fixed length or variable lenght. An example of a fixed length might be a record of a customer's name and address. An example of a variable length record may be the storage of image data in compressed format such as a Taggged Information Format (TIF) file.
When it comes to reading data from a file, it is the responsibility of the programmer to develop the appropriate algorithm to access the data. As the data is just a collection of binary numbers, the algorithm used will select the data and interpret it in a manner such that the resullts will be useful information. An inappropriate algorithm will produce garbage!!
Mike Leishman