Home » Archimedes archive » Acorn User » AU 1997-10 A.adf » Extras » Apple][e/PD/BOB/ARMBOB/doc/Ref/Types

Apple][e/PD/BOB/ARMBOB/doc/Ref/Types

This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.

Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.

Tape/disk: Home » Archimedes archive » Acorn User » AU 1997-10 A.adf » Extras
Filename: Apple][e/PD/BOB/ARMBOB/doc/Ref/Types
Read OK:
File size: 272B bytes
Load address: 0000
Exec address: 0000
File contents
ArmBob v.2.1 Reference                                GCW 29/11/94

         ----------------- TYPES ---------------

Types
-----

Armbob is an implicitly typed language. There are no type declarations.
Variables can be re-assigned irrespective of type. The function 'typeof' 
returns the integer code that determines the type of its argument. 
Synonyms for these codes are provided (see Ref.Keywords). Many functions 
and operators can take arguments of more than one type. For example, 
+ denotes concatenation of strings, addition of characters to strings, 
and addition of integers and reals, while << can denote both the shift 
left operator and the output operator of C++.

The Armbob datatypes are given below. The ones in angle brackets are
for Armbob's internal use:

0   NIL        - just the value nil, default for undefined things
1  <CLASS      - *internal type* >
2   OBJECT     - class instances, with private data
3   VECTOR     - arrays of arbitrary things
4   INTEGER    - 32-bit, includes Boolean values and characters
5   STRING     - byte arrays  
6   BYTECODE   - Bob functions, stack-machine code
7   CODE       - Built in functions, ARM machine code
8  <DICTIONARY - *internal type* >
9  <VARIABLE   - *internal type* >
10  IOSTREAM   - channels for input and output
11  REAL       - single precision floating point numbers

As far as the programmer is concerned a variable or expression may 
refer to:

           nil,
           an instance object of a class,
           a vector,
           an integer,
           a floating point number,
           a string,
           a function,
           an input/output stream.

NIL
---
The value 'nil' corresponds to 'void' in C. It is the default value 
for unassigned variables and the value returned by functions with no
return expression.

CLASS
-----
For the full syntax of class definitions see Ref.Syntax and the section
for 'class' in Ref.Built_in.

Only class definitions and function definitions can appear at the
top level, and these are the only things that can so appear.
A class definition must appear before instance objects for it are
defined.

Classes are determined by:

   an optional "base class" whose data and methods are inherited,
   private data,
   static data,
   private methods,
   static methods.

Static data and methods are common to all the instance objects of the
class. Private data and methods have separate instantiations for each
instance object. Data can only be referenced via methods. A class's
data must be declared in the class's definition, but its methods do not.
"Method" is really jargon for a special sort of function. Non-static
methods have an invisible local variable 'this' which refers to the
instance object that they belong to. A method definition resembles a
function definition prefixed by its class name followed by '::'. The
operator -> joins an instance object to a method of its class to
produce an actual function.


OBJECT
------

Objects of a class are created with statements of the form

  <object_name> = new <class_name>([ <data_values> ])

The general form for using a method is

  <object_expression>-><method>([<arguments>])

For example, one might have

         mywindow->open_window(position,size)

for an instance object called 'mywindow' belonging to a class with
a method called 'open_window'. The expressions 'position' and 'size'
might be vectors, i.e. complex data-types. 

For every class a method must be defined, with the same name as the
class, for defining new instance objects. This follows the conventions
of C++.

VECTOR
------
Vectors are arrays of fixed size. Their components can have any type.
They can be created by statements of the form

      <vector_name> = newvector(<size>);

which creates a new vector with <size> components which are all nil.

Alternatively, the expression

      vector { <expr1>; ...... <exprn>; }

returns a new vector with components <expr1> ... <exprn>. There must
be at least one component and not more than 255 for this construction.

      v = vector { x; y; z; } ;

is equivalent to 

     v = newvector(3);
     v[0] = x;
     v[1] = y;
     v[2] = z;

The function sizeof() returns the size of its argument. A vector v has
components v[i] where 0<=i<sizeof(v). 

Arrays are only 1-dimensional. To create an mxn matrix, for example,
we could define

   newmatrix(m,n)
   {
    local matrix,i;
    matrix = newvector(m);
    for(i=0;i<m;i++)
       matrix[i] = newvector(n);
    return matrix;
   }

and matrix[i][j] will be the element in the i-th row and j-th column.
This has the advantage that the i-th row is matrix[i]. When a vector
is first created its components all have the value nil.

It is permissible for a vector to be a component of itself.

An expression of the form

         enum { <var1>, ... , <varn> }

returns the integer n as result and assigns the values 0, 1, .. (n-1) to
the variables <var1>, ... , <varn> in order. This can be used to abstract
vector indices.

For example

          _3_vector = enum { x, y, z };
          v  = newvector(_3_vector);
          v[x] = v[y] = v[z] = 0.0;
          

INTEGER
-------
Integers must be in the range from -2147483648 to 2147483647. They
may also be used in hexadecimal form, with a '&' as prefix, with lower
case a,b,c,d,e,f denoting 10,11,12,13,14,15, in the range from 
&00000000 to &ffffffff. 

As in C, characters are simply integers in the range 0-255. Single 
characters are enclosed in single forward quote characters (').  So 
'A' also denotes the integer 65, for example. The character '\' is used 
as  an escape character, with '\n', '\t' denoting the newline and tab 
characters. 

In conditional expressions, any nonzero integer is taken to represent 
truth, and zero or nil as falsity. TRUE is a synonym for 1 and FALSE 
is a synonym for 0. See Ref.Keywords for a list of numerical synonyms.

It is�also possible to use integers as addresses. 

REAL
----
Single precision floating point numbers are characterised by the 
presence of a decimal point. Thus x = 0; will make x an integer, but
x = 0.0; will make x a real. Reals can be multiplied or divided by
either reals or integers and the result is a real. So an integer can
be converted to a real by multiplying it by 1.0. The function floor(x)
returns the greatest integer not greater than the real number x.
You may not add or subtract a real with an integer. The standard real
functions

  sin, cos, tan, asin, acos, atan, exp, log, sqrt

are built in. The value pi is also built in.


STRING
------
Strings are arrays of bytes. They can be created either by a command
of the form

         <string_name> = newstring(<size>);

which creates a string of ASCII nulls, of size <size>, or by using 
literal strings. These are are enclosed in double quotes (") and may 
not contain the double quote character. The function 'sizeof' can also 
be used with strings.

The component characters of a string s are

          s[0], s[1], ........ s[sizeof(s)-1]

As in Basic, strings may be concatenated using the operators + and +=. 
So
                   s += t

is equivalent to s = s + t.

In fact string handling in Armbob resembles Basic rather than C. The 
operator + can also be used to add characters to strings. This operator 
associates to the left, so that

            33+33+""

is the 1-element string "B", while

            ""+33+33

is the 2-element string "!!".

The function val() will convert as much of a string into a number as
it can. So val(" +10x") and val("&a") will both return 10.

The function input returns an input string, not a number. Leading 
spaces are not removed.

The comparison operators

                 ==, !=, >, <, >=, <= 

can be used with strings as well as numbers. String or number 
expressions may be used after the keyword 'case' in switch statements.

FUNCTIONS
---------
From the programmer's point of view built-in functions and user defined
functions behave in the same way. See Ref.Built_in for details of
built-in functions. Function definitions must appear only at the
top level. They cannot appear within function definitions or within
class definitions. Every program must have one function called 'main'
defined. This determines the entry point for the program.

Functions can be the values of variables. Note that the parenthesized
list of formal parameters following the function name in a function
definition is not part of the function name itself. Functions can be 
returned as values of functions.

IOSTREAM
--------
The following function, to type out the contents of a file, illustrates
how iostreams are opened and closed.

      typefile(filename)
      {
          local fp,c;
          if (fp = fopen(filename,"r"))
          {
              while ((c = getc(fp)) != EOF)
                  putc(c,stdout);
              fclose(fp);
          }
      }

EOF is a synonym for -1, the end of file value. The following iostreams
are built in:

      stdin           The standard input file pointer
      stdout          The standard output file pointer
      stderr          The standard error file pointer

The following iostream functions are built in:

  fopen(name,mode)    iostream     Opens a file (returns a file pointer)
  fclose(fp)          nil          Closes an iostream
  getc(fp)            integer      Gets a character from an iostream
  putc(ch,fp)         nil          Writes a character to an iostream
  print(x)            nil          Prints an object to stdout

The mode variable can take the values "r" (read), "w" (write) and
"a" (append).

The print function can take many arguments, separated by commas. These
arguments can have different types, but only strings and numbers are
generally useful.

The expression

                     fp << s

will output a string s to the iostream fp. The value of this expression
is fp, and << associates to the left, so that

                  fp << s1 << s2 .....

is equivalent to

                  fp << (s1 + s2 + ...... )

               ----------- END -------------
00000000  41 72 6d 42 6f 62 20 76  2e 32 2e 31 20 52 65 66  |ArmBob v.2.1 Ref|
00000010  65 72 65 6e 63 65 20 20  20 20 20 20 20 20 20 20  |erence          |
00000020  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00000030  20 20 20 20 20 20 47 43  57 20 32 39 2f 31 31 2f  |      GCW 29/11/|
00000040  39 34 0a 0a 20 20 20 20  20 20 20 20 20 2d 2d 2d  |94..         ---|
00000050  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 20 54  |-------------- T|
00000060  59 50 45 53 20 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |YPES -----------|
00000070  2d 2d 2d 2d 0a 0a 54 79  70 65 73 0a 2d 2d 2d 2d  |----..Types.----|
00000080  2d 0a 0a 41 72 6d 62 6f  62 20 69 73 20 61 6e 20  |-..Armbob is an |
00000090  69 6d 70 6c 69 63 69 74  6c 79 20 74 79 70 65 64  |implicitly typed|
000000a0  20 6c 61 6e 67 75 61 67  65 2e 20 54 68 65 72 65  | language. There|
000000b0  20 61 72 65 20 6e 6f 20  74 79 70 65 20 64 65 63  | are no type dec|
000000c0  6c 61 72 61 74 69 6f 6e  73 2e 0a 56 61 72 69 61  |larations..Varia|
000000d0  62 6c 65 73 20 63 61 6e  20 62 65 20 72 65 2d 61  |bles can be re-a|
000000e0  73 73 69 67 6e 65 64 20  69 72 72 65 73 70 65 63  |ssigned irrespec|
000000f0  74 69 76 65 20 6f 66 20  74 79 70 65 2e 20 54 68  |tive of type. Th|
00000100  65 20 66 75 6e 63 74 69  6f 6e 20 27 74 79 70 65  |e function 'type|
00000110  6f 66 27 20 0a 72 65 74  75 72 6e 73 20 74 68 65  |of' .returns the|
00000120  20 69 6e 74 65 67 65 72  20 63 6f 64 65 20 74 68  | integer code th|
00000130  61 74 20 64 65 74 65 72  6d 69 6e 65 73 20 74 68  |at determines th|
00000140  65 20 74 79 70 65 20 6f  66 20 69 74 73 20 61 72  |e type of its ar|
00000150  67 75 6d 65 6e 74 2e 20  0a 53 79 6e 6f 6e 79 6d  |gument. .Synonym|
00000160  73 20 66 6f 72 20 74 68  65 73 65 20 63 6f 64 65  |s for these code|
00000170  73 20 61 72 65 20 70 72  6f 76 69 64 65 64 20 28  |s are provided (|
00000180  73 65 65 20 52 65 66 2e  4b 65 79 77 6f 72 64 73  |see Ref.Keywords|
00000190  29 2e 20 4d 61 6e 79 20  66 75 6e 63 74 69 6f 6e  |). Many function|
000001a0  73 20 0a 61 6e 64 20 6f  70 65 72 61 74 6f 72 73  |s .and operators|
000001b0  20 63 61 6e 20 74 61 6b  65 20 61 72 67 75 6d 65  | can take argume|
000001c0  6e 74 73 20 6f 66 20 6d  6f 72 65 20 74 68 61 6e  |nts of more than|
000001d0  20 6f 6e 65 20 74 79 70  65 2e 20 46 6f 72 20 65  | one type. For e|
000001e0  78 61 6d 70 6c 65 2c 20  0a 2b 20 64 65 6e 6f 74  |xample, .+ denot|
000001f0  65 73 20 63 6f 6e 63 61  74 65 6e 61 74 69 6f 6e  |es concatenation|
00000200  20 6f 66 20 73 74 72 69  6e 67 73 2c 20 61 64 64  | of strings, add|
00000210  69 74 69 6f 6e 20 6f 66  20 63 68 61 72 61 63 74  |ition of charact|
00000220  65 72 73 20 74 6f 20 73  74 72 69 6e 67 73 2c 20  |ers to strings, |
00000230  0a 61 6e 64 20 61 64 64  69 74 69 6f 6e 20 6f 66  |.and addition of|
00000240  20 69 6e 74 65 67 65 72  73 20 61 6e 64 20 72 65  | integers and re|
00000250  61 6c 73 2c 20 77 68 69  6c 65 20 3c 3c 20 63 61  |als, while << ca|
00000260  6e 20 64 65 6e 6f 74 65  20 62 6f 74 68 20 74 68  |n denote both th|
00000270  65 20 73 68 69 66 74 20  0a 6c 65 66 74 20 6f 70  |e shift .left op|
00000280  65 72 61 74 6f 72 20 61  6e 64 20 74 68 65 20 6f  |erator and the o|
00000290  75 74 70 75 74 20 6f 70  65 72 61 74 6f 72 20 6f  |utput operator o|
000002a0  66 20 43 2b 2b 2e 0a 0a  54 68 65 20 41 72 6d 62  |f C++...The Armb|
000002b0  6f 62 20 64 61 74 61 74  79 70 65 73 20 61 72 65  |ob datatypes are|
000002c0  20 67 69 76 65 6e 20 62  65 6c 6f 77 2e 20 54 68  | given below. Th|
000002d0  65 20 6f 6e 65 73 20 69  6e 20 61 6e 67 6c 65 20  |e ones in angle |
000002e0  62 72 61 63 6b 65 74 73  20 61 72 65 0a 66 6f 72  |brackets are.for|
000002f0  20 41 72 6d 62 6f 62 27  73 20 69 6e 74 65 72 6e  | Armbob's intern|
00000300  61 6c 20 75 73 65 3a 0a  0a 30 20 20 20 4e 49 4c  |al use:..0   NIL|
00000310  20 20 20 20 20 20 20 20  2d 20 6a 75 73 74 20 74  |        - just t|
00000320  68 65 20 76 61 6c 75 65  20 6e 69 6c 2c 20 64 65  |he value nil, de|
00000330  66 61 75 6c 74 20 66 6f  72 20 75 6e 64 65 66 69  |fault for undefi|
00000340  6e 65 64 20 74 68 69 6e  67 73 0a 31 20 20 3c 43  |ned things.1  <C|
00000350  4c 41 53 53 20 20 20 20  20 20 2d 20 2a 69 6e 74  |LASS      - *int|
00000360  65 72 6e 61 6c 20 74 79  70 65 2a 20 3e 0a 32 20  |ernal type* >.2 |
00000370  20 20 4f 42 4a 45 43 54  20 20 20 20 20 2d 20 63  |  OBJECT     - c|
00000380  6c 61 73 73 20 69 6e 73  74 61 6e 63 65 73 2c 20  |lass instances, |
00000390  77 69 74 68 20 70 72 69  76 61 74 65 20 64 61 74  |with private dat|
000003a0  61 0a 33 20 20 20 56 45  43 54 4f 52 20 20 20 20  |a.3   VECTOR    |
000003b0  20 2d 20 61 72 72 61 79  73 20 6f 66 20 61 72 62  | - arrays of arb|
000003c0  69 74 72 61 72 79 20 74  68 69 6e 67 73 0a 34 20  |itrary things.4 |
000003d0  20 20 49 4e 54 45 47 45  52 20 20 20 20 2d 20 33  |  INTEGER    - 3|
000003e0  32 2d 62 69 74 2c 20 69  6e 63 6c 75 64 65 73 20  |2-bit, includes |
000003f0  42 6f 6f 6c 65 61 6e 20  76 61 6c 75 65 73 20 61  |Boolean values a|
00000400  6e 64 20 63 68 61 72 61  63 74 65 72 73 0a 35 20  |nd characters.5 |
00000410  20 20 53 54 52 49 4e 47  20 20 20 20 20 2d 20 62  |  STRING     - b|
00000420  79 74 65 20 61 72 72 61  79 73 20 20 0a 36 20 20  |yte arrays  .6  |
00000430  20 42 59 54 45 43 4f 44  45 20 20 20 2d 20 42 6f  | BYTECODE   - Bo|
00000440  62 20 66 75 6e 63 74 69  6f 6e 73 2c 20 73 74 61  |b functions, sta|
00000450  63 6b 2d 6d 61 63 68 69  6e 65 20 63 6f 64 65 0a  |ck-machine code.|
00000460  37 20 20 20 43 4f 44 45  20 20 20 20 20 20 20 2d  |7   CODE       -|
00000470  20 42 75 69 6c 74 20 69  6e 20 66 75 6e 63 74 69  | Built in functi|
00000480  6f 6e 73 2c 20 41 52 4d  20 6d 61 63 68 69 6e 65  |ons, ARM machine|
00000490  20 63 6f 64 65 0a 38 20  20 3c 44 49 43 54 49 4f  | code.8  <DICTIO|
000004a0  4e 41 52 59 20 2d 20 2a  69 6e 74 65 72 6e 61 6c  |NARY - *internal|
000004b0  20 74 79 70 65 2a 20 3e  0a 39 20 20 3c 56 41 52  | type* >.9  <VAR|
000004c0  49 41 42 4c 45 20 20 20  2d 20 2a 69 6e 74 65 72  |IABLE   - *inter|
000004d0  6e 61 6c 20 74 79 70 65  2a 20 3e 0a 31 30 20 20  |nal type* >.10  |
000004e0  49 4f 53 54 52 45 41 4d  20 20 20 2d 20 63 68 61  |IOSTREAM   - cha|
000004f0  6e 6e 65 6c 73 20 66 6f  72 20 69 6e 70 75 74 20  |nnels for input |
00000500  61 6e 64 20 6f 75 74 70  75 74 0a 31 31 20 20 52  |and output.11  R|
00000510  45 41 4c 20 20 20 20 20  20 20 2d 20 73 69 6e 67  |EAL       - sing|
00000520  6c 65 20 70 72 65 63 69  73 69 6f 6e 20 66 6c 6f  |le precision flo|
00000530  61 74 69 6e 67 20 70 6f  69 6e 74 20 6e 75 6d 62  |ating point numb|
00000540  65 72 73 0a 0a 41 73 20  66 61 72 20 61 73 20 74  |ers..As far as t|
00000550  68 65 20 70 72 6f 67 72  61 6d 6d 65 72 20 69 73  |he programmer is|
00000560  20 63 6f 6e 63 65 72 6e  65 64 20 61 20 76 61 72  | concerned a var|
00000570  69 61 62 6c 65 20 6f 72  20 65 78 70 72 65 73 73  |iable or express|
00000580  69 6f 6e 20 6d 61 79 20  0a 72 65 66 65 72 20 74  |ion may .refer t|
00000590  6f 3a 0a 0a 20 20 20 20  20 20 20 20 20 20 20 6e  |o:..           n|
000005a0  69 6c 2c 0a 20 20 20 20  20 20 20 20 20 20 20 61  |il,.           a|
000005b0  6e 20 69 6e 73 74 61 6e  63 65 20 6f 62 6a 65 63  |n instance objec|
000005c0  74 20 6f 66 20 61 20 63  6c 61 73 73 2c 0a 20 20  |t of a class,.  |
000005d0  20 20 20 20 20 20 20 20  20 61 20 76 65 63 74 6f  |         a vecto|
000005e0  72 2c 0a 20 20 20 20 20  20 20 20 20 20 20 61 6e  |r,.           an|
000005f0  20 69 6e 74 65 67 65 72  2c 0a 20 20 20 20 20 20  | integer,.      |
00000600  20 20 20 20 20 61 20 66  6c 6f 61 74 69 6e 67 20  |     a floating |
00000610  70 6f 69 6e 74 20 6e 75  6d 62 65 72 2c 0a 20 20  |point number,.  |
00000620  20 20 20 20 20 20 20 20  20 61 20 73 74 72 69 6e  |         a strin|
00000630  67 2c 0a 20 20 20 20 20  20 20 20 20 20 20 61 20  |g,.           a |
00000640  66 75 6e 63 74 69 6f 6e  2c 0a 20 20 20 20 20 20  |function,.      |
00000650  20 20 20 20 20 61 6e 20  69 6e 70 75 74 2f 6f 75  |     an input/ou|
00000660  74 70 75 74 20 73 74 72  65 61 6d 2e 0a 0a 4e 49  |tput stream...NI|
00000670  4c 0a 2d 2d 2d 0a 54 68  65 20 76 61 6c 75 65 20  |L.---.The value |
00000680  27 6e 69 6c 27 20 63 6f  72 72 65 73 70 6f 6e 64  |'nil' correspond|
00000690  73 20 74 6f 20 27 76 6f  69 64 27 20 69 6e 20 43  |s to 'void' in C|
000006a0  2e 20 49 74 20 69 73 20  74 68 65 20 64 65 66 61  |. It is the defa|
000006b0  75 6c 74 20 76 61 6c 75  65 20 0a 66 6f 72 20 75  |ult value .for u|
000006c0  6e 61 73 73 69 67 6e 65  64 20 76 61 72 69 61 62  |nassigned variab|
000006d0  6c 65 73 20 61 6e 64 20  74 68 65 20 76 61 6c 75  |les and the valu|
000006e0  65 20 72 65 74 75 72 6e  65 64 20 62 79 20 66 75  |e returned by fu|
000006f0  6e 63 74 69 6f 6e 73 20  77 69 74 68 20 6e 6f 0a  |nctions with no.|
00000700  72 65 74 75 72 6e 20 65  78 70 72 65 73 73 69 6f  |return expressio|
00000710  6e 2e 0a 0a 43 4c 41 53  53 0a 2d 2d 2d 2d 2d 0a  |n...CLASS.-----.|
00000720  46 6f 72 20 74 68 65 20  66 75 6c 6c 20 73 79 6e  |For the full syn|
00000730  74 61 78 20 6f 66 20 63  6c 61 73 73 20 64 65 66  |tax of class def|
00000740  69 6e 69 74 69 6f 6e 73  20 73 65 65 20 52 65 66  |initions see Ref|
00000750  2e 53 79 6e 74 61 78 20  61 6e 64 20 74 68 65 20  |.Syntax and the |
00000760  73 65 63 74 69 6f 6e 0a  66 6f 72 20 27 63 6c 61  |section.for 'cla|
00000770  73 73 27 20 69 6e 20 52  65 66 2e 42 75 69 6c 74  |ss' in Ref.Built|
00000780  5f 69 6e 2e 0a 0a 4f 6e  6c 79 20 63 6c 61 73 73  |_in...Only class|
00000790  20 64 65 66 69 6e 69 74  69 6f 6e 73 20 61 6e 64  | definitions and|
000007a0  20 66 75 6e 63 74 69 6f  6e 20 64 65 66 69 6e 69  | function defini|
000007b0  74 69 6f 6e 73 20 63 61  6e 20 61 70 70 65 61 72  |tions can appear|
000007c0  20 61 74 20 74 68 65 0a  74 6f 70 20 6c 65 76 65  | at the.top leve|
000007d0  6c 2c 20 61 6e 64 20 74  68 65 73 65 20 61 72 65  |l, and these are|
000007e0  20 74 68 65 20 6f 6e 6c  79 20 74 68 69 6e 67 73  | the only things|
000007f0  20 74 68 61 74 20 63 61  6e 20 73 6f 20 61 70 70  | that can so app|
00000800  65 61 72 2e 0a 41 20 63  6c 61 73 73 20 64 65 66  |ear..A class def|
00000810  69 6e 69 74 69 6f 6e 20  6d 75 73 74 20 61 70 70  |inition must app|
00000820  65 61 72 20 62 65 66 6f  72 65 20 69 6e 73 74 61  |ear before insta|
00000830  6e 63 65 20 6f 62 6a 65  63 74 73 20 66 6f 72 20  |nce objects for |
00000840  69 74 20 61 72 65 0a 64  65 66 69 6e 65 64 2e 0a  |it are.defined..|
00000850  0a 43 6c 61 73 73 65 73  20 61 72 65 20 64 65 74  |.Classes are det|
00000860  65 72 6d 69 6e 65 64 20  62 79 3a 0a 0a 20 20 20  |ermined by:..   |
00000870  61 6e 20 6f 70 74 69 6f  6e 61 6c 20 22 62 61 73  |an optional "bas|
00000880  65 20 63 6c 61 73 73 22  20 77 68 6f 73 65 20 64  |e class" whose d|
00000890  61 74 61 20 61 6e 64 20  6d 65 74 68 6f 64 73 20  |ata and methods |
000008a0  61 72 65 20 69 6e 68 65  72 69 74 65 64 2c 0a 20  |are inherited,. |
000008b0  20 20 70 72 69 76 61 74  65 20 64 61 74 61 2c 0a  |  private data,.|
000008c0  20 20 20 73 74 61 74 69  63 20 64 61 74 61 2c 0a  |   static data,.|
000008d0  20 20 20 70 72 69 76 61  74 65 20 6d 65 74 68 6f  |   private metho|
000008e0  64 73 2c 0a 20 20 20 73  74 61 74 69 63 20 6d 65  |ds,.   static me|
000008f0  74 68 6f 64 73 2e 0a 0a  53 74 61 74 69 63 20 64  |thods...Static d|
00000900  61 74 61 20 61 6e 64 20  6d 65 74 68 6f 64 73 20  |ata and methods |
00000910  61 72 65 20 63 6f 6d 6d  6f 6e 20 74 6f 20 61 6c  |are common to al|
00000920  6c 20 74 68 65 20 69 6e  73 74 61 6e 63 65 20 6f  |l the instance o|
00000930  62 6a 65 63 74 73 20 6f  66 20 74 68 65 0a 63 6c  |bjects of the.cl|
00000940  61 73 73 2e 20 50 72 69  76 61 74 65 20 64 61 74  |ass. Private dat|
00000950  61 20 61 6e 64 20 6d 65  74 68 6f 64 73 20 68 61  |a and methods ha|
00000960  76 65 20 73 65 70 61 72  61 74 65 20 69 6e 73 74  |ve separate inst|
00000970  61 6e 74 69 61 74 69 6f  6e 73 20 66 6f 72 20 65  |antiations for e|
00000980  61 63 68 0a 69 6e 73 74  61 6e 63 65 20 6f 62 6a  |ach.instance obj|
00000990  65 63 74 2e 20 44 61 74  61 20 63 61 6e 20 6f 6e  |ect. Data can on|
000009a0  6c 79 20 62 65 20 72 65  66 65 72 65 6e 63 65 64  |ly be referenced|
000009b0  20 76 69 61 20 6d 65 74  68 6f 64 73 2e 20 41 20  | via methods. A |
000009c0  63 6c 61 73 73 27 73 0a  64 61 74 61 20 6d 75 73  |class's.data mus|
000009d0  74 20 62 65 20 64 65 63  6c 61 72 65 64 20 69 6e  |t be declared in|
000009e0  20 74 68 65 20 63 6c 61  73 73 27 73 20 64 65 66  | the class's def|
000009f0  69 6e 69 74 69 6f 6e 2c  20 62 75 74 20 69 74 73  |inition, but its|
00000a00  20 6d 65 74 68 6f 64 73  20 64 6f 20 6e 6f 74 2e  | methods do not.|
00000a10  0a 22 4d 65 74 68 6f 64  22 20 69 73 20 72 65 61  |."Method" is rea|
00000a20  6c 6c 79 20 6a 61 72 67  6f 6e 20 66 6f 72 20 61  |lly jargon for a|
00000a30  20 73 70 65 63 69 61 6c  20 73 6f 72 74 20 6f 66  | special sort of|
00000a40  20 66 75 6e 63 74 69 6f  6e 2e 20 4e 6f 6e 2d 73  | function. Non-s|
00000a50  74 61 74 69 63 0a 6d 65  74 68 6f 64 73 20 68 61  |tatic.methods ha|
00000a60  76 65 20 61 6e 20 69 6e  76 69 73 69 62 6c 65 20  |ve an invisible |
00000a70  6c 6f 63 61 6c 20 76 61  72 69 61 62 6c 65 20 27  |local variable '|
00000a80  74 68 69 73 27 20 77 68  69 63 68 20 72 65 66 65  |this' which refe|
00000a90  72 73 20 74 6f 20 74 68  65 0a 69 6e 73 74 61 6e  |rs to the.instan|
00000aa0  63 65 20 6f 62 6a 65 63  74 20 74 68 61 74 20 74  |ce object that t|
00000ab0  68 65 79 20 62 65 6c 6f  6e 67 20 74 6f 2e 20 41  |hey belong to. A|
00000ac0  20 6d 65 74 68 6f 64 20  64 65 66 69 6e 69 74 69  | method definiti|
00000ad0  6f 6e 20 72 65 73 65 6d  62 6c 65 73 20 61 0a 66  |on resembles a.f|
00000ae0  75 6e 63 74 69 6f 6e 20  64 65 66 69 6e 69 74 69  |unction definiti|
00000af0  6f 6e 20 70 72 65 66 69  78 65 64 20 62 79 20 69  |on prefixed by i|
00000b00  74 73 20 63 6c 61 73 73  20 6e 61 6d 65 20 66 6f  |ts class name fo|
00000b10  6c 6c 6f 77 65 64 20 62  79 20 27 3a 3a 27 2e 20  |llowed by '::'. |
00000b20  54 68 65 0a 6f 70 65 72  61 74 6f 72 20 2d 3e 20  |The.operator -> |
00000b30  6a 6f 69 6e 73 20 61 6e  20 69 6e 73 74 61 6e 63  |joins an instanc|
00000b40  65 20 6f 62 6a 65 63 74  20 74 6f 20 61 20 6d 65  |e object to a me|
00000b50  74 68 6f 64 20 6f 66 20  69 74 73 20 63 6c 61 73  |thod of its clas|
00000b60  73 20 74 6f 0a 70 72 6f  64 75 63 65 20 61 6e 20  |s to.produce an |
00000b70  61 63 74 75 61 6c 20 66  75 6e 63 74 69 6f 6e 2e  |actual function.|
00000b80  0a 0a 0a 4f 42 4a 45 43  54 0a 2d 2d 2d 2d 2d 2d  |...OBJECT.------|
00000b90  0a 0a 4f 62 6a 65 63 74  73 20 6f 66 20 61 20 63  |..Objects of a c|
00000ba0  6c 61 73 73 20 61 72 65  20 63 72 65 61 74 65 64  |lass are created|
00000bb0  20 77 69 74 68 20 73 74  61 74 65 6d 65 6e 74 73  | with statements|
00000bc0  20 6f 66 20 74 68 65 20  66 6f 72 6d 0a 0a 20 20  | of the form..  |
00000bd0  3c 6f 62 6a 65 63 74 5f  6e 61 6d 65 3e 20 3d 20  |<object_name> = |
00000be0  6e 65 77 20 3c 63 6c 61  73 73 5f 6e 61 6d 65 3e  |new <class_name>|
00000bf0  28 5b 20 3c 64 61 74 61  5f 76 61 6c 75 65 73 3e  |([ <data_values>|
00000c00  20 5d 29 0a 0a 54 68 65  20 67 65 6e 65 72 61 6c  | ])..The general|
00000c10  20 66 6f 72 6d 20 66 6f  72 20 75 73 69 6e 67 20  | form for using |
00000c20  61 20 6d 65 74 68 6f 64  20 69 73 0a 0a 20 20 3c  |a method is..  <|
00000c30  6f 62 6a 65 63 74 5f 65  78 70 72 65 73 73 69 6f  |object_expressio|
00000c40  6e 3e 2d 3e 3c 6d 65 74  68 6f 64 3e 28 5b 3c 61  |n>-><method>([<a|
00000c50  72 67 75 6d 65 6e 74 73  3e 5d 29 0a 0a 46 6f 72  |rguments>])..For|
00000c60  20 65 78 61 6d 70 6c 65  2c 20 6f 6e 65 20 6d 69  | example, one mi|
00000c70  67 68 74 20 68 61 76 65  0a 0a 20 20 20 20 20 20  |ght have..      |
00000c80  20 20 20 6d 79 77 69 6e  64 6f 77 2d 3e 6f 70 65  |   mywindow->ope|
00000c90  6e 5f 77 69 6e 64 6f 77  28 70 6f 73 69 74 69 6f  |n_window(positio|
00000ca0  6e 2c 73 69 7a 65 29 0a  0a 66 6f 72 20 61 6e 20  |n,size)..for an |
00000cb0  69 6e 73 74 61 6e 63 65  20 6f 62 6a 65 63 74 20  |instance object |
00000cc0  63 61 6c 6c 65 64 20 27  6d 79 77 69 6e 64 6f 77  |called 'mywindow|
00000cd0  27 20 62 65 6c 6f 6e 67  69 6e 67 20 74 6f 20 61  |' belonging to a|
00000ce0  20 63 6c 61 73 73 20 77  69 74 68 0a 61 20 6d 65  | class with.a me|
00000cf0  74 68 6f 64 20 63 61 6c  6c 65 64 20 27 6f 70 65  |thod called 'ope|
00000d00  6e 5f 77 69 6e 64 6f 77  27 2e 20 54 68 65 20 65  |n_window'. The e|
00000d10  78 70 72 65 73 73 69 6f  6e 73 20 27 70 6f 73 69  |xpressions 'posi|
00000d20  74 69 6f 6e 27 20 61 6e  64 20 27 73 69 7a 65 27  |tion' and 'size'|
00000d30  0a 6d 69 67 68 74 20 62  65 20 76 65 63 74 6f 72  |.might be vector|
00000d40  73 2c 20 69 2e 65 2e 20  63 6f 6d 70 6c 65 78 20  |s, i.e. complex |
00000d50  64 61 74 61 2d 74 79 70  65 73 2e 20 0a 0a 46 6f  |data-types. ..Fo|
00000d60  72 20 65 76 65 72 79 20  63 6c 61 73 73 20 61 20  |r every class a |
00000d70  6d 65 74 68 6f 64 20 6d  75 73 74 20 62 65 20 64  |method must be d|
00000d80  65 66 69 6e 65 64 2c 20  77 69 74 68 20 74 68 65  |efined, with the|
00000d90  20 73 61 6d 65 20 6e 61  6d 65 20 61 73 20 74 68  | same name as th|
00000da0  65 0a 63 6c 61 73 73 2c  20 66 6f 72 20 64 65 66  |e.class, for def|
00000db0  69 6e 69 6e 67 20 6e 65  77 20 69 6e 73 74 61 6e  |ining new instan|
00000dc0  63 65 20 6f 62 6a 65 63  74 73 2e 20 54 68 69 73  |ce objects. This|
00000dd0  20 66 6f 6c 6c 6f 77 73  20 74 68 65 20 63 6f 6e  | follows the con|
00000de0  76 65 6e 74 69 6f 6e 73  0a 6f 66 20 43 2b 2b 2e  |ventions.of C++.|
00000df0  0a 0a 56 45 43 54 4f 52  0a 2d 2d 2d 2d 2d 2d 0a  |..VECTOR.------.|
00000e00  56 65 63 74 6f 72 73 20  61 72 65 20 61 72 72 61  |Vectors are arra|
00000e10  79 73 20 6f 66 20 66 69  78 65 64 20 73 69 7a 65  |ys of fixed size|
00000e20  2e 20 54 68 65 69 72 20  63 6f 6d 70 6f 6e 65 6e  |. Their componen|
00000e30  74 73 20 63 61 6e 20 68  61 76 65 20 61 6e 79 20  |ts can have any |
00000e40  74 79 70 65 2e 0a 54 68  65 79 20 63 61 6e 20 62  |type..They can b|
00000e50  65 20 63 72 65 61 74 65  64 20 62 79 20 73 74 61  |e created by sta|
00000e60  74 65 6d 65 6e 74 73 20  6f 66 20 74 68 65 20 66  |tements of the f|
00000e70  6f 72 6d 0a 0a 20 20 20  20 20 20 3c 76 65 63 74  |orm..      <vect|
00000e80  6f 72 5f 6e 61 6d 65 3e  20 3d 20 6e 65 77 76 65  |or_name> = newve|
00000e90  63 74 6f 72 28 3c 73 69  7a 65 3e 29 3b 0a 0a 77  |ctor(<size>);..w|
00000ea0  68 69 63 68 20 63 72 65  61 74 65 73 20 61 20 6e  |hich creates a n|
00000eb0  65 77 20 76 65 63 74 6f  72 20 77 69 74 68 20 3c  |ew vector with <|
00000ec0  73 69 7a 65 3e 20 63 6f  6d 70 6f 6e 65 6e 74 73  |size> components|
00000ed0  20 77 68 69 63 68 20 61  72 65 20 61 6c 6c 20 6e  | which are all n|
00000ee0  69 6c 2e 0a 0a 41 6c 74  65 72 6e 61 74 69 76 65  |il...Alternative|
00000ef0  6c 79 2c 20 74 68 65 20  65 78 70 72 65 73 73 69  |ly, the expressi|
00000f00  6f 6e 0a 0a 20 20 20 20  20 20 76 65 63 74 6f 72  |on..      vector|
00000f10  20 7b 20 3c 65 78 70 72  31 3e 3b 20 2e 2e 2e 2e  | { <expr1>; ....|
00000f20  2e 2e 20 3c 65 78 70 72  6e 3e 3b 20 7d 0a 0a 72  |.. <exprn>; }..r|
00000f30  65 74 75 72 6e 73 20 61  20 6e 65 77 20 76 65 63  |eturns a new vec|
00000f40  74 6f 72 20 77 69 74 68  20 63 6f 6d 70 6f 6e 65  |tor with compone|
00000f50  6e 74 73 20 3c 65 78 70  72 31 3e 20 2e 2e 2e 20  |nts <expr1> ... |
00000f60  3c 65 78 70 72 6e 3e 2e  20 54 68 65 72 65 20 6d  |<exprn>. There m|
00000f70  75 73 74 0a 62 65 20 61  74 20 6c 65 61 73 74 20  |ust.be at least |
00000f80  6f 6e 65 20 63 6f 6d 70  6f 6e 65 6e 74 20 61 6e  |one component an|
00000f90  64 20 6e 6f 74 20 6d 6f  72 65 20 74 68 61 6e 20  |d not more than |
00000fa0  32 35 35 20 66 6f 72 20  74 68 69 73 20 63 6f 6e  |255 for this con|
00000fb0  73 74 72 75 63 74 69 6f  6e 2e 0a 0a 20 20 20 20  |struction...    |
00000fc0  20 20 76 20 3d 20 76 65  63 74 6f 72 20 7b 20 78  |  v = vector { x|
00000fd0  3b 20 79 3b 20 7a 3b 20  7d 20 3b 0a 0a 69 73 20  |; y; z; } ;..is |
00000fe0  65 71 75 69 76 61 6c 65  6e 74 20 74 6f 20 0a 0a  |equivalent to ..|
00000ff0  20 20 20 20 20 76 20 3d  20 6e 65 77 76 65 63 74  |     v = newvect|
00001000  6f 72 28 33 29 3b 0a 20  20 20 20 20 76 5b 30 5d  |or(3);.     v[0]|
00001010  20 3d 20 78 3b 0a 20 20  20 20 20 76 5b 31 5d 20  | = x;.     v[1] |
00001020  3d 20 79 3b 0a 20 20 20  20 20 76 5b 32 5d 20 3d  |= y;.     v[2] =|
00001030  20 7a 3b 0a 0a 54 68 65  20 66 75 6e 63 74 69 6f  | z;..The functio|
00001040  6e 20 73 69 7a 65 6f 66  28 29 20 72 65 74 75 72  |n sizeof() retur|
00001050  6e 73 20 74 68 65 20 73  69 7a 65 20 6f 66 20 69  |ns the size of i|
00001060  74 73 20 61 72 67 75 6d  65 6e 74 2e 20 41 20 76  |ts argument. A v|
00001070  65 63 74 6f 72 20 76 20  68 61 73 0a 63 6f 6d 70  |ector v has.comp|
00001080  6f 6e 65 6e 74 73 20 76  5b 69 5d 20 77 68 65 72  |onents v[i] wher|
00001090  65 20 30 3c 3d 69 3c 73  69 7a 65 6f 66 28 76 29  |e 0<=i<sizeof(v)|
000010a0  2e 20 0a 0a 41 72 72 61  79 73 20 61 72 65 20 6f  |. ..Arrays are o|
000010b0  6e 6c 79 20 31 2d 64 69  6d 65 6e 73 69 6f 6e 61  |nly 1-dimensiona|
000010c0  6c 2e 20 54 6f 20 63 72  65 61 74 65 20 61 6e 20  |l. To create an |
000010d0  6d 78 6e 20 6d 61 74 72  69 78 2c 20 66 6f 72 20  |mxn matrix, for |
000010e0  65 78 61 6d 70 6c 65 2c  0a 77 65 20 63 6f 75 6c  |example,.we coul|
000010f0  64 20 64 65 66 69 6e 65  0a 0a 20 20 20 6e 65 77  |d define..   new|
00001100  6d 61 74 72 69 78 28 6d  2c 6e 29 0a 20 20 20 7b  |matrix(m,n).   {|
00001110  0a 20 20 20 20 6c 6f 63  61 6c 20 6d 61 74 72 69  |.    local matri|
00001120  78 2c 69 3b 0a 20 20 20  20 6d 61 74 72 69 78 20  |x,i;.    matrix |
00001130  3d 20 6e 65 77 76 65 63  74 6f 72 28 6d 29 3b 0a  |= newvector(m);.|
00001140  20 20 20 20 66 6f 72 28  69 3d 30 3b 69 3c 6d 3b  |    for(i=0;i<m;|
00001150  69 2b 2b 29 0a 20 20 20  20 20 20 20 6d 61 74 72  |i++).       matr|
00001160  69 78 5b 69 5d 20 3d 20  6e 65 77 76 65 63 74 6f  |ix[i] = newvecto|
00001170  72 28 6e 29 3b 0a 20 20  20 20 72 65 74 75 72 6e  |r(n);.    return|
00001180  20 6d 61 74 72 69 78 3b  0a 20 20 20 7d 0a 0a 61  | matrix;.   }..a|
00001190  6e 64 20 6d 61 74 72 69  78 5b 69 5d 5b 6a 5d 20  |nd matrix[i][j] |
000011a0  77 69 6c 6c 20 62 65 20  74 68 65 20 65 6c 65 6d  |will be the elem|
000011b0  65 6e 74 20 69 6e 20 74  68 65 20 69 2d 74 68 20  |ent in the i-th |
000011c0  72 6f 77 20 61 6e 64 20  6a 2d 74 68 20 63 6f 6c  |row and j-th col|
000011d0  75 6d 6e 2e 0a 54 68 69  73 20 68 61 73 20 74 68  |umn..This has th|
000011e0  65 20 61 64 76 61 6e 74  61 67 65 20 74 68 61 74  |e advantage that|
000011f0  20 74 68 65 20 69 2d 74  68 20 72 6f 77 20 69 73  | the i-th row is|
00001200  20 6d 61 74 72 69 78 5b  69 5d 2e 20 57 68 65 6e  | matrix[i]. When|
00001210  20 61 20 76 65 63 74 6f  72 0a 69 73 20 66 69 72  | a vector.is fir|
00001220  73 74 20 63 72 65 61 74  65 64 20 69 74 73 20 63  |st created its c|
00001230  6f 6d 70 6f 6e 65 6e 74  73 20 61 6c 6c 20 68 61  |omponents all ha|
00001240  76 65 20 74 68 65 20 76  61 6c 75 65 20 6e 69 6c  |ve the value nil|
00001250  2e 0a 0a 49 74 20 69 73  20 70 65 72 6d 69 73 73  |...It is permiss|
00001260  69 62 6c 65 20 66 6f 72  20 61 20 76 65 63 74 6f  |ible for a vecto|
00001270  72 20 74 6f 20 62 65 20  61 20 63 6f 6d 70 6f 6e  |r to be a compon|
00001280  65 6e 74 20 6f 66 20 69  74 73 65 6c 66 2e 0a 0a  |ent of itself...|
00001290  41 6e 20 65 78 70 72 65  73 73 69 6f 6e 20 6f 66  |An expression of|
000012a0  20 74 68 65 20 66 6f 72  6d 0a 0a 20 20 20 20 20  | the form..     |
000012b0  20 20 20 20 65 6e 75 6d  20 7b 20 3c 76 61 72 31  |    enum { <var1|
000012c0  3e 2c 20 2e 2e 2e 20 2c  20 3c 76 61 72 6e 3e 20  |>, ... , <varn> |
000012d0  7d 0a 0a 72 65 74 75 72  6e 73 20 74 68 65 20 69  |}..returns the i|
000012e0  6e 74 65 67 65 72 20 6e  20 61 73 20 72 65 73 75  |nteger n as resu|
000012f0  6c 74 20 61 6e 64 20 61  73 73 69 67 6e 73 20 74  |lt and assigns t|
00001300  68 65 20 76 61 6c 75 65  73 20 30 2c 20 31 2c 20  |he values 0, 1, |
00001310  2e 2e 20 28 6e 2d 31 29  20 74 6f 0a 74 68 65 20  |.. (n-1) to.the |
00001320  76 61 72 69 61 62 6c 65  73 20 3c 76 61 72 31 3e  |variables <var1>|
00001330  2c 20 2e 2e 2e 20 2c 20  3c 76 61 72 6e 3e 20 69  |, ... , <varn> i|
00001340  6e 20 6f 72 64 65 72 2e  20 54 68 69 73 20 63 61  |n order. This ca|
00001350  6e 20 62 65 20 75 73 65  64 20 74 6f 20 61 62 73  |n be used to abs|
00001360  74 72 61 63 74 0a 76 65  63 74 6f 72 20 69 6e 64  |tract.vector ind|
00001370  69 63 65 73 2e 0a 0a 46  6f 72 20 65 78 61 6d 70  |ices...For examp|
00001380  6c 65 0a 0a 20 20 20 20  20 20 20 20 20 20 5f 33  |le..          _3|
00001390  5f 76 65 63 74 6f 72 20  3d 20 65 6e 75 6d 20 7b  |_vector = enum {|
000013a0  20 78 2c 20 79 2c 20 7a  20 7d 3b 0a 20 20 20 20  | x, y, z };.    |
000013b0  20 20 20 20 20 20 76 20  20 3d 20 6e 65 77 76 65  |      v  = newve|
000013c0  63 74 6f 72 28 5f 33 5f  76 65 63 74 6f 72 29 3b  |ctor(_3_vector);|
000013d0  0a 20 20 20 20 20 20 20  20 20 20 76 5b 78 5d 20  |.          v[x] |
000013e0  3d 20 76 5b 79 5d 20 3d  20 76 5b 7a 5d 20 3d 20  |= v[y] = v[z] = |
000013f0  30 2e 30 3b 0a 20 20 20  20 20 20 20 20 20 20 0a  |0.0;.          .|
00001400  0a 49 4e 54 45 47 45 52  0a 2d 2d 2d 2d 2d 2d 2d  |.INTEGER.-------|
00001410  0a 49 6e 74 65 67 65 72  73 20 6d 75 73 74 20 62  |.Integers must b|
00001420  65 20 69 6e 20 74 68 65  20 72 61 6e 67 65 20 66  |e in the range f|
00001430  72 6f 6d 20 2d 32 31 34  37 34 38 33 36 34 38 20  |rom -2147483648 |
00001440  74 6f 20 32 31 34 37 34  38 33 36 34 37 2e 20 54  |to 2147483647. T|
00001450  68 65 79 0a 6d 61 79 20  61 6c 73 6f 20 62 65 20  |hey.may also be |
00001460  75 73 65 64 20 69 6e 20  68 65 78 61 64 65 63 69  |used in hexadeci|
00001470  6d 61 6c 20 66 6f 72 6d  2c 20 77 69 74 68 20 61  |mal form, with a|
00001480  20 27 26 27 20 61 73 20  70 72 65 66 69 78 2c 20  | '&' as prefix, |
00001490  77 69 74 68 20 6c 6f 77  65 72 0a 63 61 73 65 20  |with lower.case |
000014a0  61 2c 62 2c 63 2c 64 2c  65 2c 66 20 64 65 6e 6f  |a,b,c,d,e,f deno|
000014b0  74 69 6e 67 20 31 30 2c  31 31 2c 31 32 2c 31 33  |ting 10,11,12,13|
000014c0  2c 31 34 2c 31 35 2c 20  69 6e 20 74 68 65 20 72  |,14,15, in the r|
000014d0  61 6e 67 65 20 66 72 6f  6d 20 0a 26 30 30 30 30  |ange from .&0000|
000014e0  30 30 30 30 20 74 6f 20  26 66 66 66 66 66 66 66  |0000 to &fffffff|
000014f0  66 2e 20 0a 0a 41 73 20  69 6e 20 43 2c 20 63 68  |f. ..As in C, ch|
00001500  61 72 61 63 74 65 72 73  20 61 72 65 20 73 69 6d  |aracters are sim|
00001510  70 6c 79 20 69 6e 74 65  67 65 72 73 20 69 6e 20  |ply integers in |
00001520  74 68 65 20 72 61 6e 67  65 20 30 2d 32 35 35 2e  |the range 0-255.|
00001530  20 53 69 6e 67 6c 65 20  0a 63 68 61 72 61 63 74  | Single .charact|
00001540  65 72 73 20 61 72 65 20  65 6e 63 6c 6f 73 65 64  |ers are enclosed|
00001550  20 69 6e 20 73 69 6e 67  6c 65 20 66 6f 72 77 61  | in single forwa|
00001560  72 64 20 71 75 6f 74 65  20 63 68 61 72 61 63 74  |rd quote charact|
00001570  65 72 73 20 28 27 29 2e  20 20 53 6f 20 0a 27 41  |ers (').  So .'A|
00001580  27 20 61 6c 73 6f 20 64  65 6e 6f 74 65 73 20 74  |' also denotes t|
00001590  68 65 20 69 6e 74 65 67  65 72 20 36 35 2c 20 66  |he integer 65, f|
000015a0  6f 72 20 65 78 61 6d 70  6c 65 2e 20 54 68 65 20  |or example. The |
000015b0  63 68 61 72 61 63 74 65  72 20 27 5c 27 20 69 73  |character '\' is|
000015c0  20 75 73 65 64 20 0a 61  73 20 20 61 6e 20 65 73  | used .as  an es|
000015d0  63 61 70 65 20 63 68 61  72 61 63 74 65 72 2c 20  |cape character, |
000015e0  77 69 74 68 20 27 5c 6e  27 2c 20 27 5c 74 27 20  |with '\n', '\t' |
000015f0  64 65 6e 6f 74 69 6e 67  20 74 68 65 20 6e 65 77  |denoting the new|
00001600  6c 69 6e 65 20 61 6e 64  20 74 61 62 20 0a 63 68  |line and tab .ch|
00001610  61 72 61 63 74 65 72 73  2e 20 0a 0a 49 6e 20 63  |aracters. ..In c|
00001620  6f 6e 64 69 74 69 6f 6e  61 6c 20 65 78 70 72 65  |onditional expre|
00001630  73 73 69 6f 6e 73 2c 20  61 6e 79 20 6e 6f 6e 7a  |ssions, any nonz|
00001640  65 72 6f 20 69 6e 74 65  67 65 72 20 69 73 20 74  |ero integer is t|
00001650  61 6b 65 6e 20 74 6f 20  72 65 70 72 65 73 65 6e  |aken to represen|
00001660  74 20 0a 74 72 75 74 68  2c 20 61 6e 64 20 7a 65  |t .truth, and ze|
00001670  72 6f 20 6f 72 20 6e 69  6c 20 61 73 20 66 61 6c  |ro or nil as fal|
00001680  73 69 74 79 2e 20 54 52  55 45 20 69 73 20 61 20  |sity. TRUE is a |
00001690  73 79 6e 6f 6e 79 6d 20  66 6f 72 20 31 20 61 6e  |synonym for 1 an|
000016a0  64 20 46 41 4c 53 45 20  0a 69 73 20 61 20 73 79  |d FALSE .is a sy|
000016b0  6e 6f 6e 79 6d 20 66 6f  72 20 30 2e 20 53 65 65  |nonym for 0. See|
000016c0  20 52 65 66 2e 4b 65 79  77 6f 72 64 73 20 66 6f  | Ref.Keywords fo|
000016d0  72 20 61 20 6c 69 73 74  20 6f 66 20 6e 75 6d 65  |r a list of nume|
000016e0  72 69 63 61 6c 20 73 79  6e 6f 6e 79 6d 73 2e 0a  |rical synonyms..|
000016f0  0a 49 74 20 69 73 a0 61  6c 73 6f 20 70 6f 73 73  |.It is.also poss|
00001700  69 62 6c 65 20 74 6f 20  75 73 65 20 69 6e 74 65  |ible to use inte|
00001710  67 65 72 73 20 61 73 20  61 64 64 72 65 73 73 65  |gers as addresse|
00001720  73 2e 20 0a 0a 52 45 41  4c 0a 2d 2d 2d 2d 0a 53  |s. ..REAL.----.S|
00001730  69 6e 67 6c 65 20 70 72  65 63 69 73 69 6f 6e 20  |ingle precision |
00001740  66 6c 6f 61 74 69 6e 67  20 70 6f 69 6e 74 20 6e  |floating point n|
00001750  75 6d 62 65 72 73 20 61  72 65 20 63 68 61 72 61  |umbers are chara|
00001760  63 74 65 72 69 73 65 64  20 62 79 20 74 68 65 20  |cterised by the |
00001770  0a 70 72 65 73 65 6e 63  65 20 6f 66 20 61 20 64  |.presence of a d|
00001780  65 63 69 6d 61 6c 20 70  6f 69 6e 74 2e 20 54 68  |ecimal point. Th|
00001790  75 73 20 78 20 3d 20 30  3b 20 77 69 6c 6c 20 6d  |us x = 0; will m|
000017a0  61 6b 65 20 78 20 61 6e  20 69 6e 74 65 67 65 72  |ake x an integer|
000017b0  2c 20 62 75 74 0a 78 20  3d 20 30 2e 30 3b 20 77  |, but.x = 0.0; w|
000017c0  69 6c 6c 20 6d 61 6b 65  20 78 20 61 20 72 65 61  |ill make x a rea|
000017d0  6c 2e 20 52 65 61 6c 73  20 63 61 6e 20 62 65 20  |l. Reals can be |
000017e0  6d 75 6c 74 69 70 6c 69  65 64 20 6f 72 20 64 69  |multiplied or di|
000017f0  76 69 64 65 64 20 62 79  0a 65 69 74 68 65 72 20  |vided by.either |
00001800  72 65 61 6c 73 20 6f 72  20 69 6e 74 65 67 65 72  |reals or integer|
00001810  73 20 61 6e 64 20 74 68  65 20 72 65 73 75 6c 74  |s and the result|
00001820  20 69 73 20 61 20 72 65  61 6c 2e 20 53 6f 20 61  | is a real. So a|
00001830  6e 20 69 6e 74 65 67 65  72 20 63 61 6e 0a 62 65  |n integer can.be|
00001840  20 63 6f 6e 76 65 72 74  65 64 20 74 6f 20 61 20  | converted to a |
00001850  72 65 61 6c 20 62 79 20  6d 75 6c 74 69 70 6c 79  |real by multiply|
00001860  69 6e 67 20 69 74 20 62  79 20 31 2e 30 2e 20 54  |ing it by 1.0. T|
00001870  68 65 20 66 75 6e 63 74  69 6f 6e 20 66 6c 6f 6f  |he function floo|
00001880  72 28 78 29 0a 72 65 74  75 72 6e 73 20 74 68 65  |r(x).returns the|
00001890  20 67 72 65 61 74 65 73  74 20 69 6e 74 65 67 65  | greatest intege|
000018a0  72 20 6e 6f 74 20 67 72  65 61 74 65 72 20 74 68  |r not greater th|
000018b0  61 6e 20 74 68 65 20 72  65 61 6c 20 6e 75 6d 62  |an the real numb|
000018c0  65 72 20 78 2e 0a 59 6f  75 20 6d 61 79 20 6e 6f  |er x..You may no|
000018d0  74 20 61 64 64 20 6f 72  20 73 75 62 74 72 61 63  |t add or subtrac|
000018e0  74 20 61 20 72 65 61 6c  20 77 69 74 68 20 61 6e  |t a real with an|
000018f0  20 69 6e 74 65 67 65 72  2e 20 54 68 65 20 73 74  | integer. The st|
00001900  61 6e 64 61 72 64 20 72  65 61 6c 0a 66 75 6e 63  |andard real.func|
00001910  74 69 6f 6e 73 0a 0a 20  20 73 69 6e 2c 20 63 6f  |tions..  sin, co|
00001920  73 2c 20 74 61 6e 2c 20  61 73 69 6e 2c 20 61 63  |s, tan, asin, ac|
00001930  6f 73 2c 20 61 74 61 6e  2c 20 65 78 70 2c 20 6c  |os, atan, exp, l|
00001940  6f 67 2c 20 73 71 72 74  0a 0a 61 72 65 20 62 75  |og, sqrt..are bu|
00001950  69 6c 74 20 69 6e 2e 20  54 68 65 20 76 61 6c 75  |ilt in. The valu|
00001960  65 20 70 69 20 69 73 20  61 6c 73 6f 20 62 75 69  |e pi is also bui|
00001970  6c 74 20 69 6e 2e 0a 0a  0a 53 54 52 49 4e 47 0a  |lt in....STRING.|
00001980  2d 2d 2d 2d 2d 2d 0a 53  74 72 69 6e 67 73 20 61  |------.Strings a|
00001990  72 65 20 61 72 72 61 79  73 20 6f 66 20 62 79 74  |re arrays of byt|
000019a0  65 73 2e 20 54 68 65 79  20 63 61 6e 20 62 65 20  |es. They can be |
000019b0  63 72 65 61 74 65 64 20  65 69 74 68 65 72 20 62  |created either b|
000019c0  79 20 61 20 63 6f 6d 6d  61 6e 64 0a 6f 66 20 74  |y a command.of t|
000019d0  68 65 20 66 6f 72 6d 0a  0a 20 20 20 20 20 20 20  |he form..       |
000019e0  20 20 3c 73 74 72 69 6e  67 5f 6e 61 6d 65 3e 20  |  <string_name> |
000019f0  3d 20 6e 65 77 73 74 72  69 6e 67 28 3c 73 69 7a  |= newstring(<siz|
00001a00  65 3e 29 3b 0a 0a 77 68  69 63 68 20 63 72 65 61  |e>);..which crea|
00001a10  74 65 73 20 61 20 73 74  72 69 6e 67 20 6f 66 20  |tes a string of |
00001a20  41 53 43 49 49 20 6e 75  6c 6c 73 2c 20 6f 66 20  |ASCII nulls, of |
00001a30  73 69 7a 65 20 3c 73 69  7a 65 3e 2c 20 6f 72 20  |size <size>, or |
00001a40  62 79 20 75 73 69 6e 67  20 0a 6c 69 74 65 72 61  |by using .litera|
00001a50  6c 20 73 74 72 69 6e 67  73 2e 20 54 68 65 73 65  |l strings. These|
00001a60  20 61 72 65 20 61 72 65  20 65 6e 63 6c 6f 73 65  | are are enclose|
00001a70  64 20 69 6e 20 64 6f 75  62 6c 65 20 71 75 6f 74  |d in double quot|
00001a80  65 73 20 28 22 29 20 61  6e 64 20 6d 61 79 20 0a  |es (") and may .|
00001a90  6e 6f 74 20 63 6f 6e 74  61 69 6e 20 74 68 65 20  |not contain the |
00001aa0  64 6f 75 62 6c 65 20 71  75 6f 74 65 20 63 68 61  |double quote cha|
00001ab0  72 61 63 74 65 72 2e 20  54 68 65 20 66 75 6e 63  |racter. The func|
00001ac0  74 69 6f 6e 20 27 73 69  7a 65 6f 66 27 20 63 61  |tion 'sizeof' ca|
00001ad0  6e 20 61 6c 73 6f 20 0a  62 65 20 75 73 65 64 20  |n also .be used |
00001ae0  77 69 74 68 20 73 74 72  69 6e 67 73 2e 0a 0a 54  |with strings...T|
00001af0  68 65 20 63 6f 6d 70 6f  6e 65 6e 74 20 63 68 61  |he component cha|
00001b00  72 61 63 74 65 72 73 20  6f 66 20 61 20 73 74 72  |racters of a str|
00001b10  69 6e 67 20 73 20 61 72  65 0a 0a 20 20 20 20 20  |ing s are..     |
00001b20  20 20 20 20 20 73 5b 30  5d 2c 20 73 5b 31 5d 2c  |     s[0], s[1],|
00001b30  20 2e 2e 2e 2e 2e 2e 2e  2e 20 73 5b 73 69 7a 65  | ........ s[size|
00001b40  6f 66 28 73 29 2d 31 5d  0a 0a 41 73 20 69 6e 20  |of(s)-1]..As in |
00001b50  42 61 73 69 63 2c 20 73  74 72 69 6e 67 73 20 6d  |Basic, strings m|
00001b60  61 79 20 62 65 20 63 6f  6e 63 61 74 65 6e 61 74  |ay be concatenat|
00001b70  65 64 20 75 73 69 6e 67  20 74 68 65 20 6f 70 65  |ed using the ope|
00001b80  72 61 74 6f 72 73 20 2b  20 61 6e 64 20 2b 3d 2e  |rators + and +=.|
00001b90  20 0a 53 6f 0a 20 20 20  20 20 20 20 20 20 20 20  | .So.           |
00001ba0  20 20 20 20 20 20 20 20  73 20 2b 3d 20 74 0a 0a  |        s += t..|
00001bb0  69 73 20 65 71 75 69 76  61 6c 65 6e 74 20 74 6f  |is equivalent to|
00001bc0  20 73 20 3d 20 73 20 2b  20 74 2e 0a 0a 49 6e 20  | s = s + t...In |
00001bd0  66 61 63 74 20 73 74 72  69 6e 67 20 68 61 6e 64  |fact string hand|
00001be0  6c 69 6e 67 20 69 6e 20  41 72 6d 62 6f 62 20 72  |ling in Armbob r|
00001bf0  65 73 65 6d 62 6c 65 73  20 42 61 73 69 63 20 72  |esembles Basic r|
00001c00  61 74 68 65 72 20 74 68  61 6e 20 43 2e 20 54 68  |ather than C. Th|
00001c10  65 20 0a 6f 70 65 72 61  74 6f 72 20 2b 20 63 61  |e .operator + ca|
00001c20  6e 20 61 6c 73 6f 20 62  65 20 75 73 65 64 20 74  |n also be used t|
00001c30  6f 20 61 64 64 20 63 68  61 72 61 63 74 65 72 73  |o add characters|
00001c40  20 74 6f 20 73 74 72 69  6e 67 73 2e 20 54 68 69  | to strings. Thi|
00001c50  73 20 6f 70 65 72 61 74  6f 72 20 0a 61 73 73 6f  |s operator .asso|
00001c60  63 69 61 74 65 73 20 74  6f 20 74 68 65 20 6c 65  |ciates to the le|
00001c70  66 74 2c 20 73 6f 20 74  68 61 74 0a 0a 20 20 20  |ft, so that..   |
00001c80  20 20 20 20 20 20 20 20  20 33 33 2b 33 33 2b 22  |         33+33+"|
00001c90  22 0a 0a 69 73 20 74 68  65 20 31 2d 65 6c 65 6d  |"..is the 1-elem|
00001ca0  65 6e 74 20 73 74 72 69  6e 67 20 22 42 22 2c 20  |ent string "B", |
00001cb0  77 68 69 6c 65 0a 0a 20  20 20 20 20 20 20 20 20  |while..         |
00001cc0  20 20 20 22 22 2b 33 33  2b 33 33 0a 0a 69 73 20  |   ""+33+33..is |
00001cd0  74 68 65 20 32 2d 65 6c  65 6d 65 6e 74 20 73 74  |the 2-element st|
00001ce0  72 69 6e 67 20 22 21 21  22 2e 0a 0a 54 68 65 20  |ring "!!"...The |
00001cf0  66 75 6e 63 74 69 6f 6e  20 76 61 6c 28 29 20 77  |function val() w|
00001d00  69 6c 6c 20 63 6f 6e 76  65 72 74 20 61 73 20 6d  |ill convert as m|
00001d10  75 63 68 20 6f 66 20 61  20 73 74 72 69 6e 67 20  |uch of a string |
00001d20  69 6e 74 6f 20 61 20 6e  75 6d 62 65 72 20 61 73  |into a number as|
00001d30  0a 69 74 20 63 61 6e 2e  20 53 6f 20 76 61 6c 28  |.it can. So val(|
00001d40  22 20 2b 31 30 78 22 29  20 61 6e 64 20 76 61 6c  |" +10x") and val|
00001d50  28 22 26 61 22 29 20 77  69 6c 6c 20 62 6f 74 68  |("&a") will both|
00001d60  20 72 65 74 75 72 6e 20  31 30 2e 0a 0a 54 68 65  | return 10...The|
00001d70  20 66 75 6e 63 74 69 6f  6e 20 69 6e 70 75 74 20  | function input |
00001d80  72 65 74 75 72 6e 73 20  61 6e 20 69 6e 70 75 74  |returns an input|
00001d90  20 73 74 72 69 6e 67 2c  20 6e 6f 74 20 61 20 6e  | string, not a n|
00001da0  75 6d 62 65 72 2e 20 4c  65 61 64 69 6e 67 20 0a  |umber. Leading .|
00001db0  73 70 61 63 65 73 20 61  72 65 20 6e 6f 74 20 72  |spaces are not r|
00001dc0  65 6d 6f 76 65 64 2e 0a  0a 54 68 65 20 63 6f 6d  |emoved...The com|
00001dd0  70 61 72 69 73 6f 6e 20  6f 70 65 72 61 74 6f 72  |parison operator|
00001de0  73 0a 0a 20 20 20 20 20  20 20 20 20 20 20 20 20  |s..             |
00001df0  20 20 20 20 3d 3d 2c 20  21 3d 2c 20 3e 2c 20 3c  |    ==, !=, >, <|
00001e00  2c 20 3e 3d 2c 20 3c 3d  20 0a 0a 63 61 6e 20 62  |, >=, <= ..can b|
00001e10  65 20 75 73 65 64 20 77  69 74 68 20 73 74 72 69  |e used with stri|
00001e20  6e 67 73 20 61 73 20 77  65 6c 6c 20 61 73 20 6e  |ngs as well as n|
00001e30  75 6d 62 65 72 73 2e 20  53 74 72 69 6e 67 20 6f  |umbers. String o|
00001e40  72 20 6e 75 6d 62 65 72  20 0a 65 78 70 72 65 73  |r number .expres|
00001e50  73 69 6f 6e 73 20 6d 61  79 20 62 65 20 75 73 65  |sions may be use|
00001e60  64 20 61 66 74 65 72 20  74 68 65 20 6b 65 79 77  |d after the keyw|
00001e70  6f 72 64 20 27 63 61 73  65 27 20 69 6e 20 73 77  |ord 'case' in sw|
00001e80  69 74 63 68 20 73 74 61  74 65 6d 65 6e 74 73 2e  |itch statements.|
00001e90  0a 0a 46 55 4e 43 54 49  4f 4e 53 0a 2d 2d 2d 2d  |..FUNCTIONS.----|
00001ea0  2d 2d 2d 2d 2d 0a 46 72  6f 6d 20 74 68 65 20 70  |-----.From the p|
00001eb0  72 6f 67 72 61 6d 6d 65  72 27 73 20 70 6f 69 6e  |rogrammer's poin|
00001ec0  74 20 6f 66 20 76 69 65  77 20 62 75 69 6c 74 2d  |t of view built-|
00001ed0  69 6e 20 66 75 6e 63 74  69 6f 6e 73 20 61 6e 64  |in functions and|
00001ee0  20 75 73 65 72 20 64 65  66 69 6e 65 64 0a 66 75  | user defined.fu|
00001ef0  6e 63 74 69 6f 6e 73 20  62 65 68 61 76 65 20 69  |nctions behave i|
00001f00  6e 20 74 68 65 20 73 61  6d 65 20 77 61 79 2e 20  |n the same way. |
00001f10  53 65 65 20 52 65 66 2e  42 75 69 6c 74 5f 69 6e  |See Ref.Built_in|
00001f20  20 66 6f 72 20 64 65 74  61 69 6c 73 20 6f 66 0a  | for details of.|
00001f30  62 75 69 6c 74 2d 69 6e  20 66 75 6e 63 74 69 6f  |built-in functio|
00001f40  6e 73 2e 20 46 75 6e 63  74 69 6f 6e 20 64 65 66  |ns. Function def|
00001f50  69 6e 69 74 69 6f 6e 73  20 6d 75 73 74 20 61 70  |initions must ap|
00001f60  70 65 61 72 20 6f 6e 6c  79 20 61 74 20 74 68 65  |pear only at the|
00001f70  0a 74 6f 70 20 6c 65 76  65 6c 2e 20 54 68 65 79  |.top level. They|
00001f80  20 63 61 6e 6e 6f 74 20  61 70 70 65 61 72 20 77  | cannot appear w|
00001f90  69 74 68 69 6e 20 66 75  6e 63 74 69 6f 6e 20 64  |ithin function d|
00001fa0  65 66 69 6e 69 74 69 6f  6e 73 20 6f 72 20 77 69  |efinitions or wi|
00001fb0  74 68 69 6e 0a 63 6c 61  73 73 20 64 65 66 69 6e  |thin.class defin|
00001fc0  69 74 69 6f 6e 73 2e 20  45 76 65 72 79 20 70 72  |itions. Every pr|
00001fd0  6f 67 72 61 6d 20 6d 75  73 74 20 68 61 76 65 20  |ogram must have |
00001fe0  6f 6e 65 20 66 75 6e 63  74 69 6f 6e 20 63 61 6c  |one function cal|
00001ff0  6c 65 64 20 27 6d 61 69  6e 27 0a 64 65 66 69 6e  |led 'main'.defin|
00002000  65 64 2e 20 54 68 69 73  20 64 65 74 65 72 6d 69  |ed. This determi|
00002010  6e 65 73 20 74 68 65 20  65 6e 74 72 79 20 70 6f  |nes the entry po|
00002020  69 6e 74 20 66 6f 72 20  74 68 65 20 70 72 6f 67  |int for the prog|
00002030  72 61 6d 2e 0a 0a 46 75  6e 63 74 69 6f 6e 73 20  |ram...Functions |
00002040  63 61 6e 20 62 65 20 74  68 65 20 76 61 6c 75 65  |can be the value|
00002050  73 20 6f 66 20 76 61 72  69 61 62 6c 65 73 2e 20  |s of variables. |
00002060  4e 6f 74 65 20 74 68 61  74 20 74 68 65 20 70 61  |Note that the pa|
00002070  72 65 6e 74 68 65 73 69  7a 65 64 0a 6c 69 73 74  |renthesized.list|
00002080  20 6f 66 20 66 6f 72 6d  61 6c 20 70 61 72 61 6d  | of formal param|
00002090  65 74 65 72 73 20 66 6f  6c 6c 6f 77 69 6e 67 20  |eters following |
000020a0  74 68 65 20 66 75 6e 63  74 69 6f 6e 20 6e 61 6d  |the function nam|
000020b0  65 20 69 6e 20 61 20 66  75 6e 63 74 69 6f 6e 0a  |e in a function.|
000020c0  64 65 66 69 6e 69 74 69  6f 6e 20 69 73 20 6e 6f  |definition is no|
000020d0  74 20 70 61 72 74 20 6f  66 20 74 68 65 20 66 75  |t part of the fu|
000020e0  6e 63 74 69 6f 6e 20 6e  61 6d 65 20 69 74 73 65  |nction name itse|
000020f0  6c 66 2e 20 46 75 6e 63  74 69 6f 6e 73 20 63 61  |lf. Functions ca|
00002100  6e 20 62 65 20 0a 72 65  74 75 72 6e 65 64 20 61  |n be .returned a|
00002110  73 20 76 61 6c 75 65 73  20 6f 66 20 66 75 6e 63  |s values of func|
00002120  74 69 6f 6e 73 2e 0a 0a  49 4f 53 54 52 45 41 4d  |tions...IOSTREAM|
00002130  0a 2d 2d 2d 2d 2d 2d 2d  2d 0a 54 68 65 20 66 6f  |.--------.The fo|
00002140  6c 6c 6f 77 69 6e 67 20  66 75 6e 63 74 69 6f 6e  |llowing function|
00002150  2c 20 74 6f 20 74 79 70  65 20 6f 75 74 20 74 68  |, to type out th|
00002160  65 20 63 6f 6e 74 65 6e  74 73 20 6f 66 20 61 20  |e contents of a |
00002170  66 69 6c 65 2c 20 69 6c  6c 75 73 74 72 61 74 65  |file, illustrate|
00002180  73 0a 68 6f 77 20 69 6f  73 74 72 65 61 6d 73 20  |s.how iostreams |
00002190  61 72 65 20 6f 70 65 6e  65 64 20 61 6e 64 20 63  |are opened and c|
000021a0  6c 6f 73 65 64 2e 0a 0a  20 20 20 20 20 20 74 79  |losed...      ty|
000021b0  70 65 66 69 6c 65 28 66  69 6c 65 6e 61 6d 65 29  |pefile(filename)|
000021c0  0a 20 20 20 20 20 20 7b  0a 20 20 20 20 20 20 20  |.      {.       |
000021d0  20 20 20 6c 6f 63 61 6c  20 66 70 2c 63 3b 0a 20  |   local fp,c;. |
000021e0  20 20 20 20 20 20 20 20  20 69 66 20 28 66 70 20  |         if (fp |
000021f0  3d 20 66 6f 70 65 6e 28  66 69 6c 65 6e 61 6d 65  |= fopen(filename|
00002200  2c 22 72 22 29 29 0a 20  20 20 20 20 20 20 20 20  |,"r")).         |
00002210  20 7b 0a 20 20 20 20 20  20 20 20 20 20 20 20 20  | {.             |
00002220  20 77 68 69 6c 65 20 28  28 63 20 3d 20 67 65 74  | while ((c = get|
00002230  63 28 66 70 29 29 20 21  3d 20 45 4f 46 29 0a 20  |c(fp)) != EOF). |
00002240  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00002250  20 70 75 74 63 28 63 2c  73 74 64 6f 75 74 29 3b  | putc(c,stdout);|
00002260  0a 20 20 20 20 20 20 20  20 20 20 20 20 20 20 66  |.              f|
00002270  63 6c 6f 73 65 28 66 70  29 3b 0a 20 20 20 20 20  |close(fp);.     |
00002280  20 20 20 20 20 7d 0a 20  20 20 20 20 20 7d 0a 0a  |     }.      }..|
00002290  45 4f 46 20 69 73 20 61  20 73 79 6e 6f 6e 79 6d  |EOF is a synonym|
000022a0  20 66 6f 72 20 2d 31 2c  20 74 68 65 20 65 6e 64  | for -1, the end|
000022b0  20 6f 66 20 66 69 6c 65  20 76 61 6c 75 65 2e 20  | of file value. |
000022c0  54 68 65 20 66 6f 6c 6c  6f 77 69 6e 67 20 69 6f  |The following io|
000022d0  73 74 72 65 61 6d 73 0a  61 72 65 20 62 75 69 6c  |streams.are buil|
000022e0  74 20 69 6e 3a 0a 0a 20  20 20 20 20 20 73 74 64  |t in:..      std|
000022f0  69 6e 20 20 20 20 20 20  20 20 20 20 20 54 68 65  |in           The|
00002300  20 73 74 61 6e 64 61 72  64 20 69 6e 70 75 74 20  | standard input |
00002310  66 69 6c 65 20 70 6f 69  6e 74 65 72 0a 20 20 20  |file pointer.   |
00002320  20 20 20 73 74 64 6f 75  74 20 20 20 20 20 20 20  |   stdout       |
00002330  20 20 20 54 68 65 20 73  74 61 6e 64 61 72 64 20  |   The standard |
00002340  6f 75 74 70 75 74 20 66  69 6c 65 20 70 6f 69 6e  |output file poin|
00002350  74 65 72 0a 20 20 20 20  20 20 73 74 64 65 72 72  |ter.      stderr|
00002360  20 20 20 20 20 20 20 20  20 20 54 68 65 20 73 74  |          The st|
00002370  61 6e 64 61 72 64 20 65  72 72 6f 72 20 66 69 6c  |andard error fil|
00002380  65 20 70 6f 69 6e 74 65  72 0a 0a 54 68 65 20 66  |e pointer..The f|
00002390  6f 6c 6c 6f 77 69 6e 67  20 69 6f 73 74 72 65 61  |ollowing iostrea|
000023a0  6d 20 66 75 6e 63 74 69  6f 6e 73 20 61 72 65 20  |m functions are |
000023b0  62 75 69 6c 74 20 69 6e  3a 0a 0a 20 20 66 6f 70  |built in:..  fop|
000023c0  65 6e 28 6e 61 6d 65 2c  6d 6f 64 65 29 20 20 20  |en(name,mode)   |
000023d0  20 69 6f 73 74 72 65 61  6d 20 20 20 20 20 4f 70  | iostream     Op|
000023e0  65 6e 73 20 61 20 66 69  6c 65 20 28 72 65 74 75  |ens a file (retu|
000023f0  72 6e 73 20 61 20 66 69  6c 65 20 70 6f 69 6e 74  |rns a file point|
00002400  65 72 29 0a 20 20 66 63  6c 6f 73 65 28 66 70 29  |er).  fclose(fp)|
00002410  20 20 20 20 20 20 20 20  20 20 6e 69 6c 20 20 20  |          nil   |
00002420  20 20 20 20 20 20 20 43  6c 6f 73 65 73 20 61 6e  |       Closes an|
00002430  20 69 6f 73 74 72 65 61  6d 0a 20 20 67 65 74 63  | iostream.  getc|
00002440  28 66 70 29 20 20 20 20  20 20 20 20 20 20 20 20  |(fp)            |
00002450  69 6e 74 65 67 65 72 20  20 20 20 20 20 47 65 74  |integer      Get|
00002460  73 20 61 20 63 68 61 72  61 63 74 65 72 20 66 72  |s a character fr|
00002470  6f 6d 20 61 6e 20 69 6f  73 74 72 65 61 6d 0a 20  |om an iostream. |
00002480  20 70 75 74 63 28 63 68  2c 66 70 29 20 20 20 20  | putc(ch,fp)    |
00002490  20 20 20 20 20 6e 69 6c  20 20 20 20 20 20 20 20  |     nil        |
000024a0  20 20 57 72 69 74 65 73  20 61 20 63 68 61 72 61  |  Writes a chara|
000024b0  63 74 65 72 20 74 6f 20  61 6e 20 69 6f 73 74 72  |cter to an iostr|
000024c0  65 61 6d 0a 20 20 70 72  69 6e 74 28 78 29 20 20  |eam.  print(x)  |
000024d0  20 20 20 20 20 20 20 20  20 20 6e 69 6c 20 20 20  |          nil   |
000024e0  20 20 20 20 20 20 20 50  72 69 6e 74 73 20 61 6e  |       Prints an|
000024f0  20 6f 62 6a 65 63 74 20  74 6f 20 73 74 64 6f 75  | object to stdou|
00002500  74 0a 0a 54 68 65 20 6d  6f 64 65 20 76 61 72 69  |t..The mode vari|
00002510  61 62 6c 65 20 63 61 6e  20 74 61 6b 65 20 74 68  |able can take th|
00002520  65 20 76 61 6c 75 65 73  20 22 72 22 20 28 72 65  |e values "r" (re|
00002530  61 64 29 2c 20 22 77 22  20 28 77 72 69 74 65 29  |ad), "w" (write)|
00002540  20 61 6e 64 0a 22 61 22  20 28 61 70 70 65 6e 64  | and."a" (append|
00002550  29 2e 0a 0a 54 68 65 20  70 72 69 6e 74 20 66 75  |)...The print fu|
00002560  6e 63 74 69 6f 6e 20 63  61 6e 20 74 61 6b 65 20  |nction can take |
00002570  6d 61 6e 79 20 61 72 67  75 6d 65 6e 74 73 2c 20  |many arguments, |
00002580  73 65 70 61 72 61 74 65  64 20 62 79 20 63 6f 6d  |separated by com|
00002590  6d 61 73 2e 20 54 68 65  73 65 0a 61 72 67 75 6d  |mas. These.argum|
000025a0  65 6e 74 73 20 63 61 6e  20 68 61 76 65 20 64 69  |ents can have di|
000025b0  66 66 65 72 65 6e 74 20  74 79 70 65 73 2c 20 62  |fferent types, b|
000025c0  75 74 20 6f 6e 6c 79 20  73 74 72 69 6e 67 73 20  |ut only strings |
000025d0  61 6e 64 20 6e 75 6d 62  65 72 73 20 61 72 65 0a  |and numbers are.|
000025e0  67 65 6e 65 72 61 6c 6c  79 20 75 73 65 66 75 6c  |generally useful|
000025f0  2e 0a 0a 54 68 65 20 65  78 70 72 65 73 73 69 6f  |...The expressio|
00002600  6e 0a 0a 20 20 20 20 20  20 20 20 20 20 20 20 20  |n..             |
00002610  20 20 20 20 20 20 20 20  66 70 20 3c 3c 20 73 0a  |        fp << s.|
00002620  0a 77 69 6c 6c 20 6f 75  74 70 75 74 20 61 20 73  |.will output a s|
00002630  74 72 69 6e 67 20 73 20  74 6f 20 74 68 65 20 69  |tring s to the i|
00002640  6f 73 74 72 65 61 6d 20  66 70 2e 20 54 68 65 20  |ostream fp. The |
00002650  76 61 6c 75 65 20 6f 66  20 74 68 69 73 20 65 78  |value of this ex|
00002660  70 72 65 73 73 69 6f 6e  0a 69 73 20 66 70 2c 20  |pression.is fp, |
00002670  61 6e 64 20 3c 3c 20 61  73 73 6f 63 69 61 74 65  |and << associate|
00002680  73 20 74 6f 20 74 68 65  20 6c 65 66 74 2c 20 73  |s to the left, s|
00002690  6f 20 74 68 61 74 0a 0a  20 20 20 20 20 20 20 20  |o that..        |
000026a0  20 20 20 20 20 20 20 20  20 20 66 70 20 3c 3c 20  |          fp << |
000026b0  73 31 20 3c 3c 20 73 32  20 2e 2e 2e 2e 2e 0a 0a  |s1 << s2 .......|
000026c0  69 73 20 65 71 75 69 76  61 6c 65 6e 74 20 74 6f  |is equivalent to|
000026d0  0a 0a 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |..              |
000026e0  20 20 20 20 66 70 20 3c  3c 20 28 73 31 20 2b 20  |    fp << (s1 + |
000026f0  73 32 20 2b 20 2e 2e 2e  2e 2e 2e 20 29 0a 0a 20  |s2 + ...... ).. |
00002700  20 20 20 20 20 20 20 20  20 20 20 20 20 20 2d 2d  |              --|
00002710  2d 2d 2d 2d 2d 2d 2d 2d  2d 20 45 4e 44 20 2d 2d  |--------- END --|
00002720  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d                 |-----------|
0000272b