Home » Archimedes archive » Acorn User » AU 1997-10 A.adf » Extras » Apple][e/PD/BOB/ARMBOB/doc/Ref/Built_in
Apple][e/PD/BOB/ARMBOB/doc/Ref/Built_in
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/Built_in |
Read OK: | ✔ |
File size: | 654E bytes |
Load address: | 0000 |
Exec address: | 0000 |
File contents
ArmBob v.2.1 Reference GCW 29/11/94 ----------------- BUILT IN NAMES --------------- Operators --------- Armbob has the following operators. Ternary: c?yes:no c an integer. If c is nonzero, the expression evaluates and returns the value of yes (no is not evaluated), otherwise it evaluates and returns the value of no (yes is not evaluated). Binary: x || y x, y integers. If x is nonzero, the expression evaluates to 1, without evaluating y. Otherwise it returns 0 if y is zero and 1 otherwise. x && y x, y integers. If x is zero the expression returns 0 without evaluating y. Otherwise it returns 0 if y is zero and 1 otherwise. x | y x, y integers. Returns the bitwise OR of x and y. x ^ y x, y integers. Returns the bitwise XOR of x and y. x & y x, y integers. Returns the bitwise AND of x and y. x == y x, y both integers, strings or reals. It returns 0 if they are different and 1 if they are equal. x != y x, y both integers, strings or reals. It returns 1 if they are different and 0 if they are equal. x < y x, y both integers, strings or reals. It returns 1 if x strictly precedes y, otherwise it returns 0. x <= y x, y both integers, strings or reals. It returns 1 if x precedes or equals y, otherwise it returns 0. x >= y x, y both integers, strings or reals. It returns 1 if y precedes or equals x, otherwise it returns 0. x > y x, y both integers, strings or reals. It returns 1 if if y strictly precedes x, otherwise it returns 0. x >> y x, y both integers. It returns x arithmetically shifted right by y bits. x << y If x, y are both integers it returns x shifted left by y bits. If x is an iostream and y a string, it outputs y to x and returns the result x. x + y If x, y are both integers or both reals it returns their sum. If x, y are both strings it returns their concatenation. If either x or y is a string and the other argument is an integer, the other argument is converted to the string consisting of the single character given by the ASCII code of the bottom 8 bits and the result is the concatenation of the two strings. x - y x, y both integers or both reals. The difference is returned. x * y x, y are reals or integers. The product is returned. The type of the result is real if either x or y is a real and integer otherwise. x % y x, y both integers. The remainder is returned. x / y If x is an integer, then so must y be and an integer quotient is returned. If x is real y may be either an integer or a real and the real quotient is returned. Unary: -x x integer or real. Minus x. !x x integer. Returns 0 if x is nonzero and 1 otherwise. ~x x integer. Returns the bitwise NOT of x. Binary assignment: x = y Assign y to x, and return x. x += y Assign x+y to x, and return x. x -= y Assign x-y to x, and return x. x *= y Assign x*y to x, and return x. x /= y Assign x/y to x, and return x. x %= y Assign x%y to x, and return x. x &= y Assign x&y to x, and return x. x |= y Assign x|y to x, and return x. x ^= y Assign x^y to x, and return x. x >>= y Assign x>>y to x, and return x. x <<= y Assign x<<y to x, and return x. Unary assignment (integer expressions only): x++ Evaluate x in current expression, and then assign x+1 to x. x-- Evaluate x in current expression, and then assign x-1 to x. ++x Assign x+1 to x before further evaluation. --x Assign x-1 to x before further evaluation. Gazette of built-in values and keywords --------------------------------------- Storage and creation -------------------- $ $(x) The string stored at address x. The string is terminated by any character with ASCII code less than 32. The address x should be an integer divisible by 4. ......................................................... $$ $$(x,s) Place string s at address x. The value of s is returned. Example $$(x,$$(y,s)); stores s at both x and y. ............................................................ @ @(s) The address of the first character of the string s. This address is divisible by 4. Strings are stored as a consecutive array of bytes. Example @s = @(s = "hello"); Note that s = $(@("hello")); is equivalent to s = "hello"; . ............................................................. class Keyword introducing a class definition. Class definitions can only appear at the top level. That is to say, they cannot appear inside a class definition or a function definition. Class definitions must precede the definitions of any of their instance objects. Example class point { q; /* a vector of coordinates */ } We say that the class point has the vector q as its data. Methods for a class can be declared inside the class's definition but this is optional. They must be defined outside the class definition. For example, to add a method to point to read its first coordinate, we could have Example point::x() { return q[0]; } :: Thus, method definitions are exactly like function definitions except that the class name, followed by ::, prefixes the method name. The same method name can be used in different classes. That is to say, data and this method names are local to a class. The variable 'this' can be used in a method to refer to the instance object using the method. Example point::translate(x,y) { q[0] += x; q[1] += y; return this; } To create an instance object of a class a method must be defined with the same name as the class. Example point::point(x,y) { q = newvector(2); q[0] = x; q[1] = y; return this; } A particular point is then created by Example vertex = new point(3.5,6.0); new using the keyword 'new'. It can then be shifted by using the 'translate' method Example vertex = vertex->translate(1.0,-1.0); -> The -> operator connects an expression for an instance object with a method to produce an actual function. Example print("The x-coordinate of vertex is ",vertex->x(),"\n"); Each instance object of a class has its own private copy of the class's data, which can only be updated or accessed using a method A class can inherit the data and methods of another class. Example class particle::point { v; } particle::angular_momentum() { return (q[0]*v[1] - q[1]*v[0]);} The particle class inherits all the data and methods of the point class. static Data and methods in a class definition can be declared to be static, by placing the word 'static' in front of their declaration. Static data and methods are shared by all instances of a class, and static methods may not have the variable 'this' in their definition. A typical use of static variables would be a variable to count the number of instance objects of a certain kind. Example class foo { static total; ........... } foo::foo(...) { if (typeof(total)) total += 1; else total = 1; .............. } foo::current_number() { return total; } ............................................................... enum enum { x1 , ... , xn } This returns the integer n and assigns the values 0, 1, ... (n-1) to the n variables x1, ... xn in order. It is useful for hiding explicit indexing. Example v = newvector(enum {x,y,z}); v[x] = v[y] = v[z] = 0.0; employee = enum { name,salary,department }; fred = newvector(employee); fred[name] = "Fred"; fred[salary] = 20000; fred[department] = Widget_Handling; ................................................................. gc gc() Calling this function forces a garbage collection of the heap. The value nil is returned. ................................................................ in .. put { ... } in b put { x1 ; .... ; xn;} The expression b denotes either a string or an integer address expression specifying a buffer into which the integers or strings x1 ... xn are to be put. This is useful for defining windows, icons or menus. ................................................................... new This word is used to create a new instance object of a class. See the section on class. .................................................................... newstring newstring(n) Allocates an array of n bytes in the heap, starting on a word boundary, initializes them to zero, and returns the string which has this array as its value. ..................................................................... newvector newvector(n) Allocates space in the heap for an n-component vector, whose values are all nil, and returns this vector. ...................................................................... nil The single value of type NIL. ....................................................................... put See the section in ... put { ..... } ...................................................................... sizeof sizeof(s) Returns the number of characters in a string s, or the number of components of a vector s, as an integer. ...................................................................... static Introduces static data or method names in class definitions. See the section on class. ....................................................................... typeof typeof(x) Returns the integer code describing the type of x. The type of nil is 0, and all other values return a nonzero value. This is useful for coping with undefined vector components. Example a = typeof(a)?a:0; ..................................................................... vector vector { x1 , ... , xn } Returns a new vector with components x1, ... , xn. There must be at least one component and not more than 255 for this construction. ...................................................................... ` `(x) Returns as an integer the contents of the byte at the address x or in the string x. If s is a string `(s) is the same as s[0]. ...................................................................... `` ``(x,c) Place byte c at address x, and return c. ...................................................................... � �(x) Returns as an integer the contents of the word at the address x or in the string x. ...................................................................... �� ��(x,n) Place integer n as a word at address x, and return n. ................................................................. Condition and repetition ------------------------ break break; Jump out of the current structure. It only makes sense within a 'switch', 'do'/'repeat', 'for' or 'while' structure. ........................................................... case case x: See the section on 'switch'. ............................................................ continue continue; Start the next iteration of the smallest enclosing 'do'/'repeat', 'for' or 'while' structure. ............................................................. default See the section on 'switch'. .............................................................. do .. until/while do .. until (x); do .. while (x); Looping construct where the body is executed at least once. ............................................................... else Optional part of 'if' construct. See the section on 'if'. ................................................................ for for(<start>;<terminate>;<action>) ... iteration construct Example for(i = 0; i<sizeof(v); i++) print("v[",i,"] = ",v[i],"\n"); .................................................................. if .. else .. if (<condition>) .... conditional construct if (<condition>) .... else .... A condition is regarded as false if it is either the integer 0 or the value nil. Other values count as true. FALSE FALSE is a synonym for 0. TRUE TRUE is a synonym for 1. ................................................................... repeat .. until/while repeat ....... until <condition> repeat ....... while <condition> 'repeat' is a synonym for 'do'. See the section for 'do'. See the section for 'if' for a discussion of conditions. ................................................................... return return x; Return x from a function. return; is equivalent to return nil; Functions with no return statement return nil. ..................................................................... switch .. case .. default switch (x) If the integer or string value { x matches a value following a 'case' case y: the corresponding statements are ............. executed. Note that unless one wants case z: to drop through to the next match ............. the statements should be terminated ............... by 'break'. If no matches occur, the default: statements following 'default:' are ............. executed. The 'default' part is } optional. ................................................................... while while (x) ........ while construct. ..................................................................... Random integers --------------- rnd rnd() Returns a random positive integer. Example chance = rnd()%n; .............................................................. seed seed(n) Seeds the random number generator with the integer n and returns nil. Example seed(time()); ................................................................ Input/Output ------------ EOF EOF End of file value, -1. .......................................................... fclose fclose(fp) Closes the IOSTREAM fp and returns nil. ............................................................ fopen fopen(filename,mode) Opens a new IOSTREAM connected to the file named by 'filename', in mode 'mode' and returns either nil, if it cannot open the channel, or the IOSTREAM. The mode variable can take the values "r" (read), "w" (write) and "a" (append). .............................................................. getarg getarg(i) Return the i-th argument on the command line as a string, if there is one, and nil if there is none. The 0-th argument is the command itself (the program's pathname). Example for(i = 1; typeof(arg = getarg(i)); i++) process(arg); ................................................................ getc getc(fp) Returns a character or EOF from the IOSTREAM fp. ............................................................... input input() Returns an input string. Leading spaces are not removed. To input a number use the function val. Example print("Input a number.\n? "); x = val(input()); This should not be used in a wimp program. .................................................................. print print(x1, ... ,xn) Print the items x1, .... xn and return nil. Newlines are not automatically appended. The digrams \n, \t, \\ can be used in strings for newline, tab and \, respectively. This should not be used in a wimp program. 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 + ...... ) .................................................................... putc putc(ch,fp) Writes the character ch to the IOSTREAM fp. Returns nil. ................................................................ stderr stderr Built in IOSTREAM constants. stdin stdin stdout stdout .................................................................. Conversion ---------- val val(s) Converts as many characters of the string s to a number as it can. Decimal or hexadecimal numbers (prefixed by &) are recognized. Note that the hexadecimal digits a,b,c,d,e,f are in lower case. Reals are distinguished by a decimal point. ....................................................................... Real arithmetic functions ------------------------- acos acos(x) Arc-cosine asin asin(x) Arc-sine atan atan(x) Arc-tangent cos cos(x) Cosine exp exp(x) Exponential log log(x) Natural Logarithm sin sin(x) Sine sqrt sqrt(x) Square root tan tan(x) Tangent pi pi Built in constant. System ------ oscli oscli(s) Sends a string s to the command line interpreter. The value nil is returned. ................................................................... quit quit(s) Causes the program to exit with a message string s to stderr and returns nil. In wimp programs, wimp_closedown is called. ................................................................... start_task start_task(s) Takes a command in the string s to start up a child task, and returns its task handle. This works both from BobFiles (i.e. from a command window) or from BobTasks (i.e. from a taskwindow). This function should only be used outside wimp programs (i.e. before wimp_init or after wimp_closedown). There are other means of starting a child task from within a wimp program. .................................................................. swi swi(x,r) x is either the SWI integer or the SWI's name as a string. r is a vector of at least 8 integers. SWI x is called with register values given by the components r[0], r[1], ... r[7] and the function returns nil with the returned values of the registers in the components of r. Example getenv() { local r; swi("OS_GetEnv",r = newvector(8)); return($(r[0])); } This function to get the command string is superfluous in view of the function getarg, but it illustrates the use of swi. Note that even though a SWI may pass no values in registers, it is necessary for the second argument of swi to be a vector with at least 8 components. ................................................................... sysvar sysvar(s) Returns the string value of the string system variable s, or nil if it does not exist. Example print(sysvar("Bob$Path"),"\n"); ..................................................................... time time() Returns the first 32 bits of the time in centiseconds since the beginning of the century. Example start = time(); process(); end = time(); print("That took ",(end-start)*0.01," seconds\n"); ................................................................. wimp_closedown wimp_closedown() Programs running as wimp tasks must use the function wimp_closedown before terminating. It returns nil. ................................................................. wimp_init wimp_init(vn,name,mesg_list) vn is 100 times the version of RISC OS being used, name is the name of the wimp task, and mesg_list is a buffer, given as a string or its integer address, containing the messages, stored as words and terminated by 0, which the task wishes to receive. The function returns the task handle as an integer. After wimp_init the following function is useful for factoring wimp programs. Example event_process(maskptr,buffer,action,user) { local r, respond, go_on; r = newvector(8); go_on = TRUE; while(go_on) { r[0] = maskptr[0]; r[1] = buffer; swi("Wimp_Poll",r); go_on = (typeof(respond = action[r[0]])== BYTECODE)? respond(buffer,user,maskptr):TRUE; } wimp_closedown(); } This function event_process takes as arguments: maskptr - a 1-component vector containing the bit mask for Wimp_Poll. Handler functions can update the mask via their third argument. buffer - a buffer for wimp messages, passed to handler functions as the first argument. action - a 20-component vector of handler functions expecting 3 arguments, that return zero to cause an exit and a nonzero integer to continue. user - a user variable to pass on to handler functions as the second argument. The wimp program can now be controlled by the vector, indexed by wimp_poll reason codes, of handler functions. .................................................................. wimp_report wimp_report(s) Display string s in a dialogue box and return 0 if no key or mouse button is clicked, 1 if the OK button is selected, and 2 if the CANCEL button is selected. ------------- 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 2d 2d 2d 2d 2d |94.. -----| 00000050 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 20 42 55 49 |------------ BUI| 00000060 4c 54 20 49 4e 20 4e 41 4d 45 53 20 2d 2d 2d 2d |LT IN NAMES ----| 00000070 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0a 0a 4f 70 65 |-----------..Ope| 00000080 72 61 74 6f 72 73 0a 2d 2d 2d 2d 2d 2d 2d 2d 2d |rators.---------| 00000090 0a 0a 41 72 6d 62 6f 62 20 68 61 73 20 74 68 65 |..Armbob has the| 000000a0 20 66 6f 6c 6c 6f 77 69 6e 67 20 6f 70 65 72 61 | following opera| 000000b0 74 6f 72 73 2e 0a 0a 54 65 72 6e 61 72 79 3a 0a |tors...Ternary:.| 000000c0 20 0a 20 20 20 63 3f 79 65 73 3a 6e 6f 20 20 20 | . c?yes:no | 000000d0 20 20 63 20 61 6e 20 69 6e 74 65 67 65 72 2e 20 | c an integer. | 000000e0 49 66 20 63 20 69 73 20 6e 6f 6e 7a 65 72 6f 2c |If c is nonzero,| 000000f0 20 74 68 65 20 65 78 70 72 65 73 73 69 6f 6e 20 | the expression | 00000100 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |. | 00000110 20 65 76 61 6c 75 61 74 65 73 20 61 6e 64 20 72 | evaluates and r| 00000120 65 74 75 72 6e 73 20 74 68 65 20 76 61 6c 75 65 |eturns the value| 00000130 20 6f 66 20 79 65 73 20 28 6e 6f 20 69 73 20 0a | of yes (no is .| 00000140 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00000150 6e 6f 74 20 65 76 61 6c 75 61 74 65 64 29 2c 20 |not evaluated), | 00000160 6f 74 68 65 72 77 69 73 65 20 69 74 20 65 76 61 |otherwise it eva| 00000170 6c 75 61 74 65 73 20 61 6e 64 20 72 65 74 75 72 |luates and retur| 00000180 6e 73 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 |ns. | 00000190 20 20 20 74 68 65 20 76 61 6c 75 65 20 6f 66 20 | the value of | 000001a0 6e 6f 20 28 79 65 73 20 69 73 20 6e 6f 74 20 65 |no (yes is not e| 000001b0 76 61 6c 75 61 74 65 64 29 2e 0a 0a 42 69 6e 61 |valuated)...Bina| 000001c0 72 79 3a 0a 0a 20 20 20 20 78 20 7c 7c 20 79 20 |ry:.. x || y | 000001d0 20 20 20 20 20 78 2c 20 79 20 69 6e 74 65 67 65 | x, y intege| 000001e0 72 73 2e 20 49 66 20 78 20 69 73 20 6e 6f 6e 7a |rs. If x is nonz| 000001f0 65 72 6f 2c 20 74 68 65 20 65 78 70 72 65 73 73 |ero, the express| 00000200 69 6f 6e 20 0a 20 20 20 20 20 20 20 20 20 20 20 |ion . | 00000210 20 20 20 20 20 65 76 61 6c 75 61 74 65 73 20 74 | evaluates t| 00000220 6f 20 31 2c 20 77 69 74 68 6f 75 74 20 65 76 61 |o 1, without eva| 00000230 6c 75 61 74 69 6e 67 20 79 2e 20 4f 74 68 65 72 |luating y. Other| 00000240 77 69 73 65 20 0a 20 20 20 20 20 20 20 20 20 20 |wise . | 00000250 20 20 20 20 20 20 69 74 20 72 65 74 75 72 6e 73 | it returns| 00000260 20 30 20 69 66 20 79 20 69 73 20 7a 65 72 6f 20 | 0 if y is zero | 00000270 61 6e 64 20 31 20 6f 74 68 65 72 77 69 73 65 2e |and 1 otherwise.| 00000280 0a 0a 20 20 20 20 78 20 26 26 20 79 20 20 20 20 |.. x && y | 00000290 20 20 78 2c 20 79 20 69 6e 74 65 67 65 72 73 2e | x, y integers.| 000002a0 20 49 66 20 78 20 69 73 20 7a 65 72 6f 20 74 68 | If x is zero th| 000002b0 65 20 65 78 70 72 65 73 73 69 6f 6e 20 72 65 74 |e expression ret| 000002c0 75 72 6e 73 0a 20 20 20 20 20 20 20 20 20 20 20 |urns. | 000002d0 20 20 20 20 20 30 20 77 69 74 68 6f 75 74 20 65 | 0 without e| 000002e0 76 61 6c 75 61 74 69 6e 67 20 79 2e 20 4f 74 68 |valuating y. Oth| 000002f0 65 72 77 69 73 65 20 69 74 20 72 65 74 75 72 6e |erwise it return| 00000300 73 20 30 20 69 66 20 0a 20 20 20 20 20 20 20 20 |s 0 if . | 00000310 20 20 20 20 20 20 20 20 79 20 69 73 20 7a 65 72 | y is zer| 00000320 6f 20 61 6e 64 20 31 20 6f 74 68 65 72 77 69 73 |o and 1 otherwis| 00000330 65 2e 0a 0a 20 20 20 20 78 20 7c 20 79 20 20 20 |e... x | y | 00000340 20 20 20 20 78 2c 20 79 20 69 6e 74 65 67 65 72 | x, y integer| 00000350 73 2e 20 52 65 74 75 72 6e 73 20 74 68 65 20 62 |s. Returns the b| 00000360 69 74 77 69 73 65 20 4f 52 20 6f 66 20 78 20 61 |itwise OR of x a| 00000370 6e 64 20 79 2e 0a 0a 20 20 20 20 78 20 5e 20 79 |nd y... x ^ y| 00000380 20 20 20 20 20 20 20 78 2c 20 79 20 69 6e 74 65 | x, y inte| 00000390 67 65 72 73 2e 20 52 65 74 75 72 6e 73 20 74 68 |gers. Returns th| 000003a0 65 20 62 69 74 77 69 73 65 20 58 4f 52 20 6f 66 |e bitwise XOR of| 000003b0 20 78 20 61 6e 64 20 79 2e 0a 0a 20 20 20 20 78 | x and y... x| 000003c0 20 26 20 79 20 20 20 20 20 20 20 78 2c 20 79 20 | & y x, y | 000003d0 69 6e 74 65 67 65 72 73 2e 20 52 65 74 75 72 6e |integers. Return| 000003e0 73 20 74 68 65 20 62 69 74 77 69 73 65 20 41 4e |s the bitwise AN| 000003f0 44 20 6f 66 20 78 20 61 6e 64 20 79 2e 0a 0a 20 |D of x and y... | 00000400 20 20 20 78 20 3d 3d 20 79 20 20 20 20 20 20 78 | x == y x| 00000410 2c 20 79 20 62 6f 74 68 20 69 6e 74 65 67 65 72 |, y both integer| 00000420 73 2c 20 73 74 72 69 6e 67 73 20 6f 72 20 72 65 |s, strings or re| 00000430 61 6c 73 2e 20 49 74 20 72 65 74 75 72 6e 73 20 |als. It returns | 00000440 30 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |0. | 00000450 20 20 69 66 20 74 68 65 79 20 61 72 65 20 64 69 | if they are di| 00000460 66 66 65 72 65 6e 74 20 61 6e 64 20 31 20 69 66 |fferent and 1 if| 00000470 20 74 68 65 79 20 61 72 65 20 65 71 75 61 6c 2e | they are equal.| 00000480 0a 0a 20 20 20 20 78 20 21 3d 20 79 20 20 20 20 |.. x != y | 00000490 20 20 78 2c 20 79 20 62 6f 74 68 20 69 6e 74 65 | x, y both inte| 000004a0 67 65 72 73 2c 20 73 74 72 69 6e 67 73 20 6f 72 |gers, strings or| 000004b0 20 72 65 61 6c 73 2e 20 49 74 20 72 65 74 75 72 | reals. It retur| 000004c0 6e 73 20 31 0a 20 20 20 20 20 20 20 20 20 20 20 |ns 1. | 000004d0 20 20 20 20 20 69 66 20 74 68 65 79 20 61 72 65 | if they are| 000004e0 20 64 69 66 66 65 72 65 6e 74 20 61 6e 64 20 30 | different and 0| 000004f0 20 69 66 20 74 68 65 79 20 61 72 65 20 65 71 75 | if they are equ| 00000500 61 6c 2e 0a 0a 20 20 20 20 78 20 3c 20 79 20 20 |al... x < y | 00000510 20 20 20 20 20 78 2c 20 79 20 62 6f 74 68 20 69 | x, y both i| 00000520 6e 74 65 67 65 72 73 2c 20 73 74 72 69 6e 67 73 |ntegers, strings| 00000530 20 6f 72 20 72 65 61 6c 73 2e 20 49 74 20 72 65 | or reals. It re| 00000540 74 75 72 6e 73 20 31 0a 20 20 20 20 20 20 20 20 |turns 1. | 00000550 20 20 20 20 20 20 20 20 69 66 20 78 20 73 74 72 | if x str| 00000560 69 63 74 6c 79 20 70 72 65 63 65 64 65 73 20 79 |ictly precedes y| 00000570 2c 20 6f 74 68 65 72 77 69 73 65 20 69 74 20 72 |, otherwise it r| 00000580 65 74 75 72 6e 73 20 30 2e 0a 0a 20 20 20 20 78 |eturns 0... x| 00000590 20 3c 3d 20 79 20 20 20 20 20 20 78 2c 20 79 20 | <= y x, y | 000005a0 62 6f 74 68 20 69 6e 74 65 67 65 72 73 2c 20 73 |both integers, s| 000005b0 74 72 69 6e 67 73 20 6f 72 20 72 65 61 6c 73 2e |trings or reals.| 000005c0 20 49 74 20 72 65 74 75 72 6e 73 20 31 0a 20 20 | It returns 1. | 000005d0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 | if| 000005e0 20 78 20 70 72 65 63 65 64 65 73 20 6f 72 20 65 | x precedes or e| 000005f0 71 75 61 6c 73 20 79 2c 20 6f 74 68 65 72 77 69 |quals y, otherwi| 00000600 73 65 20 69 74 20 72 65 74 75 72 6e 73 20 30 2e |se it returns 0.| 00000610 0a 0a 20 20 20 20 78 20 3e 3d 20 79 20 20 20 20 |.. x >= y | 00000620 20 20 78 2c 20 79 20 62 6f 74 68 20 69 6e 74 65 | x, y both inte| 00000630 67 65 72 73 2c 20 73 74 72 69 6e 67 73 20 6f 72 |gers, strings or| 00000640 20 72 65 61 6c 73 2e 20 49 74 20 72 65 74 75 72 | reals. It retur| 00000650 6e 73 20 31 0a 20 20 20 20 20 20 20 20 20 20 20 |ns 1. | 00000660 20 20 20 20 20 69 66 20 79 20 70 72 65 63 65 64 | if y preced| 00000670 65 73 20 6f 72 20 65 71 75 61 6c 73 20 78 2c 20 |es or equals x, | 00000680 6f 74 68 65 72 77 69 73 65 20 69 74 20 72 65 74 |otherwise it ret| 00000690 75 72 6e 73 20 30 2e 0a 0a 20 20 20 20 78 20 3e |urns 0... x >| 000006a0 20 79 20 20 20 20 20 20 20 78 2c 20 79 20 62 6f | y x, y bo| 000006b0 74 68 20 69 6e 74 65 67 65 72 73 2c 20 73 74 72 |th integers, str| 000006c0 69 6e 67 73 20 6f 72 20 72 65 61 6c 73 2e 20 49 |ings or reals. I| 000006d0 74 20 72 65 74 75 72 6e 73 20 31 20 69 66 0a 20 |t returns 1 if. | 000006e0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 | i| 000006f0 66 20 79 20 73 74 72 69 63 74 6c 79 20 70 72 65 |f y strictly pre| 00000700 63 65 64 65 73 20 78 2c 20 6f 74 68 65 72 77 69 |cedes x, otherwi| 00000710 73 65 20 69 74 20 72 65 74 75 72 6e 73 20 30 2e |se it returns 0.| 00000720 0a 0a 20 20 20 20 78 20 3e 3e 20 79 20 20 20 20 |.. x >> y | 00000730 20 20 78 2c 20 79 20 62 6f 74 68 20 69 6e 74 65 | x, y both inte| 00000740 67 65 72 73 2e 20 49 74 20 72 65 74 75 72 6e 73 |gers. It returns| 00000750 20 78 20 61 72 69 74 68 6d 65 74 69 63 61 6c 6c | x arithmeticall| 00000760 79 20 73 68 69 66 74 65 64 0a 20 20 20 20 20 20 |y shifted. | 00000770 20 20 20 20 20 20 20 20 20 20 72 69 67 68 74 20 | right | 00000780 62 79 20 79 20 62 69 74 73 2e 0a 0a 20 20 20 20 |by y bits... | 00000790 78 20 3c 3c 20 79 20 20 20 20 20 20 49 66 20 78 |x << y If x| 000007a0 2c 20 79 20 61 72 65 20 62 6f 74 68 20 69 6e 74 |, y are both int| 000007b0 65 67 65 72 73 20 69 74 20 72 65 74 75 72 6e 73 |egers it returns| 000007c0 20 78 20 73 68 69 66 74 65 64 20 6c 65 66 74 20 | x shifted left | 000007d0 62 79 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 |by. | 000007e0 20 20 20 79 20 62 69 74 73 2e 20 49 66 20 78 20 | y bits. If x | 000007f0 69 73 20 61 6e 20 69 6f 73 74 72 65 61 6d 20 61 |is an iostream a| 00000800 6e 64 20 79 20 61 20 73 74 72 69 6e 67 2c 20 69 |nd y a string, i| 00000810 74 20 6f 75 74 70 75 74 73 0a 20 20 20 20 20 20 |t outputs. | 00000820 20 20 20 20 20 20 20 20 20 20 79 20 74 6f 20 78 | y to x| 00000830 20 61 6e 64 20 72 65 74 75 72 6e 73 20 74 68 65 | and returns the| 00000840 20 72 65 73 75 6c 74 20 78 2e 0a 0a 20 20 20 20 | result x... | 00000850 78 20 2b 20 79 20 20 20 20 20 20 20 49 66 20 78 |x + y If x| 00000860 2c 20 79 20 61 72 65 20 62 6f 74 68 20 69 6e 74 |, y are both int| 00000870 65 67 65 72 73 20 6f 72 20 62 6f 74 68 20 72 65 |egers or both re| 00000880 61 6c 73 20 69 74 20 72 65 74 75 72 6e 73 20 0a |als it returns .| 00000890 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 000008a0 74 68 65 69 72 20 73 75 6d 2e 20 49 66 20 78 2c |their sum. If x,| 000008b0 20 79 20 61 72 65 20 62 6f 74 68 20 73 74 72 69 | y are both stri| 000008c0 6e 67 73 20 69 74 20 72 65 74 75 72 6e 73 20 74 |ngs it returns t| 000008d0 68 65 69 72 20 0a 20 20 20 20 20 20 20 20 20 20 |heir . | 000008e0 20 20 20 20 20 20 63 6f 6e 63 61 74 65 6e 61 74 | concatenat| 000008f0 69 6f 6e 2e 20 49 66 20 65 69 74 68 65 72 20 78 |ion. If either x| 00000900 20 6f 72 20 79 20 69 73 20 61 20 73 74 72 69 6e | or y is a strin| 00000910 67 20 61 6e 64 20 74 68 65 20 0a 20 20 20 20 20 |g and the . | 00000920 20 20 20 20 20 20 20 20 20 20 20 6f 74 68 65 72 | other| 00000930 20 61 72 67 75 6d 65 6e 74 20 69 73 20 61 6e 20 | argument is an | 00000940 69 6e 74 65 67 65 72 2c 20 74 68 65 20 6f 74 68 |integer, the oth| 00000950 65 72 20 61 72 67 75 6d 65 6e 74 20 69 73 20 0a |er argument is .| 00000960 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00000970 63 6f 6e 76 65 72 74 65 64 20 74 6f 20 74 68 65 |converted to the| 00000980 20 73 74 72 69 6e 67 20 63 6f 6e 73 69 73 74 69 | string consisti| 00000990 6e 67 20 6f 66 20 74 68 65 20 73 69 6e 67 6c 65 |ng of the single| 000009a0 20 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | . | 000009b0 20 20 63 68 61 72 61 63 74 65 72 20 67 69 76 65 | character give| 000009c0 6e 20 62 79 20 74 68 65 20 41 53 43 49 49 20 63 |n by the ASCII c| 000009d0 6f 64 65 20 6f 66 20 74 68 65 20 62 6f 74 74 6f |ode of the botto| 000009e0 6d 20 38 20 62 69 74 73 20 0a 20 20 20 20 20 20 |m 8 bits . | 000009f0 20 20 20 20 20 20 20 20 20 20 61 6e 64 20 74 68 | and th| 00000a00 65 20 72 65 73 75 6c 74 20 69 73 20 74 68 65 20 |e result is the | 00000a10 63 6f 6e 63 61 74 65 6e 61 74 69 6f 6e 20 6f 66 |concatenation of| 00000a20 20 74 68 65 20 74 77 6f 20 73 74 72 69 6e 67 73 | the two strings| 00000a30 2e 0a 0a 20 20 20 20 78 20 2d 20 79 20 20 20 20 |... x - y | 00000a40 20 20 20 78 2c 20 79 20 62 6f 74 68 20 69 6e 74 | x, y both int| 00000a50 65 67 65 72 73 20 6f 72 20 62 6f 74 68 20 72 65 |egers or both re| 00000a60 61 6c 73 2e 20 54 68 65 20 64 69 66 66 65 72 65 |als. The differe| 00000a70 6e 63 65 20 69 73 20 0a 20 20 20 20 20 20 20 20 |nce is . | 00000a80 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 65 64 | returned| 00000a90 2e 0a 0a 20 20 20 20 78 20 2a 20 79 20 20 20 20 |... x * y | 00000aa0 20 20 20 78 2c 20 79 20 61 72 65 20 72 65 61 6c | x, y are real| 00000ab0 73 20 6f 72 20 69 6e 74 65 67 65 72 73 2e 20 54 |s or integers. T| 00000ac0 68 65 20 70 72 6f 64 75 63 74 20 69 73 20 72 65 |he product is re| 00000ad0 74 75 72 6e 65 64 2e 0a 20 20 20 20 20 20 20 20 |turned.. | 00000ae0 20 20 20 20 20 20 20 20 54 68 65 20 74 79 70 65 | The type| 00000af0 20 6f 66 20 74 68 65 20 72 65 73 75 6c 74 20 69 | of the result i| 00000b00 73 20 72 65 61 6c 20 69 66 20 65 69 74 68 65 72 |s real if either| 00000b10 20 78 20 6f 72 20 79 20 69 73 20 61 20 72 65 61 | x or y is a rea| 00000b20 6c 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |l. | 00000b30 20 20 61 6e 64 20 69 6e 74 65 67 65 72 20 6f 74 | and integer ot| 00000b40 68 65 72 77 69 73 65 2e 0a 0a 20 20 20 20 78 20 |herwise... x | 00000b50 25 20 79 20 20 20 20 20 20 20 78 2c 20 79 20 62 |% y x, y b| 00000b60 6f 74 68 20 69 6e 74 65 67 65 72 73 2e 20 54 68 |oth integers. Th| 00000b70 65 20 72 65 6d 61 69 6e 64 65 72 20 69 73 20 72 |e remainder is r| 00000b80 65 74 75 72 6e 65 64 2e 0a 0a 20 20 20 20 78 20 |eturned... x | 00000b90 2f 20 79 20 20 20 20 20 20 20 49 66 20 78 20 69 |/ y If x i| 00000ba0 73 20 61 6e 20 69 6e 74 65 67 65 72 2c 20 74 68 |s an integer, th| 00000bb0 65 6e 20 73 6f 20 6d 75 73 74 20 79 20 62 65 20 |en so must y be | 00000bc0 61 6e 64 20 61 6e 20 69 6e 74 65 67 65 72 0a 20 |and an integer. | 00000bd0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 71 | q| 00000be0 75 6f 74 69 65 6e 74 20 69 73 20 72 65 74 75 72 |uotient is retur| 00000bf0 6e 65 64 2e 20 49 66 20 78 20 69 73 20 72 65 61 |ned. If x is rea| 00000c00 6c 20 79 20 6d 61 79 20 62 65 20 65 69 74 68 65 |l y may be eithe| 00000c10 72 20 61 6e 0a 20 20 20 20 20 20 20 20 20 20 20 |r an. | 00000c20 20 20 20 20 20 69 6e 74 65 67 65 72 20 6f 72 20 | integer or | 00000c30 61 20 72 65 61 6c 20 61 6e 64 20 74 68 65 20 72 |a real and the r| 00000c40 65 61 6c 20 71 75 6f 74 69 65 6e 74 20 69 73 20 |eal quotient is | 00000c50 72 65 74 75 72 6e 65 64 2e 0a 0a 55 6e 61 72 79 |returned...Unary| 00000c60 3a 0a 0a 20 20 20 20 2d 78 20 20 20 20 20 20 20 |:.. -x | 00000c70 20 20 20 78 20 69 6e 74 65 67 65 72 20 6f 72 20 | x integer or | 00000c80 72 65 61 6c 2e 20 4d 69 6e 75 73 20 78 2e 0a 0a |real. Minus x...| 00000c90 20 20 20 20 21 78 20 20 20 20 20 20 20 20 20 20 | !x | 00000ca0 78 20 69 6e 74 65 67 65 72 2e 20 52 65 74 75 72 |x integer. Retur| 00000cb0 6e 73 20 30 20 69 66 20 78 20 69 73 20 6e 6f 6e |ns 0 if x is non| 00000cc0 7a 65 72 6f 20 61 6e 64 20 31 20 6f 74 68 65 72 |zero and 1 other| 00000cd0 77 69 73 65 2e 0a 0a 20 20 20 20 7e 78 20 20 20 |wise... ~x | 00000ce0 20 20 20 20 20 20 20 78 20 69 6e 74 65 67 65 72 | x integer| 00000cf0 2e 20 52 65 74 75 72 6e 73 20 74 68 65 20 62 69 |. Returns the bi| 00000d00 74 77 69 73 65 20 4e 4f 54 20 6f 66 20 78 2e 0a |twise NOT of x..| 00000d10 0a 42 69 6e 61 72 79 20 61 73 73 69 67 6e 6d 65 |.Binary assignme| 00000d20 6e 74 3a 0a 0a 20 20 20 20 78 20 3d 20 79 20 20 |nt:.. x = y | 00000d30 20 20 20 20 20 41 73 73 69 67 6e 20 79 20 74 6f | Assign y to| 00000d40 20 78 2c 20 61 6e 64 20 72 65 74 75 72 6e 20 78 | x, and return x| 00000d50 2e 0a 0a 20 20 20 20 78 20 2b 3d 20 79 20 20 20 |... x += y | 00000d60 20 20 20 41 73 73 69 67 6e 20 78 2b 79 20 74 6f | Assign x+y to| 00000d70 20 78 2c 20 61 6e 64 20 72 65 74 75 72 6e 20 78 | x, and return x| 00000d80 2e 0a 0a 20 20 20 20 78 20 2d 3d 20 79 20 20 20 |... x -= y | 00000d90 20 20 20 41 73 73 69 67 6e 20 78 2d 79 20 74 6f | Assign x-y to| 00000da0 20 78 2c 20 61 6e 64 20 72 65 74 75 72 6e 20 78 | x, and return x| 00000db0 2e 0a 0a 20 20 20 20 78 20 2a 3d 20 79 20 20 20 |... x *= y | 00000dc0 20 20 20 41 73 73 69 67 6e 20 78 2a 79 20 74 6f | Assign x*y to| 00000dd0 20 78 2c 20 61 6e 64 20 72 65 74 75 72 6e 20 78 | x, and return x| 00000de0 2e 0a 0a 20 20 20 20 78 20 2f 3d 20 79 20 20 20 |... x /= y | 00000df0 20 20 20 41 73 73 69 67 6e 20 78 2f 79 20 74 6f | Assign x/y to| 00000e00 20 78 2c 20 61 6e 64 20 72 65 74 75 72 6e 20 78 | x, and return x| 00000e10 2e 0a 0a 20 20 20 20 78 20 25 3d 20 79 20 20 20 |... x %= y | 00000e20 20 20 20 41 73 73 69 67 6e 20 78 25 79 20 74 6f | Assign x%y to| 00000e30 20 78 2c 20 61 6e 64 20 72 65 74 75 72 6e 20 78 | x, and return x| 00000e40 2e 0a 0a 20 20 20 20 78 20 26 3d 20 79 20 20 20 |... x &= y | 00000e50 20 20 20 41 73 73 69 67 6e 20 78 26 79 20 74 6f | Assign x&y to| 00000e60 20 78 2c 20 61 6e 64 20 72 65 74 75 72 6e 20 78 | x, and return x| 00000e70 2e 0a 0a 20 20 20 20 78 20 7c 3d 20 79 20 20 20 |... x |= y | 00000e80 20 20 20 41 73 73 69 67 6e 20 78 7c 79 20 74 6f | Assign x|y to| 00000e90 20 78 2c 20 61 6e 64 20 72 65 74 75 72 6e 20 78 | x, and return x| 00000ea0 2e 0a 0a 20 20 20 20 78 20 5e 3d 20 79 20 20 20 |... x ^= y | 00000eb0 20 20 20 41 73 73 69 67 6e 20 78 5e 79 20 74 6f | Assign x^y to| 00000ec0 20 78 2c 20 61 6e 64 20 72 65 74 75 72 6e 20 78 | x, and return x| 00000ed0 2e 0a 0a 20 20 20 20 78 20 3e 3e 3d 20 79 20 20 |... x >>= y | 00000ee0 20 20 20 41 73 73 69 67 6e 20 78 3e 3e 79 20 74 | Assign x>>y t| 00000ef0 6f 20 78 2c 20 61 6e 64 20 72 65 74 75 72 6e 20 |o x, and return | 00000f00 78 2e 0a 0a 20 20 20 20 78 20 3c 3c 3d 20 79 20 |x... x <<= y | 00000f10 20 20 20 20 41 73 73 69 67 6e 20 78 3c 3c 79 20 | Assign x<<y | 00000f20 74 6f 20 78 2c 20 61 6e 64 20 72 65 74 75 72 6e |to x, and return| 00000f30 20 78 2e 0a 0a 55 6e 61 72 79 20 61 73 73 69 67 | x...Unary assig| 00000f40 6e 6d 65 6e 74 20 28 69 6e 74 65 67 65 72 20 65 |nment (integer e| 00000f50 78 70 72 65 73 73 69 6f 6e 73 20 6f 6e 6c 79 29 |xpressions only)| 00000f60 3a 0a 0a 20 20 20 20 78 2b 2b 20 20 20 20 20 20 |:.. x++ | 00000f70 20 20 20 45 76 61 6c 75 61 74 65 20 78 20 69 6e | Evaluate x in| 00000f80 20 63 75 72 72 65 6e 74 20 65 78 70 72 65 73 73 | current express| 00000f90 69 6f 6e 2c 20 61 6e 64 20 74 68 65 6e 20 61 73 |ion, and then as| 00000fa0 73 69 67 6e 0a 20 20 20 20 20 20 20 20 20 20 20 |sign. | 00000fb0 20 20 20 20 20 78 2b 31 20 74 6f 20 78 2e 0a 0a | x+1 to x...| 00000fc0 20 20 20 20 78 2d 2d 20 20 20 20 20 20 20 20 20 | x-- | 00000fd0 45 76 61 6c 75 61 74 65 20 78 20 69 6e 20 63 75 |Evaluate x in cu| 00000fe0 72 72 65 6e 74 20 65 78 70 72 65 73 73 69 6f 6e |rrent expression| 00000ff0 2c 20 61 6e 64 20 74 68 65 6e 20 61 73 73 69 67 |, and then assig| 00001000 6e 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |n. | 00001010 20 20 78 2d 31 20 74 6f 20 78 2e 0a 0a 20 20 20 | x-1 to x... | 00001020 20 2b 2b 78 20 20 20 20 20 20 20 20 20 41 73 73 | ++x Ass| 00001030 69 67 6e 20 78 2b 31 20 74 6f 20 78 20 62 65 66 |ign x+1 to x bef| 00001040 6f 72 65 20 66 75 72 74 68 65 72 20 65 76 61 6c |ore further eval| 00001050 75 61 74 69 6f 6e 2e 0a 0a 20 20 20 20 2d 2d 78 |uation... --x| 00001060 20 20 20 20 20 20 20 20 20 41 73 73 69 67 6e 20 | Assign | 00001070 78 2d 31 20 74 6f 20 78 20 62 65 66 6f 72 65 20 |x-1 to x before | 00001080 66 75 72 74 68 65 72 20 65 76 61 6c 75 61 74 69 |further evaluati| 00001090 6f 6e 2e 0a 0a 0a 47 61 7a 65 74 74 65 20 6f 66 |on....Gazette of| 000010a0 20 62 75 69 6c 74 2d 69 6e 20 76 61 6c 75 65 73 | built-in values| 000010b0 20 61 6e 64 20 6b 65 79 77 6f 72 64 73 0a 2d 2d | and keywords.--| 000010c0 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----------------| * 000010e0 2d 2d 2d 2d 2d 0a 0a 0a 53 74 6f 72 61 67 65 20 |-----...Storage | 000010f0 61 6e 64 20 63 72 65 61 74 69 6f 6e 0a 2d 2d 2d |and creation.---| 00001100 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----------------| 00001110 2d 0a 0a 24 20 20 20 20 20 24 28 78 29 20 20 20 |-..$ $(x) | 00001120 20 20 20 20 54 68 65 20 73 74 72 69 6e 67 20 73 | The string s| 00001130 74 6f 72 65 64 20 61 74 20 61 64 64 72 65 73 73 |tored at address| 00001140 20 78 2e 20 54 68 65 20 73 74 72 69 6e 67 20 69 | x. The string i| 00001150 73 20 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 |s . | 00001160 20 20 20 20 74 65 72 6d 69 6e 61 74 65 64 20 62 | terminated b| 00001170 79 20 61 6e 79 20 63 68 61 72 61 63 74 65 72 20 |y any character | 00001180 77 69 74 68 20 41 53 43 49 49 20 63 6f 64 65 20 |with ASCII code | 00001190 6c 65 73 73 0a 20 20 20 20 20 20 20 20 20 20 20 |less. | 000011a0 20 20 20 20 20 20 74 68 61 6e 20 33 32 2e 20 54 | than 32. T| 000011b0 68 65 20 61 64 64 72 65 73 73 20 78 20 73 68 6f |he address x sho| 000011c0 75 6c 64 20 62 65 20 61 6e 20 69 6e 74 65 67 65 |uld be an intege| 000011d0 72 20 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 |r . | 000011e0 20 20 20 20 64 69 76 69 73 69 62 6c 65 20 62 79 | divisible by| 000011f0 20 34 2e 0a 20 20 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e | 4.. ..........| 00001200 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e |................| * 00001220 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 0a |................| 00001230 24 24 20 20 20 20 24 24 28 78 2c 73 29 20 20 20 |$$ $$(x,s) | 00001240 20 50 6c 61 63 65 20 73 74 72 69 6e 67 20 73 20 | Place string s | 00001250 61 74 20 61 64 64 72 65 73 73 20 78 2e 20 54 68 |at address x. Th| 00001260 65 20 76 61 6c 75 65 20 6f 66 20 73 20 69 73 0a |e value of s is.| 00001270 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00001280 20 72 65 74 75 72 6e 65 64 2e 20 0a 0a 20 20 20 | returned. .. | 00001290 20 20 20 20 20 20 20 45 78 61 6d 70 6c 65 20 20 | Example | 000012a0 20 24 24 28 78 2c 24 24 28 79 2c 73 29 29 3b 20 | $$(x,$$(y,s)); | 000012b0 73 74 6f 72 65 73 20 73 20 61 74 20 62 6f 74 68 |stores s at both| 000012c0 20 78 20 61 6e 64 20 79 2e 0a 20 20 2e 2e 2e 2e | x and y.. ....| 000012d0 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e |................| * 00001300 2e 2e 2e 2e 2e 2e 2e 2e 0a 40 20 20 20 20 20 40 |.........@ @| 00001310 28 73 29 20 20 20 20 20 20 20 54 68 65 20 61 64 |(s) The ad| 00001320 64 72 65 73 73 20 6f 66 20 74 68 65 20 66 69 72 |dress of the fir| 00001330 73 74 20 63 68 61 72 61 63 74 65 72 20 6f 66 20 |st character of | 00001340 74 68 65 20 73 74 72 69 6e 67 20 73 2e 0a 20 20 |the string s.. | 00001350 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 54 | T| 00001360 68 69 73 20 61 64 64 72 65 73 73 20 69 73 20 64 |his address is d| 00001370 69 76 69 73 69 62 6c 65 20 62 79 20 34 2e 20 53 |ivisible by 4. S| 00001380 74 72 69 6e 67 73 20 61 72 65 20 73 74 6f 72 65 |trings are store| 00001390 64 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |d. | 000013a0 20 20 20 61 73 20 61 20 63 6f 6e 73 65 63 75 74 | as a consecut| 000013b0 69 76 65 20 61 72 72 61 79 20 6f 66 20 62 79 74 |ive array of byt| 000013c0 65 73 2e 0a 0a 20 20 20 20 20 20 20 20 20 20 45 |es... E| 000013d0 78 61 6d 70 6c 65 20 20 20 40 73 20 3d 20 40 28 |xample @s = @(| 000013e0 73 20 3d 20 22 68 65 6c 6c 6f 22 29 3b 0a 0a 20 |s = "hello");.. | 000013f0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00001400 4e 6f 74 65 20 74 68 61 74 20 0a 0a 20 20 20 20 |Note that .. | 00001410 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00001420 20 20 20 20 20 73 20 3d 20 24 28 40 28 22 68 65 | s = $(@("he| 00001430 6c 6c 6f 22 29 29 3b 20 0a 0a 20 20 20 20 20 20 |llo")); .. | 00001440 20 20 20 20 20 20 20 20 20 20 20 69 73 20 65 71 | is eq| 00001450 75 69 76 61 6c 65 6e 74 20 74 6f 20 73 20 3d 20 |uivalent to s = | 00001460 22 68 65 6c 6c 6f 22 3b 20 2e 0a 0a 20 20 2e 2e |"hello"; ... ..| 00001470 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e |................| * 000014a0 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 0a 0a 63 6c 61 |.............cla| 000014b0 73 73 20 20 20 20 20 20 20 20 20 20 4b 65 79 77 |ss Keyw| 000014c0 6f 72 64 20 69 6e 74 72 6f 64 75 63 69 6e 67 20 |ord introducing | 000014d0 61 20 63 6c 61 73 73 20 64 65 66 69 6e 69 74 69 |a class definiti| 000014e0 6f 6e 2e 20 43 6c 61 73 73 0a 20 20 20 20 20 20 |on. Class. | 000014f0 20 20 20 20 20 20 20 20 20 64 65 66 69 6e 69 74 | definit| 00001500 69 6f 6e 73 20 63 61 6e 20 6f 6e 6c 79 20 61 70 |ions can only ap| 00001510 70 65 61 72 20 61 74 20 74 68 65 20 74 6f 70 20 |pear at the top | 00001520 6c 65 76 65 6c 2e 0a 20 20 20 20 20 20 20 20 20 |level.. | 00001530 20 20 20 20 20 20 54 68 61 74 20 69 73 20 74 6f | That is to| 00001540 20 73 61 79 2c 20 74 68 65 79 20 63 61 6e 6e 6f | say, they canno| 00001550 74 20 61 70 70 65 61 72 20 69 6e 73 69 64 65 20 |t appear inside | 00001560 61 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |a. | 00001570 20 63 6c 61 73 73 20 64 65 66 69 6e 69 74 69 6f | class definitio| 00001580 6e 20 6f 72 20 61 20 66 75 6e 63 74 69 6f 6e 20 |n or a function | 00001590 64 65 66 69 6e 69 74 69 6f 6e 2e 0a 20 20 20 20 |definition.. | 000015a0 20 20 20 20 20 20 20 20 20 20 20 43 6c 61 73 73 | Class| 000015b0 20 64 65 66 69 6e 69 74 69 6f 6e 73 20 6d 75 73 | definitions mus| 000015c0 74 20 70 72 65 63 65 64 65 20 74 68 65 20 64 65 |t precede the de| 000015d0 66 69 6e 69 74 69 6f 6e 73 0a 20 20 20 20 20 20 |finitions. | 000015e0 20 20 20 20 20 20 20 20 20 6f 66 20 61 6e 79 20 | of any | 000015f0 6f 66 20 74 68 65 69 72 20 69 6e 73 74 61 6e 63 |of their instanc| 00001600 65 20 6f 62 6a 65 63 74 73 2e 0a 0a 20 20 20 20 |e objects... | 00001610 20 20 45 78 61 6d 70 6c 65 20 20 20 20 63 6c 61 | Example cla| 00001620 73 73 20 70 6f 69 6e 74 0a 20 20 20 20 20 20 20 |ss point. | 00001630 20 20 20 20 20 20 20 20 20 20 7b 20 71 3b 20 20 | { q; | 00001640 20 2f 2a 20 61 20 76 65 63 74 6f 72 20 6f 66 20 | /* a vector of | 00001650 63 6f 6f 72 64 69 6e 61 74 65 73 20 2a 2f 20 7d |coordinates */ }| 00001660 0a 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |.. | 00001670 20 57 65 20 73 61 79 20 74 68 61 74 20 74 68 65 | We say that the| 00001680 20 63 6c 61 73 73 20 70 6f 69 6e 74 20 68 61 73 | class point has| 00001690 20 74 68 65 20 76 65 63 74 6f 72 20 71 20 61 73 | the vector q as| 000016a0 20 69 74 73 0a 20 20 20 20 20 20 20 20 20 20 20 | its. | 000016b0 20 20 20 20 64 61 74 61 2e 0a 0a 20 20 20 20 20 | data... | 000016c0 20 20 20 20 20 20 20 20 20 20 4d 65 74 68 6f 64 | Method| 000016d0 73 20 66 6f 72 20 61 20 63 6c 61 73 73 20 63 61 |s for a class ca| 000016e0 6e 20 62 65 20 64 65 63 6c 61 72 65 64 20 69 6e |n be declared in| 000016f0 73 69 64 65 20 74 68 65 20 63 6c 61 73 73 27 73 |side the class's| 00001700 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |. | 00001710 64 65 66 69 6e 69 74 69 6f 6e 20 62 75 74 20 74 |definition but t| 00001720 68 69 73 20 69 73 20 6f 70 74 69 6f 6e 61 6c 2e |his is optional.| 00001730 20 54 68 65 79 20 6d 75 73 74 20 62 65 20 64 65 | They must be de| 00001740 66 69 6e 65 64 20 0a 20 20 20 20 20 20 20 20 20 |fined . | 00001750 20 20 20 20 20 20 6f 75 74 73 69 64 65 20 74 68 | outside th| 00001760 65 20 63 6c 61 73 73 20 64 65 66 69 6e 69 74 69 |e class definiti| 00001770 6f 6e 2e 0a 0a 20 20 20 20 20 20 20 20 20 20 20 |on... | 00001780 20 20 20 20 46 6f 72 20 65 78 61 6d 70 6c 65 2c | For example,| 00001790 20 74 6f 20 61 64 64 20 61 20 6d 65 74 68 6f 64 | to add a method| 000017a0 20 74 6f 20 70 6f 69 6e 74 20 74 6f 20 72 65 61 | to point to rea| 000017b0 64 20 69 74 73 0a 20 20 20 20 20 20 20 20 20 20 |d its. | 000017c0 20 20 20 20 20 66 69 72 73 74 20 63 6f 6f 72 64 | first coord| 000017d0 69 6e 61 74 65 2c 20 77 65 20 63 6f 75 6c 64 20 |inate, we could | 000017e0 68 61 76 65 0a 0a 20 20 20 20 20 45 78 61 6d 70 |have.. Examp| 000017f0 6c 65 20 20 20 20 20 70 6f 69 6e 74 3a 3a 78 28 |le point::x(| 00001800 29 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |). | 00001810 20 20 20 7b 20 72 65 74 75 72 6e 20 71 5b 30 5d | { return q[0]| 00001820 3b 20 7d 0a 0a 3a 3a 20 20 20 20 20 20 20 20 20 |; }..:: | 00001830 20 20 20 20 54 68 75 73 2c 20 6d 65 74 68 6f 64 | Thus, method| 00001840 20 64 65 66 69 6e 69 74 69 6f 6e 73 20 61 72 65 | definitions are| 00001850 20 65 78 61 63 74 6c 79 20 6c 69 6b 65 20 66 75 | exactly like fu| 00001860 6e 63 74 69 6f 6e 0a 20 20 20 20 20 20 20 20 20 |nction. | 00001870 20 20 20 20 20 20 64 65 66 69 6e 69 74 69 6f 6e | definition| 00001880 73 20 65 78 63 65 70 74 20 74 68 61 74 20 74 68 |s except that th| 00001890 65 20 63 6c 61 73 73 20 6e 61 6d 65 2c 20 66 6f |e class name, fo| 000018a0 6c 6c 6f 77 65 64 20 62 79 20 3a 3a 2c 0a 20 20 |llowed by ::,. | 000018b0 20 20 20 20 20 20 20 20 20 20 20 20 20 70 72 65 | pre| 000018c0 66 69 78 65 73 20 74 68 65 20 6d 65 74 68 6f 64 |fixes the method| 000018d0 20 6e 61 6d 65 2e 20 54 68 65 20 73 61 6d 65 20 | name. The same | 000018e0 6d 65 74 68 6f 64 20 6e 61 6d 65 20 63 61 6e 20 |method name can | 000018f0 62 65 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 |be. | 00001900 20 20 75 73 65 64 20 69 6e 20 64 69 66 66 65 72 | used in differ| 00001910 65 6e 74 20 63 6c 61 73 73 65 73 2e 20 54 68 61 |ent classes. Tha| 00001920 74 20 69 73 20 74 6f 20 73 61 79 2c 20 64 61 74 |t is to say, dat| 00001930 61 20 61 6e 64 0a 74 68 69 73 20 20 20 20 20 20 |a and.this | 00001940 20 20 20 20 20 6d 65 74 68 6f 64 20 6e 61 6d 65 | method name| 00001950 73 20 61 72 65 20 6c 6f 63 61 6c 20 74 6f 20 61 |s are local to a| 00001960 20 63 6c 61 73 73 2e 20 54 68 65 20 76 61 72 69 | class. The vari| 00001970 61 62 6c 65 20 27 74 68 69 73 27 0a 20 20 20 20 |able 'this'. | 00001980 20 20 20 20 20 20 20 20 20 20 20 63 61 6e 20 62 | can b| 00001990 65 20 75 73 65 64 20 69 6e 20 61 20 6d 65 74 68 |e used in a meth| 000019a0 6f 64 20 74 6f 20 72 65 66 65 72 20 74 6f 20 74 |od to refer to t| 000019b0 68 65 20 69 6e 73 74 61 6e 63 65 20 6f 62 6a 65 |he instance obje| 000019c0 63 74 20 0a 20 20 20 20 20 20 20 20 20 20 20 20 |ct . | 000019d0 20 20 20 75 73 69 6e 67 20 74 68 65 20 6d 65 74 | using the met| 000019e0 68 6f 64 2e 0a 0a 20 20 20 20 20 45 78 61 6d 70 |hod... Examp| 000019f0 6c 65 20 20 20 20 20 70 6f 69 6e 74 3a 3a 74 72 |le point::tr| 00001a00 61 6e 73 6c 61 74 65 28 78 2c 79 29 0a 20 20 20 |anslate(x,y). | 00001a10 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7b 0a | {.| 00001a20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00001a30 20 20 71 5b 30 5d 20 2b 3d 20 78 3b 0a 20 20 20 | q[0] += x;. | 00001a40 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 71 | q| 00001a50 5b 31 5d 20 2b 3d 20 79 3b 0a 20 20 20 20 20 20 |[1] += y;. | 00001a60 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 75 | retu| 00001a70 72 6e 20 74 68 69 73 3b 0a 20 20 20 20 20 20 20 |rn this;. | 00001a80 20 20 20 20 20 20 20 20 20 20 7d 0a 0a 20 20 20 | }.. | 00001a90 20 20 20 20 20 20 20 20 20 20 20 20 54 6f 20 63 | To c| 00001aa0 72 65 61 74 65 20 61 6e 20 69 6e 73 74 61 6e 63 |reate an instanc| 00001ab0 65 20 6f 62 6a 65 63 74 20 6f 66 20 61 20 63 6c |e object of a cl| 00001ac0 61 73 73 20 61 20 6d 65 74 68 6f 64 20 6d 75 73 |ass a method mus| 00001ad0 74 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |t. | 00001ae0 20 62 65 20 64 65 66 69 6e 65 64 20 77 69 74 68 | be defined with| 00001af0 20 74 68 65 20 73 61 6d 65 20 6e 61 6d 65 20 61 | the same name a| 00001b00 73 20 74 68 65 20 63 6c 61 73 73 2e 0a 0a 20 20 |s the class... | 00001b10 20 20 20 45 78 61 6d 70 6c 65 20 20 20 20 70 6f | Example po| 00001b20 69 6e 74 3a 3a 70 6f 69 6e 74 28 78 2c 79 29 0a |int::point(x,y).| 00001b30 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00001b40 7b 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |{. | 00001b50 20 20 20 71 20 3d 20 6e 65 77 76 65 63 74 6f 72 | q = newvector| 00001b60 28 32 29 3b 0a 20 20 20 20 20 20 20 20 20 20 20 |(2);. | 00001b70 20 20 20 20 20 20 71 5b 30 5d 20 3d 20 78 3b 0a | q[0] = x;.| 00001b80 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00001b90 20 71 5b 31 5d 20 3d 20 79 3b 0a 20 20 20 20 20 | q[1] = y;. | 00001ba0 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 75 | retu| 00001bb0 72 6e 20 74 68 69 73 3b 0a 20 20 20 20 20 20 20 |rn this;. | 00001bc0 20 20 20 20 20 20 20 20 20 7d 0a 20 20 20 20 20 | }. | 00001bd0 20 20 20 20 20 20 20 20 20 20 20 0a 20 20 20 20 | . | 00001be0 20 20 20 20 20 20 20 20 20 20 20 41 20 70 61 72 | A par| 00001bf0 74 69 63 75 6c 61 72 20 70 6f 69 6e 74 20 69 73 |ticular point is| 00001c00 20 74 68 65 6e 20 63 72 65 61 74 65 64 20 62 79 | then created by| 00001c10 0a 0a 20 20 20 20 20 45 78 61 6d 70 6c 65 20 20 |.. Example | 00001c20 20 20 76 65 72 74 65 78 20 3d 20 6e 65 77 20 70 | vertex = new p| 00001c30 6f 69 6e 74 28 33 2e 35 2c 36 2e 30 29 3b 20 0a |oint(3.5,6.0); .| 00001c40 0a 6e 65 77 20 20 20 20 20 20 20 20 20 20 20 20 |.new | 00001c50 20 20 20 75 73 69 6e 67 20 74 68 65 20 6b 65 79 | using the key| 00001c60 77 6f 72 64 20 27 6e 65 77 27 2e 0a 0a 20 20 20 |word 'new'... | 00001c70 20 20 20 20 20 20 20 20 20 20 20 20 49 74 20 63 | It c| 00001c80 61 6e 20 74 68 65 6e 20 62 65 20 73 68 69 66 74 |an then be shift| 00001c90 65 64 20 62 79 20 75 73 69 6e 67 20 74 68 65 20 |ed by using the | 00001ca0 27 74 72 61 6e 73 6c 61 74 65 27 20 6d 65 74 68 |'translate' meth| 00001cb0 6f 64 0a 0a 20 20 20 20 20 45 78 61 6d 70 6c 65 |od.. Example| 00001cc0 20 20 20 20 76 65 72 74 65 78 20 3d 20 76 65 72 | vertex = ver| 00001cd0 74 65 78 2d 3e 74 72 61 6e 73 6c 61 74 65 28 31 |tex->translate(1| 00001ce0 2e 30 2c 2d 31 2e 30 29 3b 0a 0a 2d 3e 20 20 20 |.0,-1.0);..-> | 00001cf0 20 20 20 20 20 20 20 20 20 54 68 65 20 2d 3e 20 | The -> | 00001d00 6f 70 65 72 61 74 6f 72 20 63 6f 6e 6e 65 63 74 |operator connect| 00001d10 73 20 61 6e 20 65 78 70 72 65 73 73 69 6f 6e 20 |s an expression | 00001d20 66 6f 72 20 61 6e 20 69 6e 73 74 61 6e 63 65 0a |for an instance.| 00001d30 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6f 62 | ob| 00001d40 6a 65 63 74 20 77 69 74 68 20 61 20 6d 65 74 68 |ject with a meth| 00001d50 6f 64 20 74 6f 20 70 72 6f 64 75 63 65 20 61 6e |od to produce an| 00001d60 20 61 63 74 75 61 6c 20 66 75 6e 63 74 69 6f 6e | actual function| 00001d70 2e 0a 0a 20 20 20 20 20 45 78 61 6d 70 6c 65 20 |... Example | 00001d80 20 20 20 70 72 69 6e 74 28 22 54 68 65 20 78 2d | print("The x-| 00001d90 63 6f 6f 72 64 69 6e 61 74 65 20 6f 66 20 76 65 |coordinate of ve| 00001da0 72 74 65 78 20 69 73 20 22 2c 76 65 72 74 65 78 |rtex is ",vertex| 00001db0 2d 3e 78 28 29 2c 22 5c 6e 22 29 3b 0a 0a 20 20 |->x(),"\n");.. | 00001dc0 20 20 20 20 20 20 20 20 20 20 20 20 45 61 63 68 | Each| 00001dd0 20 69 6e 73 74 61 6e 63 65 20 6f 62 6a 65 63 74 | instance object| 00001de0 20 6f 66 20 61 20 63 6c 61 73 73 20 68 61 73 20 | of a class has | 00001df0 69 74 73 20 6f 77 6e 20 70 72 69 76 61 74 65 20 |its own private | 00001e00 63 6f 70 79 0a 20 20 20 20 20 20 20 20 20 20 20 |copy. | 00001e10 20 20 20 6f 66 20 74 68 65 20 63 6c 61 73 73 27 | of the class'| 00001e20 73 20 64 61 74 61 2c 20 77 68 69 63 68 20 63 61 |s data, which ca| 00001e30 6e 20 6f 6e 6c 79 20 62 65 20 75 70 64 61 74 65 |n only be update| 00001e40 64 20 6f 72 20 61 63 63 65 73 73 65 64 0a 20 20 |d or accessed. | 00001e50 20 20 20 20 20 20 20 20 20 20 20 20 75 73 69 6e | usin| 00001e60 67 20 61 20 20 6d 65 74 68 6f 64 0a 20 20 20 20 |g a method. | 00001e70 20 20 20 20 20 20 20 20 20 0a 20 20 20 20 20 20 | . | 00001e80 20 20 20 20 20 20 20 20 41 20 63 6c 61 73 73 20 | A class | 00001e90 63 61 6e 20 69 6e 68 65 72 69 74 20 74 68 65 20 |can inherit the | 00001ea0 64 61 74 61 20 61 6e 64 20 6d 65 74 68 6f 64 73 |data and methods| 00001eb0 20 6f 66 20 61 6e 6f 74 68 65 72 0a 20 20 20 20 | of another. | 00001ec0 20 20 20 20 20 20 20 20 20 20 63 6c 61 73 73 2e | class.| 00001ed0 0a 0a 20 20 20 20 20 45 78 61 6d 70 6c 65 20 20 |.. Example | 00001ee0 20 20 63 6c 61 73 73 20 70 61 72 74 69 63 6c 65 | class particle| 00001ef0 3a 3a 70 6f 69 6e 74 0a 20 20 20 20 20 20 20 20 |::point. | 00001f00 20 20 20 20 20 20 20 20 7b 20 76 3b 20 7d 0a 0a | { v; }..| 00001f10 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00001f20 70 61 72 74 69 63 6c 65 3a 3a 61 6e 67 75 6c 61 |particle::angula| 00001f30 72 5f 6d 6f 6d 65 6e 74 75 6d 28 29 0a 20 20 20 |r_momentum(). | 00001f40 20 20 20 20 20 20 20 20 20 20 20 20 20 7b 20 72 | { r| 00001f50 65 74 75 72 6e 20 28 71 5b 30 5d 2a 76 5b 31 5d |eturn (q[0]*v[1]| 00001f60 20 2d 20 71 5b 31 5d 2a 76 5b 30 5d 29 3b 7d 0a | - q[1]*v[0]);}.| 00001f70 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 54 |. T| 00001f80 68 65 20 70 61 72 74 69 63 6c 65 20 63 6c 61 73 |he particle clas| 00001f90 73 20 69 6e 68 65 72 69 74 73 20 61 6c 6c 20 74 |s inherits all t| 00001fa0 68 65 20 64 61 74 61 20 61 6e 64 20 6d 65 74 68 |he data and meth| 00001fb0 6f 64 73 0a 20 20 20 20 20 20 20 20 20 20 20 20 |ods. | 00001fc0 20 20 6f 66 20 74 68 65 20 70 6f 69 6e 74 20 63 | of the point c| 00001fd0 6c 61 73 73 2e 20 20 0a 0a 73 74 61 74 69 63 20 |lass. ..static | 00001fe0 20 20 20 20 20 20 20 44 61 74 61 20 61 6e 64 20 | Data and | 00001ff0 6d 65 74 68 6f 64 73 20 69 6e 20 61 20 63 6c 61 |methods in a cla| 00002000 73 73 20 64 65 66 69 6e 69 74 69 6f 6e 20 63 61 |ss definition ca| 00002010 6e 20 62 65 20 64 65 63 6c 61 72 65 64 0a 20 20 |n be declared. | 00002020 20 20 20 20 20 20 20 20 20 20 20 20 74 6f 20 62 | to b| 00002030 65 20 73 74 61 74 69 63 2c 20 62 79 20 70 6c 61 |e static, by pla| 00002040 63 69 6e 67 20 74 68 65 20 77 6f 72 64 20 27 73 |cing the word 's| 00002050 74 61 74 69 63 27 20 69 6e 20 66 72 6f 6e 74 0a |tatic' in front.| 00002060 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6f 66 | of| 00002070 20 74 68 65 69 72 20 64 65 63 6c 61 72 61 74 69 | their declarati| 00002080 6f 6e 2e 20 53 74 61 74 69 63 20 64 61 74 61 20 |on. Static data | 00002090 61 6e 64 20 6d 65 74 68 6f 64 73 20 61 72 65 0a |and methods are.| 000020a0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 73 68 | sh| 000020b0 61 72 65 64 20 62 79 20 61 6c 6c 20 69 6e 73 74 |ared by all inst| 000020c0 61 6e 63 65 73 20 6f 66 20 61 20 63 6c 61 73 73 |ances of a class| 000020d0 2c 20 61 6e 64 20 73 74 61 74 69 63 20 6d 65 74 |, and static met| 000020e0 68 6f 64 73 0a 20 20 20 20 20 20 20 20 20 20 20 |hods. | 000020f0 20 20 20 6d 61 79 20 6e 6f 74 20 68 61 76 65 20 | may not have | 00002100 74 68 65 20 76 61 72 69 61 62 6c 65 20 27 74 68 |the variable 'th| 00002110 69 73 27 20 69 6e 20 74 68 65 69 72 20 64 65 66 |is' in their def| 00002120 69 6e 69 74 69 6f 6e 2e 20 20 20 20 20 20 20 20 |inition. | 00002130 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00002140 20 20 20 41 20 74 79 70 69 63 61 6c 20 75 73 65 | A typical use| 00002150 20 6f 66 20 73 74 61 74 69 63 20 76 61 72 69 61 | of static varia| 00002160 62 6c 65 73 20 77 6f 75 6c 64 20 62 65 20 61 20 |bles would be a | 00002170 76 61 72 69 61 62 6c 65 0a 20 20 20 20 20 20 20 |variable. | 00002180 20 20 20 20 20 20 20 74 6f 20 63 6f 75 6e 74 20 | to count | 00002190 74 68 65 20 6e 75 6d 62 65 72 20 6f 66 20 69 6e |the number of in| 000021a0 73 74 61 6e 63 65 20 6f 62 6a 65 63 74 73 20 6f |stance objects o| 000021b0 66 20 61 20 63 65 72 74 61 69 6e 20 6b 69 6e 64 |f a certain kind| 000021c0 2e 0a 0a 20 20 20 20 20 45 78 61 6d 70 6c 65 20 |... Example | 000021d0 20 20 20 63 6c 61 73 73 20 66 6f 6f 0a 20 20 20 | class foo. | 000021e0 20 20 20 20 20 20 20 20 20 20 20 20 20 7b 0a 20 | {. | 000021f0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00002200 73 74 61 74 69 63 20 74 6f 74 61 6c 3b 0a 20 20 |static total;. | 00002210 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2e | .| 00002220 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 0a 20 20 20 20 20 |........... | 00002230 20 20 20 20 20 20 20 20 20 20 20 7d 20 0a 0a 20 | } .. | 00002240 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 66 | f| 00002250 6f 6f 3a 3a 66 6f 6f 28 2e 2e 2e 29 0a 20 20 20 |oo::foo(...). | 00002260 20 20 20 20 20 20 20 20 20 20 20 20 20 7b 0a 20 | {. | 00002270 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00002280 69 66 20 28 74 79 70 65 6f 66 28 74 6f 74 61 6c |if (typeof(total| 00002290 29 29 20 74 6f 74 61 6c 20 2b 3d 20 31 3b 0a 20 |)) total += 1;. | 000022a0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 000022b0 65 6c 73 65 20 74 6f 74 61 6c 20 3d 20 31 3b 0a |else total = 1;.| 000022c0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 000022d0 20 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 0a | ...............| 000022e0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 000022f0 7d 0a 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 |}.. | 00002300 20 20 20 66 6f 6f 3a 3a 63 75 72 72 65 6e 74 5f | foo::current_| 00002310 6e 75 6d 62 65 72 28 29 0a 20 20 20 20 20 20 20 |number(). | 00002320 20 20 20 20 20 20 20 20 20 7b 20 72 65 74 75 72 | { retur| 00002330 6e 20 74 6f 74 61 6c 3b 20 7d 0a 0a 20 20 2e 2e |n total; }.. ..| 00002340 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e |................| * 00002370 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 20 0a 0a |............. ..| 00002380 65 6e 75 6d 20 20 20 20 65 6e 75 6d 20 7b 20 78 |enum enum { x| 00002390 31 20 2c 20 2e 2e 2e 20 2c 20 78 6e 20 7d 20 20 |1 , ... , xn } | 000023a0 20 54 68 69 73 20 72 65 74 75 72 6e 73 20 74 68 | This returns th| 000023b0 65 20 69 6e 74 65 67 65 72 20 6e 20 61 6e 64 20 |e integer n and | 000023c0 61 73 73 69 67 6e 73 0a 20 20 20 20 20 20 20 20 |assigns. | 000023d0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 000023e0 20 20 20 20 20 20 20 20 20 74 68 65 20 76 61 6c | the val| 000023f0 75 65 73 20 30 2c 20 31 2c 20 2e 2e 2e 20 28 6e |ues 0, 1, ... (n| 00002400 2d 31 29 20 74 6f 20 74 68 65 20 6e 0a 20 20 20 |-1) to the n. | 00002410 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00002420 20 20 76 61 72 69 61 62 6c 65 73 20 78 31 2c 20 | variables x1, | 00002430 2e 2e 2e 20 78 6e 20 69 6e 20 6f 72 64 65 72 2e |... xn in order.| 00002440 20 49 74 20 69 73 20 75 73 65 66 75 6c 20 66 6f | It is useful fo| 00002450 72 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |r. | 00002460 20 20 20 20 20 20 20 68 69 64 69 6e 67 20 65 78 | hiding ex| 00002470 70 6c 69 63 69 74 20 69 6e 64 65 78 69 6e 67 2e |plicit indexing.| 00002480 0a 0a 20 20 20 20 20 20 20 20 45 78 61 6d 70 6c |.. Exampl| 00002490 65 20 20 20 20 20 20 76 20 3d 20 6e 65 77 76 65 |e v = newve| 000024a0 63 74 6f 72 28 65 6e 75 6d 20 7b 78 2c 79 2c 7a |ctor(enum {x,y,z| 000024b0 7d 29 3b 0a 20 20 20 20 20 20 20 20 20 20 20 20 |});. | 000024c0 20 20 20 20 20 20 20 20 20 76 5b 78 5d 20 3d 20 | v[x] = | 000024d0 76 5b 79 5d 20 3d 20 76 5b 7a 5d 20 3d 20 30 2e |v[y] = v[z] = 0.| 000024e0 30 3b 0a 0a 20 20 20 20 20 20 20 20 20 20 20 20 |0;.. | 000024f0 20 20 20 20 20 20 20 20 20 65 6d 70 6c 6f 79 65 | employe| 00002500 65 20 3d 20 65 6e 75 6d 20 7b 20 6e 61 6d 65 2c |e = enum { name,| 00002510 73 61 6c 61 72 79 2c 64 65 70 61 72 74 6d 65 6e |salary,departmen| 00002520 74 20 7d 3b 20 20 20 20 20 20 20 20 20 20 20 20 |t }; | 00002530 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00002540 20 20 20 20 20 20 20 20 20 66 72 65 64 20 3d 20 | fred = | 00002550 6e 65 77 76 65 63 74 6f 72 28 65 6d 70 6c 6f 79 |newvector(employ| 00002560 65 65 29 3b 0a 20 20 20 20 20 20 20 20 20 20 20 |ee);. | 00002570 20 20 20 20 20 20 20 20 20 20 66 72 65 64 5b 6e | fred[n| 00002580 61 6d 65 5d 20 3d 20 22 46 72 65 64 22 3b 0a 20 |ame] = "Fred";. | 00002590 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 000025a0 20 20 20 20 66 72 65 64 5b 73 61 6c 61 72 79 5d | fred[salary]| 000025b0 20 3d 20 32 30 30 30 30 3b 0a 20 20 20 20 20 20 | = 20000;. | 000025c0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 66 | f| 000025d0 72 65 64 5b 64 65 70 61 72 74 6d 65 6e 74 5d 20 |red[department] | 000025e0 3d 20 57 69 64 67 65 74 5f 48 61 6e 64 6c 69 6e |= Widget_Handlin| 000025f0 67 3b 0a 0a 20 20 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e |g;.. ..........| 00002600 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e |................| * 00002630 2e 2e 2e 2e 2e 2e 2e 20 20 20 20 20 20 0a 20 0a |....... . .| 00002640 67 63 20 20 20 20 20 20 67 63 28 29 20 20 20 20 |gc gc() | 00002650 20 20 20 20 20 43 61 6c 6c 69 6e 67 20 74 68 69 | Calling thi| 00002660 73 20 66 75 6e 63 74 69 6f 6e 20 66 6f 72 63 65 |s function force| 00002670 73 20 61 20 67 61 72 62 61 67 65 20 63 6f 6c 6c |s a garbage coll| 00002680 65 63 74 69 6f 6e 0a 20 20 20 20 20 20 20 20 20 |ection. | 00002690 20 20 20 20 20 20 20 20 20 20 20 20 6f 66 20 74 | of t| 000026a0 68 65 20 68 65 61 70 2e 20 54 68 65 20 76 61 6c |he heap. The val| 000026b0 75 65 20 6e 69 6c 20 69 73 20 72 65 74 75 72 6e |ue nil is return| 000026c0 65 64 2e 0a 0a 20 20 2e 2e 2e 2e 2e 2e 2e 2e 2e |ed... .........| 000026d0 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e |................| * 00002700 2e 2e 2e 2e 2e 2e 2e 0a 0a 69 6e 20 2e 2e 20 70 |.........in .. p| 00002710 75 74 20 7b 20 2e 2e 2e 20 7d 20 20 20 20 20 20 |ut { ... } | 00002720 20 20 20 20 20 69 6e 20 62 20 70 75 74 20 7b 20 | in b put { | 00002730 78 31 20 3b 20 2e 2e 2e 2e 20 3b 20 78 6e 3b 7d |x1 ; .... ; xn;}| 00002740 20 20 0a 0a 20 20 20 20 20 20 20 20 20 20 20 20 | .. | 00002750 20 20 20 20 20 20 20 20 20 20 54 68 65 20 65 78 | The ex| 00002760 70 72 65 73 73 69 6f 6e 20 62 20 64 65 6e 6f 74 |pression b denot| 00002770 65 73 20 65 69 74 68 65 72 20 61 20 73 74 72 69 |es either a stri| 00002780 6e 67 20 6f 72 20 61 6e 20 0a 20 20 20 20 20 20 |ng or an . | 00002790 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 000027a0 69 6e 74 65 67 65 72 20 61 64 64 72 65 73 73 20 |integer address | 000027b0 65 78 70 72 65 73 73 69 6f 6e 20 73 70 65 63 69 |expression speci| 000027c0 66 79 69 6e 67 20 61 20 62 75 66 66 65 72 20 69 |fying a buffer i| 000027d0 6e 74 6f 0a 20 20 20 20 20 20 20 20 20 20 20 20 |nto. | 000027e0 20 20 20 20 20 20 20 20 20 20 77 68 69 63 68 20 | which | 000027f0 74 68 65 20 69 6e 74 65 67 65 72 73 20 6f 72 20 |the integers or | 00002800 73 74 72 69 6e 67 73 20 78 31 20 2e 2e 2e 20 78 |strings x1 ... x| 00002810 6e 20 61 72 65 20 74 6f 20 62 65 0a 20 20 20 20 |n are to be. | 00002820 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00002830 20 20 70 75 74 2e 20 54 68 69 73 20 69 73 20 75 | put. This is u| 00002840 73 65 66 75 6c 20 66 6f 72 20 64 65 66 69 6e 69 |seful for defini| 00002850 6e 67 20 77 69 6e 64 6f 77 73 2c 20 69 63 6f 6e |ng windows, icon| 00002860 73 20 6f 72 0a 20 20 20 20 20 20 20 20 20 20 20 |s or. | 00002870 20 20 20 20 20 20 20 20 20 20 20 6d 65 6e 75 73 | menus| 00002880 2e 0a 0a 20 20 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e |... ...........| 00002890 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e |................| * 000028c0 2e 2e 2e 2e 2e 2e 2e 2e 0a 20 20 20 20 20 20 0a |......... .| 000028d0 6e 65 77 20 20 20 20 20 20 20 20 20 20 20 20 20 |new | 000028e0 20 20 20 20 20 20 54 68 69 73 20 77 6f 72 64 20 | This word | 000028f0 69 73 20 75 73 65 64 20 74 6f 20 63 72 65 61 74 |is used to creat| 00002900 65 20 61 20 6e 65 77 20 69 6e 73 74 61 6e 63 65 |e a new instance| 00002910 20 6f 62 6a 65 63 74 0a 20 20 20 20 20 20 20 20 | object. | 00002920 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6f 66 | of| 00002930 20 61 20 63 6c 61 73 73 2e 20 53 65 65 20 74 68 | a class. See th| 00002940 65 20 73 65 63 74 69 6f 6e 20 6f 6e 20 63 6c 61 |e section on cla| 00002950 73 73 2e 0a 0a 20 20 2e 2e 2e 2e 2e 2e 2e 2e 2e |ss... .........| 00002960 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e |................| * 00002990 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 0a 0a 6e 65 77 |.............new| 000029a0 73 74 72 69 6e 67 20 20 20 6e 65 77 73 74 72 69 |string newstri| 000029b0 6e 67 28 6e 29 20 20 20 20 41 6c 6c 6f 63 61 74 |ng(n) Allocat| 000029c0 65 73 20 61 6e 20 61 72 72 61 79 20 6f 66 20 6e |es an array of n| 000029d0 20 62 79 74 65 73 20 69 6e 20 74 68 65 20 68 65 | bytes in the he| 000029e0 61 70 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20 |ap,. | 000029f0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00002a00 73 74 61 72 74 69 6e 67 20 6f 6e 20 61 20 77 6f |starting on a wo| 00002a10 72 64 20 62 6f 75 6e 64 61 72 79 2c 20 69 6e 69 |rd boundary, ini| 00002a20 74 69 61 6c 69 7a 65 73 20 0a 20 20 20 20 20 20 |tializes . | 00002a30 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00002a40 20 74 68 65 6d 20 74 6f 20 7a 65 72 6f 2c 20 61 | them to zero, a| 00002a50 6e 64 20 72 65 74 75 72 6e 73 20 74 68 65 20 73 |nd returns the s| 00002a60 74 72 69 6e 67 20 77 68 69 63 68 20 68 61 73 20 |tring which has | 00002a70 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |. | 00002a80 20 20 20 20 20 20 20 20 74 68 69 73 20 61 72 72 | this arr| 00002a90 61 79 20 61 73 20 69 74 73 20 76 61 6c 75 65 2e |ay as its value.| 00002aa0 0a 0a 20 20 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e |.. ............| 00002ab0 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e |................| * 00002ae0 2e 2e 2e 2e 2e 2e 2e 2e 2e 0a 0a 6e 65 77 76 65 |...........newve| 00002af0 63 74 6f 72 20 20 6e 65 77 76 65 63 74 6f 72 28 |ctor newvector(| 00002b00 6e 29 20 20 20 20 41 6c 6c 6f 63 61 74 65 73 20 |n) Allocates | 00002b10 73 70 61 63 65 20 69 6e 20 74 68 65 20 68 65 61 |space in the hea| 00002b20 70 20 66 6f 72 20 61 6e 20 6e 2d 63 6f 6d 70 6f |p for an n-compo| 00002b30 6e 65 6e 74 0a 20 20 20 20 20 20 20 20 20 20 20 |nent. | 00002b40 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00002b50 76 65 63 74 6f 72 2c 20 77 68 6f 73 65 20 76 61 |vector, whose va| 00002b60 6c 75 65 73 20 61 72 65 20 61 6c 6c 20 6e 69 6c |lues are all nil| 00002b70 2c 20 61 6e 64 20 72 65 74 75 72 6e 73 0a 20 20 |, and returns. | 00002b80 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00002b90 20 20 20 20 20 20 74 68 69 73 20 76 65 63 74 6f | this vecto| 00002ba0 72 2e 0a 0a 20 20 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e |r... ..........| 00002bb0 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e |................| * 00002be0 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 0a 0a 6e 69 |..............ni| 00002bf0 6c 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |l | 00002c00 20 20 20 20 20 54 68 65 20 73 69 6e 67 6c 65 20 | The single | 00002c10 76 61 6c 75 65 20 6f 66 20 74 79 70 65 20 4e 49 |value of type NI| 00002c20 4c 2e 20 0a 0a 20 20 2e 2e 2e 2e 2e 2e 2e 2e 2e |L. .. .........| 00002c30 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e |................| * 00002c60 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 0a 0a |................| 00002c70 70 75 74 20 20 20 20 20 20 20 20 20 20 20 20 20 |put | 00002c80 20 20 20 20 20 20 20 53 65 65 20 74 68 65 20 73 | See the s| 00002c90 65 63 74 69 6f 6e 20 69 6e 20 2e 2e 2e 20 70 75 |ection in ... pu| 00002ca0 74 20 7b 20 2e 2e 2e 2e 2e 20 7d 0a 0a 20 20 2e |t { ..... }.. .| 00002cb0 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e |................| * 00002cf0 2e 2e 2e 2e 2e 0a 0a 73 69 7a 65 6f 66 20 20 20 |.......sizeof | 00002d00 73 69 7a 65 6f 66 28 73 29 20 20 20 20 20 52 65 |sizeof(s) Re| 00002d10 74 75 72 6e 73 20 74 68 65 20 6e 75 6d 62 65 72 |turns the number| 00002d20 20 6f 66 20 63 68 61 72 61 63 74 65 72 73 20 69 | of characters i| 00002d30 6e 20 61 20 73 74 72 69 6e 67 20 73 2c 0a 20 20 |n a string s,. | 00002d40 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00002d50 20 20 20 20 20 6f 72 20 74 68 65 20 6e 75 6d 62 | or the numb| 00002d60 65 72 20 6f 66 20 63 6f 6d 70 6f 6e 65 6e 74 73 |er of components| 00002d70 20 6f 66 20 61 20 76 65 63 74 6f 72 20 73 2c 20 | of a vector s, | 00002d80 61 73 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 |as. | 00002d90 20 20 20 20 20 20 20 20 20 20 61 6e 20 69 6e 74 | an int| 00002da0 65 67 65 72 2e 0a 0a 20 20 2e 2e 2e 2e 2e 2e 2e |eger... .......| 00002db0 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e |................| * 00002de0 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 0a |................| 00002df0 0a 73 74 61 74 69 63 20 20 20 20 20 20 20 20 20 |.static | 00002e00 20 20 20 20 20 20 20 20 49 6e 74 72 6f 64 75 63 | Introduc| 00002e10 65 73 20 73 74 61 74 69 63 20 64 61 74 61 20 6f |es static data o| 00002e20 72 20 6d 65 74 68 6f 64 20 6e 61 6d 65 73 20 69 |r method names i| 00002e30 6e 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |n. | 00002e40 20 20 20 20 20 20 20 20 20 63 6c 61 73 73 20 64 | class d| 00002e50 65 66 69 6e 69 74 69 6f 6e 73 2e 20 53 65 65 20 |efinitions. See | 00002e60 74 68 65 20 73 65 63 74 69 6f 6e 20 6f 6e 20 63 |the section on c| 00002e70 6c 61 73 73 2e 0a 0a 20 20 2e 2e 2e 2e 2e 2e 2e |lass... .......| 00002e80 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e |................| * 00002ec0 0a 0a 74 79 70 65 6f 66 20 20 74 79 70 65 6f 66 |..typeof typeof| 00002ed0 28 78 29 20 20 20 20 20 20 52 65 74 75 72 6e 73 |(x) Returns| 00002ee0 20 74 68 65 20 69 6e 74 65 67 65 72 20 63 6f 64 | the integer cod| 00002ef0 65 20 64 65 73 63 72 69 62 69 6e 67 20 74 68 65 |e describing the| 00002f00 20 74 79 70 65 20 6f 66 20 78 2e 0a 20 20 20 20 | type of x.. | 00002f10 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00002f20 20 20 20 54 68 65 20 74 79 70 65 20 6f 66 20 6e | The type of n| 00002f30 69 6c 20 69 73 20 30 2c 20 61 6e 64 20 61 6c 6c |il is 0, and all| 00002f40 20 6f 74 68 65 72 20 76 61 6c 75 65 73 0a 20 20 | other values. | 00002f50 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00002f60 20 20 20 20 20 72 65 74 75 72 6e 20 61 20 6e 6f | return a no| 00002f70 6e 7a 65 72 6f 20 76 61 6c 75 65 2e 20 54 68 69 |nzero value. Thi| 00002f80 73 20 69 73 20 75 73 65 66 75 6c 20 66 6f 72 20 |s is useful for | 00002f90 63 6f 70 69 6e 67 0a 20 20 20 20 20 20 20 20 20 |coping. | 00002fa0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 77 69 | wi| 00002fb0 74 68 20 75 6e 64 65 66 69 6e 65 64 20 76 65 63 |th undefined vec| 00002fc0 74 6f 72 20 63 6f 6d 70 6f 6e 65 6e 74 73 2e 0a |tor components..| 00002fd0 0a 20 20 20 20 20 20 20 20 20 20 45 78 61 6d 70 |. Examp| 00002fe0 6c 65 20 20 20 20 20 20 61 20 3d 20 74 79 70 65 |le a = type| 00002ff0 6f 66 28 61 29 3f 61 3a 30 3b 0a 0a 20 20 2e 2e |of(a)?a:0;.. ..| 00003000 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e |................| * 00003040 2e 2e 2e 0a 0a 76 65 63 74 6f 72 20 20 20 76 65 |.....vector ve| 00003050 63 74 6f 72 20 7b 20 78 31 20 2c 20 2e 2e 2e 20 |ctor { x1 , ... | 00003060 2c 20 78 6e 20 7d 20 20 52 65 74 75 72 6e 73 20 |, xn } Returns | 00003070 61 20 6e 65 77 20 76 65 63 74 6f 72 20 77 69 74 |a new vector wit| 00003080 68 20 63 6f 6d 70 6f 6e 65 6e 74 73 0a 20 20 20 |h components. | 00003090 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 000030b0 78 31 2c 20 2e 2e 2e 20 2c 20 78 6e 2e 20 54 68 |x1, ... , xn. Th| 000030c0 65 72 65 20 6d 75 73 74 20 62 65 20 61 74 20 6c |ere must be at l| 000030d0 65 61 73 74 0a 20 20 20 20 20 20 20 20 20 20 20 |east. | 000030e0 20 20 20 20 20 20 20 20 20 20 20 20 20 6f 6e 65 | one| 000030f0 20 63 6f 6d 70 6f 6e 65 6e 74 20 61 6e 64 20 6e | component and n| 00003100 6f 74 20 6d 6f 72 65 20 74 68 61 6e 20 32 35 35 |ot more than 255| 00003110 20 66 6f 72 20 74 68 69 73 0a 20 20 20 20 20 20 | for this. | 00003120 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00003130 20 20 63 6f 6e 73 74 72 75 63 74 69 6f 6e 2e 0a | construction..| 00003140 0a 20 20 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e |. .............| 00003150 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e |................| * 00003180 2e 2e 2e 2e 2e 2e 2e 2e 2e 0a 0a 60 20 20 20 20 |...........` | 00003190 20 20 20 60 28 78 29 20 20 20 20 20 20 20 20 20 | `(x) | 000031a0 20 20 52 65 74 75 72 6e 73 20 61 73 20 61 6e 20 | Returns as an | 000031b0 69 6e 74 65 67 65 72 20 74 68 65 20 63 6f 6e 74 |integer the cont| 000031c0 65 6e 74 73 20 6f 66 20 74 68 65 20 62 79 74 65 |ents of the byte| 000031d0 20 61 74 0a 20 20 20 20 20 20 20 20 20 20 20 20 | at. | 000031e0 20 20 20 20 20 20 20 20 20 20 20 74 68 65 20 61 | the a| 000031f0 64 64 72 65 73 73 20 78 20 6f 72 20 69 6e 20 74 |ddress x or in t| 00003200 68 65 20 73 74 72 69 6e 67 20 78 2e 20 49 66 20 |he string x. If | 00003210 73 20 69 73 20 61 20 73 74 72 69 6e 67 0a 20 20 |s is a string. | 00003220 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00003230 20 20 20 20 20 60 28 73 29 20 69 73 20 74 68 65 | `(s) is the| 00003240 20 73 61 6d 65 20 61 73 20 73 5b 30 5d 2e 0a 0a | same as s[0]...| 00003250 20 20 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e | ..............| 00003260 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e |................| * 00003290 2e 2e 2e 2e 2e 2e 2e 2e 0a 0a 60 60 20 20 20 20 |..........`` | 000032a0 20 20 60 60 28 78 2c 63 29 20 20 20 20 20 20 20 | ``(x,c) | 000032b0 20 50 6c 61 63 65 20 62 79 74 65 20 63 20 61 74 | Place byte c at| 000032c0 20 61 64 64 72 65 73 73 20 78 2c 20 61 6e 64 20 | address x, and | 000032d0 72 65 74 75 72 6e 20 63 2e 0a 0a 20 20 2e 2e 2e |return c... ...| 000032e0 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e |................| * 00003320 2e 2e 2e 0a 0a a3 20 20 20 20 20 20 20 20 a3 28 |...... .(| 00003330 78 29 20 20 20 20 20 20 20 20 20 52 65 74 75 72 |x) Retur| 00003340 6e 73 20 61 73 20 61 6e 20 69 6e 74 65 67 65 72 |ns as an integer| 00003350 20 74 68 65 20 63 6f 6e 74 65 6e 74 73 20 6f 66 | the contents of| 00003360 20 74 68 65 20 77 6f 72 64 20 61 74 20 0a 20 20 | the word at . | 00003370 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00003380 20 20 20 20 74 68 65 20 61 64 64 72 65 73 73 20 | the address | 00003390 78 20 6f 72 20 69 6e 20 74 68 65 20 73 74 72 69 |x or in the stri| 000033a0 6e 67 20 78 2e 0a 0a 20 20 2e 2e 2e 2e 2e 2e 2e |ng x... .......| 000033b0 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e |................| * 000033e0 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 0a |................| 000033f0 0a a3 a3 20 20 20 20 20 20 20 a3 a3 28 78 2c 6e |... ..(x,n| 00003400 29 20 20 20 20 20 20 50 6c 61 63 65 20 69 6e 74 |) Place int| 00003410 65 67 65 72 20 6e 20 61 73 20 61 20 77 6f 72 64 |eger n as a word| 00003420 20 61 74 20 61 64 64 72 65 73 73 20 78 2c 20 61 | at address x, a| 00003430 6e 64 20 72 65 74 75 72 6e 20 6e 2e 0a 0a 20 20 |nd return n... | 00003440 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e |................| * 00003480 2e 0a 0a 43 6f 6e 64 69 74 69 6f 6e 20 61 6e 64 |...Condition and| 00003490 20 72 65 70 65 74 69 74 69 6f 6e 0a 2d 2d 2d 2d | repetition.----| 000034a0 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----------------| 000034b0 2d 2d 2d 2d 0a 0a 62 72 65 61 6b 20 20 20 20 20 |----..break | 000034c0 20 20 20 62 72 65 61 6b 3b 20 20 20 20 20 20 4a | break; J| 000034d0 75 6d 70 20 6f 75 74 20 6f 66 20 74 68 65 20 63 |ump out of the c| 000034e0 75 72 72 65 6e 74 20 73 74 72 75 63 74 75 72 65 |urrent structure| 000034f0 2e 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |.. | 00003500 20 20 20 20 20 20 20 20 20 20 20 49 74 20 6f 6e | It on| 00003510 6c 79 20 6d 61 6b 65 73 20 73 65 6e 73 65 20 77 |ly makes sense w| 00003520 69 74 68 69 6e 20 61 20 27 73 77 69 74 63 68 27 |ithin a 'switch'| 00003530 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |,. | 00003540 20 20 20 20 20 20 20 20 20 20 20 27 64 6f 27 2f | 'do'/| 00003550 27 72 65 70 65 61 74 27 2c 20 27 66 6f 72 27 20 |'repeat', 'for' | 00003560 6f 72 20 27 77 68 69 6c 65 27 20 73 74 72 75 63 |or 'while' struc| 00003570 74 75 72 65 2e 0a 0a 20 20 2e 2e 2e 2e 2e 2e 2e |ture... .......| 00003580 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e |................| * 000035b0 2e 2e 2e 2e 0a 0a 63 61 73 65 20 20 20 20 20 20 |......case | 000035c0 20 63 61 73 65 20 78 3a 20 20 20 20 20 20 20 53 | case x: S| 000035d0 65 65 20 74 68 65 20 73 65 63 74 69 6f 6e 20 6f |ee the section o| 000035e0 6e 20 27 73 77 69 74 63 68 27 2e 0a 0a 20 20 2e |n 'switch'... .| 000035f0 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e |................| * 00003620 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 0a 0a 63 6f 6e |.............con| 00003630 74 69 6e 75 65 20 20 20 20 63 6f 6e 74 69 6e 75 |tinue continu| 00003640 65 3b 20 20 20 53 74 61 72 74 20 74 68 65 20 6e |e; Start the n| 00003650 65 78 74 20 69 74 65 72 61 74 69 6f 6e 20 6f 66 |ext iteration of| 00003660 20 74 68 65 20 73 6d 61 6c 6c 65 73 74 20 0a 20 | the smallest . | 00003670 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00003680 20 20 20 20 20 20 20 65 6e 63 6c 6f 73 69 6e 67 | enclosing| 00003690 20 27 64 6f 27 2f 27 72 65 70 65 61 74 27 2c 20 | 'do'/'repeat', | 000036a0 27 66 6f 72 27 20 6f 72 20 27 77 68 69 6c 65 27 |'for' or 'while'| 000036b0 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |. | 000036c0 20 20 20 20 20 20 20 20 20 73 74 72 75 63 74 75 | structu| 000036d0 72 65 2e 0a 0a 20 20 2e 2e 2e 2e 2e 2e 2e 2e 2e |re... .........| 000036e0 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e |................| * 00003710 2e 2e 2e 2e 0a 0a 64 65 66 61 75 6c 74 20 20 20 |......default | 00003720 20 20 20 20 20 53 65 65 20 74 68 65 20 73 65 63 | See the sec| 00003730 74 69 6f 6e 20 6f 6e 20 27 73 77 69 74 63 68 27 |tion on 'switch'| 00003740 2e 0a 0a 20 20 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e |... ...........| 00003750 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e |................| * 00003780 2e 2e 2e 0a 0a 64 6f 20 2e 2e 20 75 6e 74 69 6c |.....do .. until| 00003790 2f 77 68 69 6c 65 20 20 20 20 64 6f 20 2e 2e 20 |/while do .. | 000037a0 75 6e 74 69 6c 20 28 78 29 3b 0a 20 20 20 20 20 |until (x);. | 000037b0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 000037c0 64 6f 20 2e 2e 20 77 68 69 6c 65 20 28 78 29 3b |do .. while (x);| 000037d0 0a 0a 20 20 4c 6f 6f 70 69 6e 67 20 63 6f 6e 73 |.. Looping cons| 000037e0 74 72 75 63 74 20 77 68 65 72 65 20 74 68 65 20 |truct where the | 000037f0 62 6f 64 79 20 69 73 20 65 78 65 63 75 74 65 64 |body is executed| 00003800 20 61 74 20 6c 65 61 73 74 20 6f 6e 63 65 2e 0a | at least once..| 00003810 0a 20 20 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e |. .............| 00003820 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e |................| * 00003850 2e 2e 0a 0a 65 6c 73 65 20 20 20 20 20 20 20 20 |....else | 00003860 4f 70 74 69 6f 6e 61 6c 20 70 61 72 74 20 6f 66 |Optional part of| 00003870 20 27 69 66 27 20 63 6f 6e 73 74 72 75 63 74 2e | 'if' construct.| 00003880 20 53 65 65 20 74 68 65 20 73 65 63 74 69 6f 6e | See the section| 00003890 20 6f 6e 20 27 69 66 27 2e 0a 0a 20 20 2e 2e 2e | on 'if'... ...| 000038a0 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e |................| * 000038d0 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 0a 0a 66 |...............f| 000038e0 6f 72 20 20 20 66 6f 72 28 3c 73 74 61 72 74 3e |or for(<start>| 000038f0 3b 3c 74 65 72 6d 69 6e 61 74 65 3e 3b 3c 61 63 |;<terminate>;<ac| 00003900 74 69 6f 6e 3e 29 20 2e 2e 2e 20 20 20 20 69 74 |tion>) ... it| 00003910 65 72 61 74 69 6f 6e 20 63 6f 6e 73 74 72 75 63 |eration construc| 00003920 74 0a 0a 20 20 20 20 45 78 61 6d 70 6c 65 20 20 |t.. Example | 00003930 20 20 66 6f 72 28 69 20 3d 20 30 3b 20 69 3c 73 | for(i = 0; i<s| 00003940 69 7a 65 6f 66 28 76 29 3b 20 69 2b 2b 29 0a 20 |izeof(v); i++). | 00003950 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00003960 20 70 72 69 6e 74 28 22 76 5b 22 2c 69 2c 22 5d | print("v[",i,"]| 00003970 20 3d 20 22 2c 76 5b 69 5d 2c 22 5c 6e 22 29 3b | = ",v[i],"\n");| 00003980 0a 0a 20 20 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e |.. ............| 00003990 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e |................| * 000039c0 2e 2e 2e 2e 2e 2e 0a 0a 69 66 20 2e 2e 20 65 6c |........if .. el| 000039d0 73 65 20 2e 2e 20 20 20 20 20 69 66 20 28 3c 63 |se .. if (<c| 000039e0 6f 6e 64 69 74 69 6f 6e 3e 29 20 2e 2e 2e 2e 20 |ondition>) .... | 000039f0 20 20 20 20 20 63 6f 6e 64 69 74 69 6f 6e 61 6c | conditional| 00003a00 20 63 6f 6e 73 74 72 75 63 74 0a 0a 20 20 20 20 | construct.. | 00003a10 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 | if| 00003a20 20 28 3c 63 6f 6e 64 69 74 69 6f 6e 3e 29 20 2e | (<condition>) .| 00003a30 2e 2e 2e 20 65 6c 73 65 20 2e 2e 2e 2e 0a 0a 20 |... else ...... | 00003a40 20 20 20 41 20 63 6f 6e 64 69 74 69 6f 6e 20 69 | A condition i| 00003a50 73 20 72 65 67 61 72 64 65 64 20 61 73 20 66 61 |s regarded as fa| 00003a60 6c 73 65 20 69 66 20 69 74 20 69 73 20 65 69 74 |lse if it is eit| 00003a70 68 65 72 20 74 68 65 20 69 6e 74 65 67 65 72 20 |her the integer | 00003a80 30 0a 20 20 20 20 6f 72 20 74 68 65 20 76 61 6c |0. or the val| 00003a90 75 65 20 6e 69 6c 2e 20 4f 74 68 65 72 20 76 61 |ue nil. Other va| 00003aa0 6c 75 65 73 20 63 6f 75 6e 74 20 61 73 20 74 72 |lues count as tr| 00003ab0 75 65 2e 20 0a 0a 46 41 4c 53 45 20 20 20 20 20 |ue. ..FALSE | 00003ac0 20 20 46 41 4c 53 45 20 69 73 20 61 20 73 79 6e | FALSE is a syn| 00003ad0 6f 6e 79 6d 20 66 6f 72 20 30 2e 0a 0a 54 52 55 |onym for 0...TRU| 00003ae0 45 20 20 20 20 20 20 20 20 54 52 55 45 20 20 69 |E TRUE i| 00003af0 73 20 61 20 73 79 6e 6f 6e 79 6d 20 66 6f 72 20 |s a synonym for | 00003b00 31 2e 0a 0a 20 20 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e |1... ..........| 00003b10 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e |................| * 00003b40 2e 2e 2e 2e 2e 2e 2e 2e 2e 0a 20 20 20 20 20 20 |.......... | 00003b50 20 0a 72 65 70 65 61 74 20 2e 2e 20 75 6e 74 69 | .repeat .. unti| 00003b60 6c 2f 77 68 69 6c 65 20 20 20 20 72 65 70 65 61 |l/while repea| 00003b70 74 20 2e 2e 2e 2e 2e 2e 2e 20 75 6e 74 69 6c 20 |t ....... until | 00003b80 3c 63 6f 6e 64 69 74 69 6f 6e 3e 0a 20 20 20 20 |<condition>. | 00003b90 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00003ba0 20 20 20 20 20 72 65 70 65 61 74 20 2e 2e 2e 2e | repeat ....| 00003bb0 2e 2e 2e 20 77 68 69 6c 65 20 3c 63 6f 6e 64 69 |... while <condi| 00003bc0 74 69 6f 6e 3e 0a 0a 20 20 20 20 20 20 20 20 20 |tion>.. | 00003bd0 27 72 65 70 65 61 74 27 20 69 73 20 61 20 73 79 |'repeat' is a sy| 00003be0 6e 6f 6e 79 6d 20 66 6f 72 20 27 64 6f 27 2e 20 |nonym for 'do'. | 00003bf0 53 65 65 20 74 68 65 20 73 65 63 74 69 6f 6e 20 |See the section | 00003c00 66 6f 72 20 27 64 6f 27 2e 0a 20 20 20 20 20 20 |for 'do'.. | 00003c10 20 20 20 53 65 65 20 74 68 65 20 73 65 63 74 69 | See the secti| 00003c20 6f 6e 20 66 6f 72 20 27 69 66 27 20 66 6f 72 20 |on for 'if' for | 00003c30 61 20 64 69 73 63 75 73 73 69 6f 6e 20 6f 66 20 |a discussion of | 00003c40 63 6f 6e 64 69 74 69 6f 6e 73 2e 0a 0a 20 20 2e |conditions... .| 00003c50 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e |................| * 00003c90 2e 2e 0a 0a 72 65 74 75 72 6e 20 20 20 20 72 65 |....return re| 00003ca0 74 75 72 6e 20 78 3b 20 20 20 20 20 20 20 20 20 |turn x; | 00003cb0 52 65 74 75 72 6e 20 78 20 66 72 6f 6d 20 61 20 |Return x from a | 00003cc0 66 75 6e 63 74 69 6f 6e 2e 0a 0a 20 20 20 20 20 |function... | 00003cd0 20 20 20 20 20 72 65 74 75 72 6e 3b 20 20 20 20 | return; | 00003ce0 20 20 20 20 20 20 20 69 73 20 65 71 75 69 76 61 | is equiva| 00003cf0 6c 65 6e 74 20 74 6f 20 20 20 20 20 20 72 65 74 |lent to ret| 00003d00 75 72 6e 20 6e 69 6c 3b 0a 0a 20 20 20 20 20 46 |urn nil;.. F| 00003d10 75 6e 63 74 69 6f 6e 73 20 77 69 74 68 20 6e 6f |unctions with no| 00003d20 20 72 65 74 75 72 6e 20 73 74 61 74 65 6d 65 6e | return statemen| 00003d30 74 20 72 65 74 75 72 6e 20 6e 69 6c 2e 0a 0a 20 |t return nil... | 00003d40 20 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e | ...............| 00003d50 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e |................| * 00003d80 2e 2e 2e 2e 2e 2e 0a 0a 73 77 69 74 63 68 20 2e |........switch .| 00003d90 2e 20 63 61 73 65 20 2e 2e 20 64 65 66 61 75 6c |. case .. defaul| 00003da0 74 0a 0a 20 20 20 20 20 20 20 20 73 77 69 74 63 |t.. switc| 00003db0 68 20 28 78 29 20 20 20 20 20 20 20 20 20 20 20 |h (x) | 00003dc0 20 20 20 20 20 20 49 66 20 74 68 65 20 69 6e 74 | If the int| 00003dd0 65 67 65 72 20 6f 72 20 73 74 72 69 6e 67 20 76 |eger or string v| 00003de0 61 6c 75 65 0a 20 20 20 20 20 20 20 20 7b 20 20 |alue. { | 00003df0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00003e00 20 20 20 20 20 20 20 20 78 20 6d 61 74 63 68 65 | x matche| 00003e10 73 20 61 20 76 61 6c 75 65 20 66 6f 6c 6c 6f 77 |s a value follow| 00003e20 69 6e 67 20 61 20 27 63 61 73 65 27 0a 20 20 20 |ing a 'case'. | 00003e30 20 20 20 20 20 20 63 61 73 65 20 79 3a 20 20 20 | case y: | 00003e40 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00003e50 74 68 65 20 63 6f 72 72 65 73 70 6f 6e 64 69 6e |the correspondin| 00003e60 67 20 73 74 61 74 65 6d 65 6e 74 73 20 61 72 65 |g statements are| 00003e70 0a 20 20 20 20 20 20 20 20 20 20 20 2e 2e 2e 2e |. ....| 00003e80 2e 2e 2e 2e 2e 2e 2e 2e 2e 20 20 20 20 20 20 20 |......... | 00003e90 20 20 20 20 65 78 65 63 75 74 65 64 2e 20 4e 6f | executed. No| 00003ea0 74 65 20 74 68 61 74 20 75 6e 6c 65 73 73 20 6f |te that unless o| 00003eb0 6e 65 20 77 61 6e 74 73 0a 20 20 20 20 20 20 20 |ne wants. | 00003ec0 20 20 63 61 73 65 20 7a 3a 20 20 20 20 20 20 20 | case z: | 00003ed0 20 20 20 20 20 20 20 20 20 20 20 20 74 6f 20 64 | to d| 00003ee0 72 6f 70 20 74 68 72 6f 75 67 68 20 74 6f 20 74 |rop through to t| 00003ef0 68 65 20 6e 65 78 74 20 6d 61 74 63 68 0a 20 20 |he next match. | 00003f00 20 20 20 20 20 20 20 20 20 2e 2e 2e 2e 2e 2e 2e | .......| 00003f10 2e 2e 2e 2e 2e 2e 20 20 20 20 20 20 20 20 20 20 |...... | 00003f20 20 74 68 65 20 73 74 61 74 65 6d 65 6e 74 73 20 | the statements | 00003f30 73 68 6f 75 6c 64 20 62 65 20 74 65 72 6d 69 6e |should be termin| 00003f40 61 74 65 64 0a 20 20 20 20 20 20 20 20 20 2e 2e |ated. ..| 00003f50 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 20 20 20 |............. | 00003f60 20 20 20 20 20 20 20 20 62 79 20 27 62 72 65 61 | by 'brea| 00003f70 6b 27 2e 20 49 66 20 6e 6f 20 6d 61 74 63 68 65 |k'. If no matche| 00003f80 73 20 6f 63 63 75 72 2c 20 74 68 65 0a 20 20 20 |s occur, the. | 00003f90 20 20 20 20 20 20 64 65 66 61 75 6c 74 3a 20 20 | default: | 00003fa0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00003fb0 73 74 61 74 65 6d 65 6e 74 73 20 66 6f 6c 6c 6f |statements follo| 00003fc0 77 69 6e 67 20 27 64 65 66 61 75 6c 74 3a 27 20 |wing 'default:' | 00003fd0 61 72 65 0a 20 20 20 20 20 20 20 20 20 20 20 2e |are. .| 00003fe0 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 20 20 20 20 |............ | 00003ff0 20 20 20 20 20 20 20 65 78 65 63 75 74 65 64 2e | executed.| 00004000 20 54 68 65 20 27 64 65 66 61 75 6c 74 27 20 70 | The 'default' p| 00004010 61 72 74 20 69 73 0a 20 20 20 20 20 20 20 20 20 |art is. | 00004020 7d 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |} | 00004030 20 20 20 20 20 20 20 20 20 20 6f 70 74 69 6f 6e | option| 00004040 61 6c 2e 0a 0a 20 20 2e 2e 2e 2e 2e 2e 2e 2e 2e |al... .........| 00004050 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e |................| * 00004080 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 0a 0a 77 68 69 6c |............whil| 00004090 65 20 20 20 77 68 69 6c 65 20 28 78 29 20 2e 2e |e while (x) ..| 000040a0 2e 2e 2e 2e 2e 2e 20 20 20 20 20 20 20 77 68 69 |...... whi| 000040b0 6c 65 20 63 6f 6e 73 74 72 75 63 74 2e 20 0a 0a |le construct. ..| 000040c0 20 20 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e | ..............| 000040d0 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e |................| * 00004100 2e 2e 2e 2e 2e 2e 2e 0a 0a 52 61 6e 64 6f 6d 20 |.........Random | 00004110 69 6e 74 65 67 65 72 73 0a 2d 2d 2d 2d 2d 2d 2d |integers.-------| 00004120 2d 2d 2d 2d 2d 2d 2d 2d 0a 0a 72 6e 64 20 20 20 |--------..rnd | 00004130 72 6e 64 28 29 20 20 20 20 20 20 20 52 65 74 75 |rnd() Retu| 00004140 72 6e 73 20 61 20 72 61 6e 64 6f 6d 20 70 6f 73 |rns a random pos| 00004150 69 74 69 76 65 20 69 6e 74 65 67 65 72 2e 0a 0a |itive integer...| 00004160 20 20 20 20 20 20 45 78 61 6d 70 6c 65 20 20 20 | Example | 00004170 20 20 20 20 63 68 61 6e 63 65 20 3d 20 72 6e 64 | chance = rnd| 00004180 28 29 25 6e 3b 0a 0a 20 20 2e 2e 2e 2e 2e 2e 2e |()%n;.. .......| 00004190 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e |................| * 000041c0 2e 2e 2e 2e 2e 2e 2e 0a 0a 73 65 65 64 20 20 73 |.........seed s| 000041d0 65 65 64 28 6e 29 20 20 20 20 20 20 53 65 65 64 |eed(n) Seed| 000041e0 73 20 74 68 65 20 72 61 6e 64 6f 6d 20 6e 75 6d |s the random num| 000041f0 62 65 72 20 67 65 6e 65 72 61 74 6f 72 20 77 69 |ber generator wi| 00004200 74 68 20 74 68 65 20 69 6e 74 65 67 65 72 20 6e |th the integer n| 00004210 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |. | 00004220 20 20 20 20 61 6e 64 20 72 65 74 75 72 6e 73 20 | and returns | 00004230 6e 69 6c 2e 0a 0a 20 20 20 20 20 20 45 78 61 6d |nil... Exam| 00004240 70 6c 65 20 20 20 20 20 20 20 20 73 65 65 64 28 |ple seed(| 00004250 74 69 6d 65 28 29 29 3b 0a 0a 20 20 2e 2e 2e 2e |time());.. ....| 00004260 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e |................| * 00004290 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 0a 0a 0a 49 |...............I| 000042a0 6e 70 75 74 2f 4f 75 74 70 75 74 0a 2d 2d 2d 2d |nput/Output.----| 000042b0 2d 2d 2d 2d 2d 2d 2d 2d 0a 0a 45 4f 46 20 20 20 |--------..EOF | 000042c0 20 20 20 20 20 20 45 4f 46 20 20 20 20 20 20 20 | EOF | 000042d0 20 20 20 45 6e 64 20 6f 66 20 66 69 6c 65 20 76 | End of file v| 000042e0 61 6c 75 65 2c 20 2d 31 2e 0a 0a 20 20 2e 2e 2e |alue, -1... ...| 000042f0 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e |................| * 00004320 2e 2e 2e 2e 2e 2e 2e 0a 0a 66 63 6c 6f 73 65 20 |.........fclose | 00004330 20 20 20 20 66 63 6c 6f 73 65 28 66 70 29 20 20 | fclose(fp) | 00004340 20 20 43 6c 6f 73 65 73 20 74 68 65 20 49 4f 53 | Closes the IOS| 00004350 54 52 45 41 4d 20 66 70 20 61 6e 64 20 72 65 74 |TREAM fp and ret| 00004360 75 72 6e 73 20 6e 69 6c 2e 0a 0a 20 20 2e 2e 2e |urns nil... ...| 00004370 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e |................| * 000043a0 2e 2e 2e 2e 2e 2e 2e 2e 2e 0a 0a 66 6f 70 65 6e |...........fopen| 000043b0 20 20 20 20 20 20 66 6f 70 65 6e 28 66 69 6c 65 | fopen(file| 000043c0 6e 61 6d 65 2c 6d 6f 64 65 29 20 20 20 20 4f 70 |name,mode) Op| 000043d0 65 6e 73 20 61 20 6e 65 77 20 49 4f 53 54 52 45 |ens a new IOSTRE| 000043e0 41 4d 20 63 6f 6e 6e 65 63 74 65 64 20 74 6f 0a |AM connected to.| 000043f0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 00004410 20 20 20 74 68 65 20 66 69 6c 65 20 6e 61 6d 65 | the file name| 00004420 64 20 62 79 20 27 66 69 6c 65 6e 61 6d 65 27 2c |d by 'filename',| 00004430 20 69 6e 0a 20 20 20 20 20 20 20 20 20 20 20 20 | in. | 00004440 20 20 20 20 20 20 6d 6f 64 65 20 27 6d 6f 64 65 | mode 'mode| 00004450 27 20 61 6e 64 20 72 65 74 75 72 6e 73 20 65 69 |' and returns ei| 00004460 74 68 65 72 20 6e 69 6c 2c 20 69 66 20 69 74 20 |ther nil, if it | 00004470 63 61 6e 6e 6f 74 0a 20 20 20 20 20 20 20 20 20 |cannot. | 00004480 20 20 20 20 20 20 20 20 20 6f 70 65 6e 20 74 68 | open th| 00004490 65 20 63 68 61 6e 6e 65 6c 2c 20 6f 72 20 74 68 |e channel, or th| 000044a0 65 20 49 4f 53 54 52 45 41 4d 2e 20 54 68 65 20 |e IOSTREAM. The | 000044b0 6d 6f 64 65 20 76 61 72 69 61 62 6c 65 20 0a 20 |mode variable . | 000044c0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 000044d0 20 63 61 6e 20 74 61 6b 65 20 74 68 65 20 76 61 | can take the va| 000044e0 6c 75 65 73 20 22 72 22 20 28 72 65 61 64 29 2c |lues "r" (read),| 000044f0 20 22 77 22 20 28 77 72 69 74 65 29 20 61 6e 64 | "w" (write) and| 00004500 20 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | . | 00004510 20 20 20 20 22 61 22 20 28 61 70 70 65 6e 64 29 | "a" (append)| 00004520 2e 0a 0a 20 20 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e |... ...........| 00004530 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e |................| * 00004560 2e 2e 2e 0a 0a 67 65 74 61 72 67 20 20 67 65 74 |.....getarg get| 00004570 61 72 67 28 69 29 20 20 20 20 20 20 52 65 74 75 |arg(i) Retu| 00004580 72 6e 20 74 68 65 20 69 2d 74 68 20 61 72 67 75 |rn the i-th argu| 00004590 6d 65 6e 74 20 6f 6e 20 74 68 65 20 63 6f 6d 6d |ment on the comm| 000045a0 61 6e 64 20 6c 69 6e 65 0a 20 20 20 20 20 20 20 |and line. | 000045b0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 000045c0 61 73 20 61 20 73 74 72 69 6e 67 2c 20 69 66 20 |as a string, if | 000045d0 74 68 65 72 65 20 69 73 20 6f 6e 65 2c 20 61 6e |there is one, an| 000045e0 64 20 6e 69 6c 20 69 66 20 74 68 65 72 65 0a 20 |d nil if there. | 000045f0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00004600 20 20 20 20 20 20 69 73 20 6e 6f 6e 65 2e 20 54 | is none. T| 00004610 68 65 20 30 2d 74 68 20 61 72 67 75 6d 65 6e 74 |he 0-th argument| 00004620 20 69 73 20 74 68 65 20 63 6f 6d 6d 61 6e 64 0a | is the command.| 00004630 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00004640 20 20 20 20 20 20 20 69 74 73 65 6c 66 20 28 74 | itself (t| 00004650 68 65 20 70 72 6f 67 72 61 6d 27 73 20 70 61 74 |he program's pat| 00004660 68 6e 61 6d 65 29 2e 0a 0a 20 20 20 20 20 20 20 |hname)... | 00004670 20 45 78 61 6d 70 6c 65 20 20 20 20 66 6f 72 28 | Example for(| 00004680 69 20 3d 20 31 3b 20 74 79 70 65 6f 66 28 61 72 |i = 1; typeof(ar| 00004690 67 20 3d 20 67 65 74 61 72 67 28 69 29 29 3b 20 |g = getarg(i)); | 000046a0 69 2b 2b 29 0a 20 20 20 20 20 20 20 20 20 20 20 |i++). | 000046b0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 70 72 | pr| 000046c0 6f 63 65 73 73 28 61 72 67 29 3b 0a 0a 20 20 2e |ocess(arg);.. .| 000046d0 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e |................| * 00004700 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 0a |................| 00004710 0a 67 65 74 63 20 20 20 20 20 20 20 67 65 74 63 |.getc getc| 00004720 28 66 70 29 20 20 20 20 20 20 52 65 74 75 72 6e |(fp) Return| 00004730 73 20 61 20 63 68 61 72 61 63 74 65 72 20 6f 72 |s a character or| 00004740 20 45 4f 46 20 66 72 6f 6d 20 74 68 65 0a 20 20 | EOF from the. | 00004750 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00004760 20 20 20 20 20 20 20 49 4f 53 54 52 45 41 4d 20 | IOSTREAM | 00004770 66 70 2e 0a 0a 20 20 2e 2e 2e 2e 2e 2e 2e 2e 2e |fp... .........| 00004780 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e |................| * 000047b0 2e 2e 2e 2e 2e 2e 0a 20 20 20 20 20 20 20 20 20 |....... | 000047c0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 000047d0 20 0a 69 6e 70 75 74 20 20 20 69 6e 70 75 74 28 | .input input(| 000047e0 29 20 20 20 20 20 20 20 20 52 65 74 75 72 6e 73 |) Returns| 000047f0 20 61 6e 20 69 6e 70 75 74 20 73 74 72 69 6e 67 | an input string| 00004800 2e 20 4c 65 61 64 69 6e 67 20 73 70 61 63 65 73 |. Leading spaces| 00004810 20 61 72 65 0a 20 20 20 20 20 20 20 20 20 20 20 | are. | 00004820 20 20 20 20 20 20 20 20 20 20 20 20 6e 6f 74 20 | not | 00004830 72 65 6d 6f 76 65 64 2e 20 54 6f 20 69 6e 70 75 |removed. To inpu| 00004840 74 20 61 20 6e 75 6d 62 65 72 20 75 73 65 20 74 |t a number use t| 00004850 68 65 20 66 75 6e 63 74 69 6f 6e 20 76 61 6c 2e |he function val.| 00004860 0a 0a 20 20 20 20 20 20 20 20 20 45 78 61 6d 70 |.. Examp| 00004870 6c 65 20 20 20 20 20 20 20 20 20 70 72 69 6e 74 |le print| 00004880 28 22 49 6e 70 75 74 20 61 20 6e 75 6d 62 65 72 |("Input a number| 00004890 2e 5c 6e 3f 20 22 29 3b 0a 20 20 20 20 20 20 20 |.\n? ");. | 000048a0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 000048b0 20 20 78 20 3d 20 76 61 6c 28 69 6e 70 75 74 28 | x = val(input(| 000048c0 29 29 3b 0a 0a 20 20 20 20 20 20 20 20 20 20 20 |));.. | 000048d0 20 20 20 20 20 20 20 20 20 20 20 20 54 68 69 73 | This| 000048e0 20 73 68 6f 75 6c 64 20 6e 6f 74 20 62 65 20 75 | should not be u| 000048f0 73 65 64 20 69 6e 20 61 20 20 77 69 6d 70 20 70 |sed in a wimp p| 00004900 72 6f 67 72 61 6d 2e 0a 0a 20 20 2e 2e 2e 2e 2e |rogram... .....| 00004910 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e |................| * 00004940 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 0a 0a 70 |...............p| 00004950 72 69 6e 74 20 20 20 20 70 72 69 6e 74 28 78 31 |rint print(x1| 00004960 2c 20 2e 2e 2e 20 2c 78 6e 29 20 20 50 72 69 6e |, ... ,xn) Prin| 00004970 74 20 74 68 65 20 69 74 65 6d 73 20 78 31 2c 20 |t the items x1, | 00004980 2e 2e 2e 2e 20 78 6e 20 61 6e 64 20 72 65 74 75 |.... xn and retu| 00004990 72 6e 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 |rn. | 000049a0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 000049b0 6e 69 6c 2e 20 4e 65 77 6c 69 6e 65 73 20 61 72 |nil. Newlines ar| 000049c0 65 20 6e 6f 74 20 61 75 74 6f 6d 61 74 69 63 61 |e not automatica| 000049d0 6c 6c 79 20 0a 20 20 20 20 20 20 20 20 20 20 20 |lly . | 000049e0 20 20 20 20 20 20 20 20 20 20 20 20 20 61 70 70 | app| 000049f0 65 6e 64 65 64 2e 20 54 68 65 20 64 69 67 72 61 |ended. The digra| 00004a00 6d 73 20 5c 6e 2c 20 5c 74 2c 20 5c 5c 20 63 61 |ms \n, \t, \\ ca| 00004a10 6e 20 62 65 20 75 73 65 64 20 0a 20 20 20 20 20 |n be used . | 00004a20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00004a30 20 20 20 69 6e 20 73 74 72 69 6e 67 73 20 66 6f | in strings fo| 00004a40 72 20 6e 65 77 6c 69 6e 65 2c 20 74 61 62 20 61 |r newline, tab a| 00004a50 6e 64 20 5c 2c 20 72 65 73 70 65 63 74 69 76 65 |nd \, respective| 00004a60 6c 79 2e 0a 0a 20 20 20 20 20 20 20 20 20 20 20 |ly... | 00004a70 20 20 20 20 20 20 20 20 20 20 20 20 20 54 68 69 | Thi| 00004a80 73 20 73 68 6f 75 6c 64 20 6e 6f 74 20 62 65 20 |s should not be | 00004a90 75 73 65 64 20 69 6e 20 61 20 20 77 69 6d 70 20 |used in a wimp | 00004aa0 70 72 6f 67 72 61 6d 2e 0a 0a 20 54 68 65 20 65 |program... The e| 00004ab0 78 70 72 65 73 73 69 6f 6e 0a 0a 20 20 20 20 20 |xpression.. | 00004ac0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00004ad0 66 70 20 3c 3c 20 73 0a 0a 20 77 69 6c 6c 20 6f |fp << s.. will o| 00004ae0 75 74 70 75 74 20 61 20 73 74 72 69 6e 67 20 73 |utput a string s| 00004af0 20 74 6f 20 74 68 65 20 69 6f 73 74 72 65 61 6d | to the iostream| 00004b00 20 66 70 2e 20 54 68 65 20 76 61 6c 75 65 20 6f | fp. The value o| 00004b10 66 20 74 68 69 73 20 65 78 70 72 65 73 73 69 6f |f this expressio| 00004b20 6e 0a 20 69 73 20 66 70 2c 20 61 6e 64 20 3c 3c |n. is fp, and <<| 00004b30 20 61 73 73 6f 63 69 61 74 65 73 20 74 6f 20 74 | associates to t| 00004b40 68 65 20 6c 65 66 74 2c 20 73 6f 20 74 68 61 74 |he left, so that| 00004b50 0a 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |.. | 00004b60 20 20 20 20 66 70 20 3c 3c 20 73 31 20 3c 3c 20 | fp << s1 << | 00004b70 73 32 20 2e 2e 2e 2e 2e 0a 0a 20 69 73 20 65 71 |s2 ....... is eq| 00004b80 75 69 76 61 6c 65 6e 74 20 74 6f 0a 0a 20 20 20 |uivalent to.. | 00004b90 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 66 | f| 00004ba0 70 20 3c 3c 20 28 73 31 20 2b 20 73 32 20 2b 20 |p << (s1 + s2 + | 00004bb0 2e 2e 2e 2e 2e 2e 20 29 0a 0a 20 20 2e 2e 2e 2e |...... ).. ....| 00004bc0 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e |................| * 00004c00 0a 0a 70 75 74 63 20 20 20 20 20 20 20 70 75 74 |..putc put| 00004c10 63 28 63 68 2c 66 70 29 20 20 20 57 72 69 74 65 |c(ch,fp) Write| 00004c20 73 20 74 68 65 20 63 68 61 72 61 63 74 65 72 20 |s the character | 00004c30 63 68 20 74 6f 20 74 68 65 20 49 4f 53 54 52 45 |ch to the IOSTRE| 00004c40 41 4d 20 66 70 2e 0a 20 20 20 20 20 20 20 20 20 |AM fp.. | 00004c50 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00004c60 52 65 74 75 72 6e 73 20 6e 69 6c 2e 0a 0a 20 20 |Returns nil... | 00004c70 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e |................| * 00004cb0 0a 0a 73 74 64 65 72 72 20 20 20 20 20 20 73 74 |..stderr st| 00004cc0 64 65 72 72 20 20 20 20 20 20 42 75 69 6c 74 20 |derr Built | 00004cd0 69 6e 20 49 4f 53 54 52 45 41 4d 20 63 6f 6e 73 |in IOSTREAM cons| 00004ce0 74 61 6e 74 73 2e 0a 73 74 64 69 6e 20 20 20 20 |tants..stdin | 00004cf0 20 20 20 73 74 64 69 6e 0a 73 74 64 6f 75 74 20 | stdin.stdout | 00004d00 20 20 20 20 20 73 74 64 6f 75 74 0a 0a 20 20 2e | stdout.. .| 00004d10 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e |................| * 00004d50 2e 0a 0a 43 6f 6e 76 65 72 73 69 6f 6e 0a 2d 2d |...Conversion.--| 00004d60 2d 2d 2d 2d 2d 2d 2d 2d 0a 0a 76 61 6c 20 20 20 |--------..val | 00004d70 20 20 76 61 6c 28 73 29 20 20 20 20 20 20 20 20 | val(s) | 00004d80 20 20 43 6f 6e 76 65 72 74 73 20 61 73 20 6d 61 | Converts as ma| 00004d90 6e 79 20 63 68 61 72 61 63 74 65 72 73 20 6f 66 |ny characters of| 00004da0 20 74 68 65 20 73 74 72 69 6e 67 20 73 20 74 6f | the string s to| 00004db0 20 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | . | 00004dc0 20 20 20 20 20 20 20 20 20 20 61 20 6e 75 6d 62 | a numb| 00004dd0 65 72 20 61 73 20 69 74 20 63 61 6e 2e 20 44 65 |er as it can. De| 00004de0 63 69 6d 61 6c 20 6f 72 20 68 65 78 61 64 65 63 |cimal or hexadec| 00004df0 69 6d 61 6c 20 0a 20 20 20 20 20 20 20 20 20 20 |imal . | 00004e00 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6e 75 | nu| 00004e10 6d 62 65 72 73 20 28 70 72 65 66 69 78 65 64 20 |mbers (prefixed | 00004e20 62 79 20 26 29 20 61 72 65 20 72 65 63 6f 67 6e |by &) are recogn| 00004e30 69 7a 65 64 2e 20 4e 6f 74 65 0a 20 20 20 20 20 |ized. Note. | 00004e40 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00004e50 20 20 20 74 68 61 74 20 74 68 65 20 68 65 78 61 | that the hexa| 00004e60 64 65 63 69 6d 61 6c 20 64 69 67 69 74 73 20 61 |decimal digits a| 00004e70 2c 62 2c 63 2c 64 2c 65 2c 66 20 61 72 65 20 69 |,b,c,d,e,f are i| 00004e80 6e 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |n. | 00004e90 20 20 20 20 20 20 20 20 20 20 6c 6f 77 65 72 20 | lower | 00004ea0 63 61 73 65 2e 20 52 65 61 6c 73 20 61 72 65 20 |case. Reals are | 00004eb0 64 69 73 74 69 6e 67 75 69 73 68 65 64 20 62 79 |distinguished by| 00004ec0 20 61 20 64 65 63 69 6d 61 6c 20 0a 20 20 20 20 | a decimal . | 00004ed0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00004ee0 20 20 20 20 70 6f 69 6e 74 2e 0a 0a 20 20 2e 2e | point... ..| 00004ef0 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e |................| * 00004f30 2e 2e 2e 2e 2e 0a 0a 0a 52 65 61 6c 20 61 72 69 |........Real ari| 00004f40 74 68 6d 65 74 69 63 20 66 75 6e 63 74 69 6f 6e |thmetic function| 00004f50 73 0a 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |s.--------------| 00004f60 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0a 0a 61 63 6f |-----------..aco| 00004f70 73 20 20 20 20 61 63 6f 73 28 78 29 20 20 20 20 |s acos(x) | 00004f80 20 20 41 72 63 2d 63 6f 73 69 6e 65 0a 61 73 69 | Arc-cosine.asi| 00004f90 6e 20 20 20 20 61 73 69 6e 28 78 29 20 20 20 20 |n asin(x) | 00004fa0 20 20 41 72 63 2d 73 69 6e 65 0a 61 74 61 6e 20 | Arc-sine.atan | 00004fb0 20 20 20 61 74 61 6e 28 78 29 20 20 20 20 20 20 | atan(x) | 00004fc0 41 72 63 2d 74 61 6e 67 65 6e 74 0a 63 6f 73 20 |Arc-tangent.cos | 00004fd0 20 20 20 20 63 6f 73 28 78 29 20 20 20 20 20 20 | cos(x) | 00004fe0 20 43 6f 73 69 6e 65 0a 65 78 70 20 20 20 20 20 | Cosine.exp | 00004ff0 65 78 70 28 78 29 20 20 20 20 20 20 20 45 78 70 |exp(x) Exp| 00005000 6f 6e 65 6e 74 69 61 6c 0a 6c 6f 67 20 20 20 20 |onential.log | 00005010 20 6c 6f 67 28 78 29 20 20 20 20 20 20 20 4e 61 | log(x) Na| 00005020 74 75 72 61 6c 20 4c 6f 67 61 72 69 74 68 6d 0a |tural Logarithm.| 00005030 73 69 6e 20 20 20 20 20 73 69 6e 28 78 29 20 20 |sin sin(x) | 00005040 20 20 20 20 20 53 69 6e 65 0a 73 71 72 74 20 20 | Sine.sqrt | 00005050 20 20 73 71 72 74 28 78 29 20 20 20 20 20 20 53 | sqrt(x) S| 00005060 71 75 61 72 65 20 72 6f 6f 74 0a 74 61 6e 20 20 |quare root.tan | 00005070 20 20 20 74 61 6e 28 78 29 20 20 20 20 20 20 20 | tan(x) | 00005080 54 61 6e 67 65 6e 74 0a 0a 70 69 20 20 20 20 20 |Tangent..pi | 00005090 20 70 69 20 20 20 20 20 20 20 20 20 20 20 42 75 | pi Bu| 000050a0 69 6c 74 20 69 6e 20 63 6f 6e 73 74 61 6e 74 2e |ilt in constant.| 000050b0 0a 0a 53 79 73 74 65 6d 0a 2d 2d 2d 2d 2d 2d 0a |..System.------.| 000050c0 0a 6f 73 63 6c 69 20 20 20 20 20 20 6f 73 63 6c |.oscli oscl| 000050d0 69 28 73 29 20 20 20 20 20 20 53 65 6e 64 73 20 |i(s) Sends | 000050e0 61 20 73 74 72 69 6e 67 20 73 20 74 6f 20 74 68 |a string s to th| 000050f0 65 20 63 6f 6d 6d 61 6e 64 20 6c 69 6e 65 0a 20 |e command line. | 00005100 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00005110 20 20 20 20 20 20 20 20 69 6e 74 65 72 70 72 65 | interpre| 00005120 74 65 72 2e 20 54 68 65 20 76 61 6c 75 65 20 6e |ter. The value n| 00005130 69 6c 20 69 73 20 72 65 74 75 72 6e 65 64 2e 0a |il is returned..| 00005140 0a 20 20 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e |. .............| 00005150 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e |................| * 00005180 2e 2e 2e 2e 2e 2e 0a 0a 71 75 69 74 20 20 20 20 |........quit | 00005190 20 71 75 69 74 28 73 29 20 20 20 20 20 20 20 43 | quit(s) C| 000051a0 61 75 73 65 73 20 74 68 65 20 70 72 6f 67 72 61 |auses the progra| 000051b0 6d 20 74 6f 20 65 78 69 74 20 77 69 74 68 20 61 |m to exit with a| 000051c0 20 6d 65 73 73 61 67 65 0a 20 20 20 20 20 20 20 | message. | 000051d0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 000051e0 73 74 72 69 6e 67 20 73 20 74 6f 20 73 74 64 65 |string s to stde| 000051f0 72 72 20 61 6e 64 20 72 65 74 75 72 6e 73 20 6e |rr and returns n| 00005200 69 6c 2e 20 49 6e 20 77 69 6d 70 0a 20 20 20 20 |il. In wimp. | 00005210 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00005220 20 20 20 70 72 6f 67 72 61 6d 73 2c 20 77 69 6d | programs, wim| 00005230 70 5f 63 6c 6f 73 65 64 6f 77 6e 20 69 73 20 63 |p_closedown is c| 00005240 61 6c 6c 65 64 2e 0a 0a 20 20 2e 2e 2e 2e 2e 2e |alled... ......| 00005250 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e |................| * 00005280 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 0a 0a 73 |...............s| 00005290 74 61 72 74 5f 74 61 73 6b 20 20 73 74 61 72 74 |tart_task start| 000052a0 5f 74 61 73 6b 28 73 29 20 20 54 61 6b 65 73 20 |_task(s) Takes | 000052b0 61 20 63 6f 6d 6d 61 6e 64 20 69 6e 20 74 68 65 |a command in the| 000052c0 20 73 74 72 69 6e 67 20 73 20 74 6f 20 73 74 61 | string s to sta| 000052d0 72 74 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 |rt. | 000052e0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 75 70 | up| 000052f0 20 61 20 63 68 69 6c 64 20 74 61 73 6b 2c 20 61 | a child task, a| 00005300 6e 64 20 72 65 74 75 72 6e 73 20 69 74 73 20 74 |nd returns its t| 00005310 61 73 6b 0a 20 20 20 20 20 20 20 20 20 20 20 20 |ask. | 00005320 20 20 20 20 68 61 6e 64 6c 65 2e 20 54 68 69 73 | handle. This| 00005330 20 77 6f 72 6b 73 20 62 6f 74 68 20 66 72 6f 6d | works both from| 00005340 20 42 6f 62 46 69 6c 65 73 20 28 69 2e 65 2e 20 | BobFiles (i.e. | 00005350 66 72 6f 6d 20 61 20 0a 20 20 20 20 20 20 20 20 |from a . | 00005360 20 20 20 20 20 20 20 20 63 6f 6d 6d 61 6e 64 20 | command | 00005370 77 69 6e 64 6f 77 29 20 6f 72 20 66 72 6f 6d 20 |window) or from | 00005380 42 6f 62 54 61 73 6b 73 20 28 69 2e 65 2e 20 66 |BobTasks (i.e. f| 00005390 72 6f 6d 20 61 20 74 61 73 6b 77 69 6e 64 6f 77 |rom a taskwindow| 000053a0 29 2e 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 |).. | 000053b0 20 20 20 54 68 69 73 20 66 75 6e 63 74 69 6f 6e | This function| 000053c0 20 73 68 6f 75 6c 64 20 6f 6e 6c 79 20 62 65 20 | should only be | 000053d0 75 73 65 64 20 6f 75 74 73 69 64 65 20 77 69 6d |used outside wim| 000053e0 70 20 70 72 6f 67 72 61 6d 73 20 0a 20 20 20 20 |p programs . | 000053f0 20 20 20 20 20 20 20 20 20 20 20 20 28 69 2e 65 | (i.e| 00005400 2e 20 62 65 66 6f 72 65 20 77 69 6d 70 5f 69 6e |. before wimp_in| 00005410 69 74 20 6f 72 20 61 66 74 65 72 20 77 69 6d 70 |it or after wimp| 00005420 5f 63 6c 6f 73 65 64 6f 77 6e 29 2e 20 54 68 65 |_closedown). The| 00005430 72 65 20 61 72 65 0a 20 20 20 20 20 20 20 20 20 |re are. | 00005440 20 20 20 20 20 20 20 6f 74 68 65 72 20 6d 65 61 | other mea| 00005450 6e 73 20 6f 66 20 73 74 61 72 74 69 6e 67 20 61 |ns of starting a| 00005460 20 63 68 69 6c 64 20 74 61 73 6b 20 66 72 6f 6d | child task from| 00005470 20 77 69 74 68 69 6e 20 61 20 77 69 6d 70 20 0a | within a wimp .| 00005480 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00005490 70 72 6f 67 72 61 6d 2e 0a 0a 20 20 2e 2e 2e 2e |program... ....| 000054a0 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e |................| * 000054d0 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 0a 0a |................| 000054e0 73 77 69 20 20 20 20 73 77 69 28 78 2c 72 29 20 |swi swi(x,r) | 000054f0 20 20 20 20 78 20 69 73 20 65 69 74 68 65 72 20 | x is either | 00005500 74 68 65 20 53 57 49 20 69 6e 74 65 67 65 72 20 |the SWI integer | 00005510 6f 72 20 74 68 65 20 53 57 49 27 73 20 6e 61 6d |or the SWI's nam| 00005520 65 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |e. | 00005530 20 20 20 20 20 20 61 73 20 61 20 73 74 72 69 6e | as a strin| 00005540 67 2e 20 72 20 69 73 20 61 20 76 65 63 74 6f 72 |g. r is a vector| 00005550 20 6f 66 20 61 74 20 6c 65 61 73 74 20 38 20 69 | of at least 8 i| 00005560 6e 74 65 67 65 72 73 2e 0a 20 20 20 20 20 20 20 |ntegers.. | 00005570 20 20 53 57 49 20 78 20 69 73 20 63 61 6c 6c 65 | SWI x is calle| 00005580 64 20 77 69 74 68 20 72 65 67 69 73 74 65 72 20 |d with register | 00005590 76 61 6c 75 65 73 20 67 69 76 65 6e 20 62 79 20 |values given by | 000055a0 74 68 65 20 63 6f 6d 70 6f 6e 65 6e 74 73 20 0a |the components .| 000055b0 20 20 20 20 20 20 20 20 20 72 5b 30 5d 2c 20 72 | r[0], r| 000055c0 5b 31 5d 2c 20 2e 2e 2e 20 72 5b 37 5d 20 61 6e |[1], ... r[7] an| 000055d0 64 20 74 68 65 20 66 75 6e 63 74 69 6f 6e 20 72 |d the function r| 000055e0 65 74 75 72 6e 73 20 6e 69 6c 20 77 69 74 68 20 |eturns nil with | 000055f0 74 68 65 20 72 65 74 75 72 6e 65 64 20 0a 20 20 |the returned . | 00005600 20 20 20 20 20 20 20 76 61 6c 75 65 73 20 6f 66 | values of| 00005610 20 74 68 65 20 72 65 67 69 73 74 65 72 73 20 69 | the registers i| 00005620 6e 20 74 68 65 20 63 6f 6d 70 6f 6e 65 6e 74 73 |n the components| 00005630 20 6f 66 20 72 2e 20 0a 0a 20 20 20 20 20 20 45 | of r. .. E| 00005640 78 61 6d 70 6c 65 20 20 20 20 20 20 20 20 20 20 |xample | 00005650 20 20 67 65 74 65 6e 76 28 29 0a 20 20 20 20 20 | getenv(). | 00005660 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00005670 20 20 20 20 7b 0a 20 20 20 20 20 20 20 20 20 20 | {. | 00005680 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00005690 6c 6f 63 61 6c 20 72 3b 0a 20 20 20 20 20 20 20 |local r;. | 000056a0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 000056b0 20 20 20 73 77 69 28 22 4f 53 5f 47 65 74 45 6e | swi("OS_GetEn| 000056c0 76 22 2c 72 20 3d 20 6e 65 77 76 65 63 74 6f 72 |v",r = newvector| 000056d0 28 38 29 29 3b 0a 20 20 20 20 20 20 20 20 20 20 |(8));. | 000056e0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 000056f0 72 65 74 75 72 6e 28 24 28 72 5b 30 5d 29 29 3b |return($(r[0]));| 00005700 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |. | 00005710 20 20 20 20 20 20 20 20 20 20 7d 0a 0a 20 20 20 | }.. | 00005720 20 20 20 54 68 69 73 20 66 75 6e 63 74 69 6f 6e | This function| 00005730 20 74 6f 20 67 65 74 20 74 68 65 20 63 6f 6d 6d | to get the comm| 00005740 61 6e 64 20 73 74 72 69 6e 67 20 69 73 20 73 75 |and string is su| 00005750 70 65 72 66 6c 75 6f 75 73 20 69 6e 20 76 69 65 |perfluous in vie| 00005760 77 0a 20 20 20 20 20 20 6f 66 20 74 68 65 20 66 |w. of the f| 00005770 75 6e 63 74 69 6f 6e 20 67 65 74 61 72 67 2c 20 |unction getarg, | 00005780 62 75 74 20 69 74 20 69 6c 6c 75 73 74 72 61 74 |but it illustrat| 00005790 65 73 20 74 68 65 20 75 73 65 20 6f 66 20 73 77 |es the use of sw| 000057a0 69 2e 0a 0a 20 20 20 20 20 20 4e 6f 74 65 20 74 |i... Note t| 000057b0 68 61 74 20 65 76 65 6e 20 74 68 6f 75 67 68 20 |hat even though | 000057c0 61 20 53 57 49 20 6d 61 79 20 70 61 73 73 20 6e |a SWI may pass n| 000057d0 6f 20 76 61 6c 75 65 73 20 69 6e 20 72 65 67 69 |o values in regi| 000057e0 73 74 65 72 73 2c 20 0a 20 20 20 20 20 20 69 74 |sters, . it| 000057f0 20 69 73 20 6e 65 63 65 73 73 61 72 79 20 66 6f | is necessary fo| 00005800 72 20 74 68 65 20 73 65 63 6f 6e 64 20 61 72 67 |r the second arg| 00005810 75 6d 65 6e 74 20 6f 66 20 73 77 69 20 74 6f 20 |ument of swi to | 00005820 62 65 20 61 20 76 65 63 74 6f 72 20 0a 20 20 20 |be a vector . | 00005830 20 20 20 77 69 74 68 20 61 74 20 6c 65 61 73 74 | with at least| 00005840 20 38 20 63 6f 6d 70 6f 6e 65 6e 74 73 2e 0a 0a | 8 components...| 00005850 20 20 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e | ..............| 00005860 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e |................| * 00005890 2e 2e 2e 2e 2e 0a 0a 0a 73 79 73 76 61 72 20 20 |........sysvar | 000058a0 20 73 79 73 76 61 72 28 73 29 20 20 20 20 20 52 | sysvar(s) R| 000058b0 65 74 75 72 6e 73 20 74 68 65 20 73 74 72 69 6e |eturns the strin| 000058c0 67 20 76 61 6c 75 65 20 6f 66 20 74 68 65 20 73 |g value of the s| 000058d0 74 72 69 6e 67 20 73 79 73 74 65 6d 0a 20 20 20 |tring system. | 000058e0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 000058f0 20 20 20 20 76 61 72 69 61 62 6c 65 20 73 2c 20 | variable s, | 00005900 6f 72 20 6e 69 6c 20 69 66 20 69 74 20 64 6f 65 |or nil if it doe| 00005910 73 20 6e 6f 74 20 65 78 69 73 74 2e 0a 0a 20 20 |s not exist... | 00005920 20 20 20 20 20 20 45 78 61 6d 70 6c 65 20 20 20 | Example | 00005930 20 20 20 20 20 20 70 72 69 6e 74 28 73 79 73 76 | print(sysv| 00005940 61 72 28 22 42 6f 62 24 50 61 74 68 22 29 2c 22 |ar("Bob$Path"),"| 00005950 5c 6e 22 29 3b 0a 0a 20 20 2e 2e 2e 2e 2e 2e 2e |\n");.. .......| 00005960 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e |................| * 00005990 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 0a 0a |................| 000059a0 74 69 6d 65 20 20 74 69 6d 65 28 29 20 20 20 20 |time time() | 000059b0 20 20 20 20 20 20 52 65 74 75 72 6e 73 20 74 68 | Returns th| 000059c0 65 20 66 69 72 73 74 20 33 32 20 62 69 74 73 20 |e first 32 bits | 000059d0 6f 66 20 74 68 65 20 74 69 6d 65 20 69 6e 20 0a |of the time in .| 000059e0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 000059f0 20 20 20 20 20 20 63 65 6e 74 69 73 65 63 6f 6e | centisecon| 00005a00 64 73 20 73 69 6e 63 65 20 74 68 65 20 62 65 67 |ds since the beg| 00005a10 69 6e 6e 69 6e 67 20 6f 66 20 74 68 65 20 63 65 |inning of the ce| 00005a20 6e 74 75 72 79 2e 0a 0a 20 20 20 20 20 20 20 45 |ntury... E| 00005a30 78 61 6d 70 6c 65 20 20 20 20 20 20 20 20 73 74 |xample st| 00005a40 61 72 74 20 3d 20 74 69 6d 65 28 29 3b 0a 20 20 |art = time();. | 00005a50 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00005a60 20 20 20 20 70 72 6f 63 65 73 73 28 29 3b 0a 20 | process();. | 00005a70 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00005a80 20 20 20 20 20 65 6e 64 20 3d 20 74 69 6d 65 28 | end = time(| 00005a90 29 3b 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 |);. | 00005aa0 20 20 20 20 20 20 20 20 20 70 72 69 6e 74 28 22 | print("| 00005ab0 54 68 61 74 20 74 6f 6f 6b 20 22 2c 28 65 6e 64 |That took ",(end| 00005ac0 2d 73 74 61 72 74 29 2a 30 2e 30 31 2c 22 20 73 |-start)*0.01," s| 00005ad0 65 63 6f 6e 64 73 5c 6e 22 29 3b 0a 0a 20 20 2e |econds\n");.. .| 00005ae0 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e |................| * 00005b20 0a 0a 77 69 6d 70 5f 63 6c 6f 73 65 64 6f 77 6e |..wimp_closedown| 00005b30 20 20 20 20 20 20 77 69 6d 70 5f 63 6c 6f 73 65 | wimp_close| 00005b40 64 6f 77 6e 28 29 20 20 20 20 20 20 50 72 6f 67 |down() Prog| 00005b50 72 61 6d 73 20 72 75 6e 6e 69 6e 67 20 61 73 20 |rams running as | 00005b60 77 69 6d 70 20 0a 20 20 20 20 20 20 20 20 20 20 |wimp . | 00005b70 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 00005b90 74 61 73 6b 73 20 6d 75 73 74 20 75 73 65 20 74 |tasks must use t| 00005ba0 68 65 20 66 75 6e 63 74 69 6f 6e 0a 20 20 20 20 |he function. | 00005bb0 20 20 20 20 20 20 20 20 20 77 69 6d 70 5f 63 6c | wimp_cl| 00005bc0 6f 73 65 64 6f 77 6e 20 62 65 66 6f 72 65 20 74 |osedown before t| 00005bd0 65 72 6d 69 6e 61 74 69 6e 67 2e 20 49 74 20 72 |erminating. It r| 00005be0 65 74 75 72 6e 73 20 6e 69 6c 2e 0a 0a 20 20 2e |eturns nil... .| 00005bf0 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e |................| * 00005c30 0a 0a 77 69 6d 70 5f 69 6e 69 74 20 20 20 77 69 |..wimp_init wi| 00005c40 6d 70 5f 69 6e 69 74 28 76 6e 2c 6e 61 6d 65 2c |mp_init(vn,name,| 00005c50 6d 65 73 67 5f 6c 69 73 74 29 20 20 20 20 20 76 |mesg_list) v| 00005c60 6e 20 69 73 20 31 30 30 20 74 69 6d 65 73 20 74 |n is 100 times t| 00005c70 68 65 20 0a 20 20 20 20 20 20 20 20 20 20 20 20 |he . | 00005c80 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 00005ca0 20 76 65 72 73 69 6f 6e 20 6f 66 20 52 49 53 43 | version of RISC| 00005cb0 20 4f 53 20 62 65 69 6e 67 20 0a 20 20 20 20 20 | OS being . | 00005cc0 20 20 20 20 20 20 20 20 75 73 65 64 2c 20 6e 61 | used, na| 00005cd0 6d 65 20 69 73 20 74 68 65 20 6e 61 6d 65 20 6f |me is the name o| 00005ce0 66 20 74 68 65 20 77 69 6d 70 20 74 61 73 6b 2c |f the wimp task,| 00005cf0 20 61 6e 64 20 6d 65 73 67 5f 6c 69 73 74 20 69 | and mesg_list i| 00005d00 73 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 61 |s. a| 00005d10 20 62 75 66 66 65 72 2c 20 67 69 76 65 6e 20 61 | buffer, given a| 00005d20 73 20 61 20 73 74 72 69 6e 67 20 6f 72 20 69 74 |s a string or it| 00005d30 73 20 69 6e 74 65 67 65 72 20 61 64 64 72 65 73 |s integer addres| 00005d40 73 2c 20 0a 20 20 20 20 20 20 20 20 20 20 20 20 |s, . | 00005d50 20 63 6f 6e 74 61 69 6e 69 6e 67 20 74 68 65 20 | containing the | 00005d60 6d 65 73 73 61 67 65 73 2c 20 73 74 6f 72 65 64 |messages, stored| 00005d70 20 61 73 20 77 6f 72 64 73 20 61 6e 64 20 74 65 | as words and te| 00005d80 72 6d 69 6e 61 74 65 64 20 0a 20 20 20 20 20 20 |rminated . | 00005d90 20 20 20 20 20 20 20 62 79 20 30 2c 20 77 68 69 | by 0, whi| 00005da0 63 68 20 74 68 65 20 74 61 73 6b 20 77 69 73 68 |ch the task wish| 00005db0 65 73 20 74 6f 20 72 65 63 65 69 76 65 2e 20 54 |es to receive. T| 00005dc0 68 65 20 66 75 6e 63 74 69 6f 6e 20 0a 20 20 20 |he function . | 00005dd0 20 20 20 20 20 20 20 20 20 20 72 65 74 75 72 6e | return| 00005de0 73 20 74 68 65 20 74 61 73 6b 20 68 61 6e 64 6c |s the task handl| 00005df0 65 20 61 73 20 61 6e 20 69 6e 74 65 67 65 72 2e |e as an integer.| 00005e00 20 41 66 74 65 72 20 77 69 6d 70 5f 69 6e 69 74 | After wimp_init| 00005e10 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 74 68 |. th| 00005e20 65 20 66 6f 6c 6c 6f 77 69 6e 67 20 66 75 6e 63 |e following func| 00005e30 74 69 6f 6e 20 69 73 20 75 73 65 66 75 6c 20 66 |tion is useful f| 00005e40 6f 72 20 66 61 63 74 6f 72 69 6e 67 20 77 69 6d |or factoring wim| 00005e50 70 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 70 |p. p| 00005e60 72 6f 67 72 61 6d 73 2e 0a 0a 20 20 45 78 61 6d |rograms... Exam| 00005e70 70 6c 65 20 20 20 20 20 20 65 76 65 6e 74 5f 70 |ple event_p| 00005e80 72 6f 63 65 73 73 28 6d 61 73 6b 70 74 72 2c 62 |rocess(maskptr,b| 00005e90 75 66 66 65 72 2c 61 63 74 69 6f 6e 2c 75 73 65 |uffer,action,use| 00005ea0 72 29 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 |r). | 00005eb0 20 20 7b 0a 20 20 20 20 20 20 20 20 20 20 20 20 | {. | 00005ec0 20 20 20 20 6c 6f 63 61 6c 20 72 2c 20 72 65 73 | local r, res| 00005ed0 70 6f 6e 64 2c 20 67 6f 5f 6f 6e 3b 0a 20 20 20 |pond, go_on;. | 00005ee0 20 20 20 20 20 20 20 20 20 20 20 20 20 72 20 3d | r =| 00005ef0 20 6e 65 77 76 65 63 74 6f 72 28 38 29 3b 0a 20 | newvector(8);. | 00005f00 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 67 | g| 00005f10 6f 5f 6f 6e 20 3d 20 54 52 55 45 3b 0a 20 20 20 |o_on = TRUE;. | 00005f20 20 20 20 20 20 20 20 20 20 20 20 20 20 77 68 69 | whi| 00005f30 6c 65 28 67 6f 5f 6f 6e 29 0a 20 20 20 20 20 20 |le(go_on). | 00005f40 20 20 20 20 20 20 20 20 20 20 7b 0a 20 20 20 20 | {. | 00005f50 20 20 20 20 20 20 20 20 20 20 20 20 20 72 5b 30 | r[0| 00005f60 5d 20 3d 20 6d 61 73 6b 70 74 72 5b 30 5d 3b 0a |] = maskptr[0];.| 00005f70 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00005f80 20 72 5b 31 5d 20 3d 20 62 75 66 66 65 72 3b 0a | r[1] = buffer;.| 00005f90 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00005fa0 20 73 77 69 28 22 57 69 6d 70 5f 50 6f 6c 6c 22 | swi("Wimp_Poll"| 00005fb0 2c 72 29 3b 0a 20 20 20 20 20 20 20 20 20 20 20 |,r);. | 00005fc0 20 20 20 20 20 20 67 6f 5f 6f 6e 20 3d 20 28 74 | go_on = (t| 00005fd0 79 70 65 6f 66 28 72 65 73 70 6f 6e 64 20 3d 20 |ypeof(respond = | 00005fe0 61 63 74 69 6f 6e 5b 72 5b 30 5d 5d 29 3d 3d 20 |action[r[0]])== | 00005ff0 42 59 54 45 43 4f 44 45 29 3f 0a 20 20 20 20 20 |BYTECODE)?. | 00006000 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00006010 20 20 20 20 20 72 65 73 70 6f 6e 64 28 62 75 66 | respond(buf| 00006020 66 65 72 2c 75 73 65 72 2c 6d 61 73 6b 70 74 72 |fer,user,maskptr| 00006030 29 3a 54 52 55 45 3b 0a 20 20 20 20 20 20 20 20 |):TRUE;. | 00006040 20 20 20 20 20 20 20 20 20 7d 0a 20 20 20 20 20 | }. | 00006050 20 20 20 20 20 20 20 20 20 20 20 77 69 6d 70 5f | wimp_| 00006060 63 6c 6f 73 65 64 6f 77 6e 28 29 3b 0a 20 20 20 |closedown();. | 00006070 20 20 20 20 20 20 20 20 20 20 20 20 7d 0a 0a 20 | }.. | 00006080 20 20 20 20 20 20 54 68 69 73 20 66 75 6e 63 74 | This funct| 00006090 69 6f 6e 20 65 76 65 6e 74 5f 70 72 6f 63 65 73 |ion event_proces| 000060a0 73 20 74 61 6b 65 73 20 61 73 20 61 72 67 75 6d |s takes as argum| 000060b0 65 6e 74 73 3a 0a 0a 20 20 20 20 20 20 20 20 6d |ents:.. m| 000060c0 61 73 6b 70 74 72 20 20 20 20 2d 20 20 61 20 31 |askptr - a 1| 000060d0 2d 63 6f 6d 70 6f 6e 65 6e 74 20 76 65 63 74 6f |-component vecto| 000060e0 72 20 63 6f 6e 74 61 69 6e 69 6e 67 20 74 68 65 |r containing the| 000060f0 20 62 69 74 20 6d 61 73 6b 0a 20 20 20 20 20 20 | bit mask. | 00006100 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00006110 66 6f 72 20 57 69 6d 70 5f 50 6f 6c 6c 2e 20 48 |for Wimp_Poll. H| 00006120 61 6e 64 6c 65 72 20 66 75 6e 63 74 69 6f 6e 73 |andler functions| 00006130 20 63 61 6e 20 75 70 64 61 74 65 20 74 68 65 0a | can update the.| 00006140 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00006150 20 20 20 20 20 20 6d 61 73 6b 20 76 69 61 20 74 | mask via t| 00006160 68 65 69 72 20 74 68 69 72 64 20 61 72 67 75 6d |heir third argum| 00006170 65 6e 74 2e 0a 20 20 20 20 20 20 20 20 62 75 66 |ent.. buf| 00006180 66 65 72 20 20 20 20 20 2d 20 20 61 20 62 75 66 |fer - a buf| 00006190 66 65 72 20 66 6f 72 20 77 69 6d 70 20 6d 65 73 |fer for wimp mes| 000061a0 73 61 67 65 73 2c 20 70 61 73 73 65 64 20 74 6f |sages, passed to| 000061b0 20 68 61 6e 64 6c 65 72 0a 20 20 20 20 20 20 20 | handler. | 000061c0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 66 | f| 000061d0 75 6e 63 74 69 6f 6e 73 20 61 73 20 74 68 65 20 |unctions as the | 000061e0 66 69 72 73 74 20 61 72 67 75 6d 65 6e 74 2e 0a |first argument..| 000061f0 20 20 20 20 20 20 20 20 61 63 74 69 6f 6e 20 20 | action | 00006200 20 20 20 2d 20 20 61 20 32 30 2d 63 6f 6d 70 6f | - a 20-compo| 00006210 6e 65 6e 74 20 76 65 63 74 6f 72 20 6f 66 20 68 |nent vector of h| 00006220 61 6e 64 6c 65 72 20 66 75 6e 63 74 69 6f 6e 73 |andler functions| 00006230 20 65 78 70 65 63 74 69 6e 67 0a 20 20 20 20 20 | expecting. | 00006240 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00006250 20 33 20 61 72 67 75 6d 65 6e 74 73 2c 20 74 68 | 3 arguments, th| 00006260 61 74 20 72 65 74 75 72 6e 20 7a 65 72 6f 20 74 |at return zero t| 00006270 6f 20 63 61 75 73 65 20 61 6e 20 65 78 69 74 0a |o cause an exit.| 00006280 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00006290 20 20 20 20 20 20 61 6e 64 20 61 20 6e 6f 6e 7a | and a nonz| 000062a0 65 72 6f 20 69 6e 74 65 67 65 72 20 74 6f 20 63 |ero integer to c| 000062b0 6f 6e 74 69 6e 75 65 2e 0a 20 20 20 20 20 20 20 |ontinue.. | 000062c0 20 75 73 65 72 20 20 20 20 20 20 20 2d 20 20 61 | user - a| 000062d0 20 75 73 65 72 20 76 61 72 69 61 62 6c 65 20 74 | user variable t| 000062e0 6f 20 70 61 73 73 20 6f 6e 20 74 6f 20 68 61 6e |o pass on to han| 000062f0 64 6c 65 72 20 66 75 6e 63 74 69 6f 6e 73 0a 20 |dler functions. | 00006300 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00006310 20 20 20 20 20 61 73 20 74 68 65 20 73 65 63 6f | as the seco| 00006320 6e 64 20 61 72 67 75 6d 65 6e 74 2e 0a 0a 20 20 |nd argument... | 00006330 20 20 20 20 20 54 68 65 20 77 69 6d 70 20 70 72 | The wimp pr| 00006340 6f 67 72 61 6d 20 63 61 6e 20 6e 6f 77 20 62 65 |ogram can now be| 00006350 20 63 6f 6e 74 72 6f 6c 6c 65 64 20 62 79 20 74 | controlled by t| 00006360 68 65 20 76 65 63 74 6f 72 2c 20 69 6e 64 65 78 |he vector, index| 00006370 65 64 20 62 79 0a 20 20 20 20 20 20 20 77 69 6d |ed by. wim| 00006380 70 5f 70 6f 6c 6c 20 72 65 61 73 6f 6e 20 63 6f |p_poll reason co| 00006390 64 65 73 2c 20 6f 66 20 68 61 6e 64 6c 65 72 20 |des, of handler | 000063a0 66 75 6e 63 74 69 6f 6e 73 2e 0a 0a 20 20 2e 2e |functions... ..| 000063b0 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e |................| * 000063f0 0a 0a 77 69 6d 70 5f 72 65 70 6f 72 74 20 20 20 |..wimp_report | 00006400 20 20 77 69 6d 70 5f 72 65 70 6f 72 74 28 73 29 | wimp_report(s)| 00006410 20 20 20 20 20 44 69 73 70 6c 61 79 20 73 74 72 | Display str| 00006420 69 6e 67 20 73 20 69 6e 20 61 20 64 69 61 6c 6f |ing s in a dialo| 00006430 67 75 65 20 0a 20 20 20 20 20 20 20 20 20 20 20 |gue . | 00006440 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00006450 20 20 20 20 20 20 20 20 62 6f 78 20 61 6e 64 20 | box and | 00006460 72 65 74 75 72 6e 20 30 20 69 66 20 6e 6f 20 6b |return 0 if no k| 00006470 65 79 20 6f 72 0a 20 20 20 20 20 20 20 20 20 20 |ey or. | 00006480 20 20 20 20 20 6d 6f 75 73 65 20 62 75 74 74 6f | mouse butto| 00006490 6e 20 69 73 20 63 6c 69 63 6b 65 64 2c 20 31 20 |n is clicked, 1 | 000064a0 69 66 20 74 68 65 20 4f 4b 20 62 75 74 74 6f 6e |if the OK button| 000064b0 20 69 73 20 73 65 6c 65 63 74 65 64 2c 0a 20 20 | is selected,. | 000064c0 20 20 20 20 20 20 20 20 20 20 20 20 20 61 6e 64 | and| 000064d0 20 32 20 69 66 20 74 68 65 20 43 41 4e 43 45 4c | 2 if the CANCEL| 000064e0 20 62 75 74 74 6f 6e 20 69 73 20 73 65 6c 65 63 | button is selec| 000064f0 74 65 64 2e 0a 0a 20 20 0a 20 20 20 20 20 20 20 |ted... . | 00006500 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00006510 20 20 20 20 20 20 20 20 20 0a 20 20 20 20 20 20 | . | 00006520 20 20 20 20 20 20 20 20 20 2d 2d 2d 2d 2d 2d 2d | -------| 00006530 2d 2d 2d 2d 2d 2d 20 45 4e 44 20 2d 2d 2d 2d 2d |------ END -----| 00006540 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |--------------| 0000654e