Functions

/Users/garethloy/Musimathics/Musimat1.2/MusimatTutorial/B0129.cpp File Reference

#include "MusimatTutorial.h"

Go to the source code of this file.

Functions

 MusimatTutorialSection (B0129)

Function Documentation

MusimatTutorialSection ( B0129   )

Definition at line 2 of file B0129.cpp.

                              {
        Print("*** B.1.29 Representing Text ***");
        /*****************************************************************************
         
         B.1.29 Representing Text
         
         In order to print text, we use a data type called Character, which consists of the letters of the Roman 
         alphabet, digits from 0 to 9, and some nonprinting characters like tab, white space, and punctuation. 
         Characters are written in single quotes: 'a', 'B', 'c', and so on. Punctuation marks include ' ' 
         (blank), ',' (comma), ';' (semicolon), and '.' (period). We can spell words and sentences by 
         making lists of characters, for example {'G', 'u', 'i', 'd', 'o'}, but this would be exces-
         sively tedious. A shortcut for lists of characters is another data type called String. For example,
         *****************************************************************************/
        
        String c = "Ut queant laxis resonare";
        Print(c);
        
        /*****************************************************************************
         This string is equivalent to, and much simpler than, assembling a list of characters.
         
         Computers operate with binary numbers, not alphabetic letters. So we must associate each char-
         acter we want to display with a unique binary number. The computer operates only on the binary 
         numeric values; the display screen connected to the computer knows how to convert binary 
         numeric values to the corresponding characters for display.
         
         We need a table listing the association between particular binary values and the corresponding 
         printed characters. This table is called a character set. When a key is pressed on a computer key-
         board, the keyboard looks up the corresponding binary number in the character set and sends it 
         to the computer. The computer forwards the number to the display screen, which also uses 
         the character set to determine which character to display. Only the keyboard and the screen use the 
         character set; the computer just stores the corresponding binary numbers.
         
         International standard ISO-10646 defines a Universal Character Set, commonly called Unicode. 
         To keep things simple, Musimat uses a common subset of Unicode called ASCII (see section B.2). 
         The built-in Character() function takes an ASCII character code as its argument and returns 
         the corresponding printable Character.
         *****************************************************************************/
        
        Print(Character(65));
        
        /*****************************************************************************
         prints the character 'A'. The Integer() function can take a printable Character as its argu-
         ment and return the corresponding ASCII character code. For example:
         *****************************************************************************/
        
        Print(Integer('A'));
        
        /*****************************************************************************
         prints 65.
         *****************************************************************************/
}