- Main Page
- Namespaces
- Files

- File List
- File Members

# C:/Musimathics_local/Musimat/MusimatTutorial/B0129.cpp

Go to the documentation of this file.

    00001 #include "MusimatTutorial.h"
    00002 MusimatTutorialSection(B0129) {
    00003 Print("*** B.1.29 Representing Text ***");
    00004 /*****************************************************************************
    00005
    00006 B.1.29 Representing Text
    00007
    00008 In order to print text, we use a data type called Character, which consists of the letters of the Roman
    00009 alphabet, digits from 0 to 9, and some nonprinting characters like tab, white space, and punctuation.
    00010 Characters are written in single quotes: 'a', 'B', 'c', and so on. Punctuation marks include ' '
    00011 (blank), ',' (comma), ';' (semicolon), and '.' (period). We can spell words and sentences by
    00012 making lists of characters, for example {'G', 'u', 'i', 'd', 'o'}, but this would be exces-
    00013 sively tedious. A shortcut for lists of characters is another data type called String. For example,
    00014 *****************************************************************************/
    00015
    00016 String c = "Ut queant laxis resonare";
    00017
    00018 /*****************************************************************************
    00019 This string is equivalent to, and much simpler than, assembling a list of characters.
    00020
    00021 Computers operate with binary numbers, not alphabetic letters. So we must associate each char-
    00022 acter we want to display with a unique binary number. The computer operates only on the binary
    00023 numeric values; the display screen connected to the computer knows how to convert binary
    00024 numeric values to the corresponding characters for display.
    00025
    00026 We need a table listing the association between particular binary values and the corresponding
    00027 printed characters. This table is called a character set. When a key is pressed on a computer key-
    00028 board, the keyboard looks up the corresponding binary number in the character set and sends it
    00029 to the computer. The computer forwards the number to the display screen, which also uses
    00030 the character set to determine which character to display. Only the keyboard and the screen use the
    00031 character set; the computer just stores the corresponding binary numbers.
    00032
    00033 International standard ISO-10646 defines a Universal Character Set, commonly called Unicode.
    00034 To keep things simple, Musimat uses a common subset of Unicode called ASCII (see section B.2).
    00035 The built-in Character() function takes an ASCII character code as its argument and returns
    00036 the corresponding printable Character.
    00037 *****************************************************************************/
    00038
    00039 Print(Character(65));
    00040
    00041 /*****************************************************************************
    00042 prints the character 'A'. The Integer() function can take a printable Character as its argu-
    00043 ment and return the corresponding ASCII character code. For example:
    00044 *****************************************************************************/
    00045
    00046 Print(Integer('A'));
    00047
    00048 /*****************************************************************************
    00049 prints 65.
    00050
    00051 *****************************************************************************/
    00052 }}
    00053
    00055 /* $Revision: 1.1 $ $Date: 2006/09/08 19:11:33 $ $Author: dgl $ $Name:  $ $Id: _b0129_8cpp-source.html,v 1.1 2006/09/08 19:11:33 dgl Exp $ */
    00056 // The Musimat Tutorial © 2006 Gareth Loy
    00057 // Derived from Chapter 9 and Appendix B of "Musimathics Vol. 1" © 2006 Gareth Loy
    00058 // and published exclusively by The MIT Press.
    00059 // This program is released WITHOUT ANY WARRANTY; without even the implied
    00060 // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    00061 // For information on usage and redistribution, and for a DISCLAIMER OF ALL
    00062 // WARRANTIES, see the file, "LICENSE.txt," in this distribution.
    00063 // "Musimathics" is available here:     http://mitpress.mit.edu/catalog/item/default.asp?ttype=2&tid=10916
    00064 // Gareth Loy's Musimathics website:    http://www.musimathics.com/
    00065 // The Musimat website:                 http://www.musimat.com/
    00066 // This program is released under the terms of the GNU General Public License
    00067 // available here:                      http://www.gnu.org/licenses/gpl.txt
    00068