• Main Page
  • Files
  • File List
  • File Members

/Users/garethloy/Musimathics/Musimat1.2/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         Print(c);
00018         
00019         /*****************************************************************************
00020          This string is equivalent to, and much simpler than, assembling a list of characters.
00021          
00022          Computers operate with binary numbers, not alphabetic letters. So we must associate each char-
00023          acter we want to display with a unique binary number. The computer operates only on the binary 
00024          numeric values; the display screen connected to the computer knows how to convert binary 
00025          numeric values to the corresponding characters for display.
00026          
00027          We need a table listing the association between particular binary values and the corresponding 
00028          printed characters. This table is called a character set. When a key is pressed on a computer key-
00029          board, the keyboard looks up the corresponding binary number in the character set and sends it 
00030          to the computer. The computer forwards the number to the display screen, which also uses 
00031          the character set to determine which character to display. Only the keyboard and the screen use the 
00032          character set; the computer just stores the corresponding binary numbers.
00033          
00034          International standard ISO-10646 defines a Universal Character Set, commonly called Unicode. 
00035          To keep things simple, Musimat uses a common subset of Unicode called ASCII (see section B.2). 
00036          The built-in Character() function takes an ASCII character code as its argument and returns 
00037          the corresponding printable Character.
00038          *****************************************************************************/
00039         
00040         Print(Character(65));
00041         
00042         /*****************************************************************************
00043          prints the character 'A'. The Integer() function can take a printable Character as its argu-
00044          ment and return the corresponding ASCII character code. For example:
00045          *****************************************************************************/
00046         
00047         Print(Integer('A'));
00048         
00049         /*****************************************************************************
00050          prints 65.
00051          *****************************************************************************/
00052 }
00053 
00055 /* $Revision: 1.2 $ $Date: 2006/09/05 06:32:26 $ $Author: dgl $ $Name:  $ $Id: B0129.cpp,v 1.2 2006/09/05 06:32:26 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 

Generated on Fri Nov 26 2010 16:18:25 for Musimat Tutorial by  doxygen 1.7.2