Home » Archimedes archive » Acorn User » AU 1997-10 A.adf » Extras » Apple][e/PD/BOB/ARMBOB/doc/Tutorial/01
Apple][e/PD/BOB/ARMBOB/doc/Tutorial/01
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/Tutorial/01 |
Read OK: | ✔ |
File size: | 0F32 bytes |
Load address: | 0000 |
Exec address: | 0000 |
File contents
ArmBob v.1.02 Tutorial 1 GCW 06/06/94 Hello World ----------- ArmBob has syntax that conforms very closely to that of C. The standard textbook on C is "The C Programming Language" by B.W.Kernighan and D.M.Ritchie (KR). If you are not acquainted with C you will find the first few chapters of this book very useful. If you are acquainted with C you might find it interesting to note in which respects the examples below fail to be C programs. Let us follow KR by considering the "first program" in any language - a program to print the words "Hello, World". Here it is in Bob: main() { print("Hello, World\n"); } To run this program, create a text file, type the program in, and save your file. Then use the filer menu to change its filetype to BobTask. If you get a message box saying "Bad file type" that means that either the system has not "seen" the !ArmBob application or you mistyped. Double-click on !ArmBob and try again. You should find that the file's icon has changed to light blue with yellow text lines on it, with a small window overlaid. Double-click on the file's icon and the program will run in a task window (we presume you have Risc OS 3). If you change the file's type to BobFile it will run in a command window. A Bob program consists of functions and classes. We have defined a single function 'main'. Normally a function can have any name you like (subject to the rules of syntax - see ref.Syntax). However, main is special, in that a program starts executing at main's first statement. Every program must have a function called 'main'. The order in which the functions are defined makes no difference. Classes must be defined before their instance objects are created. The statements in a function are enclosed in braces ({ ... }). Our program has only one statement, print("Hello, World\n"); A function is called (i.e. used) by naming it, followed by a parenthesized list of argument expressions. Here we call the built-in function 'print'. Most functions take a definite number of arguments, separated by commas, but 'print' is rather special in that it can take an indefinite number of arguments. In our example, there was the single argument "Hello, World\n" which is a 'string' expression. Strings are sequences of characters enclosed in double-quotes ("). They may not contain double-quotes. The pair of characters '\n' denotes a single character - the newline. Unlike Basic, Bob's print function does not provide a newline automatically. We could have written our program as main() { print("Hello, ","World","\n"); } or as main() { print("Hello, "); print("World"); print("\n"); } Bob has an alternative notation borrowed from C++. We could also have written main() { stdout << "Hello, World\n"; } The expression 'stdout' stands for "standard output channel". If 'out' denotes any output channel, say to a file, and 'message' denotes a string, the statement out << message; causes message to be transmitted along out. Now the expression out << message actually evaluates to out itself. The process of evaluating it causes the transmission of message along out as a side-effect. It follows that a statement of the form out << mesg1 << mesg2 << ..... << mesgn; will cause mesg1, mesg2, ... mesgn all to be transmitted, in order, along out. So we could also have written main() { stdout << "Hello, " << "World" << "\n"; } Note the distinction we made between the expression 'out << message' and the statement 'out << message;'. The semicolon (;) marks the termination of a single statement. Statements are like complete sentences, but expressions are like nouns; they stand for something but mean nothing by themselves.
00000000 41 72 6d 42 6f 62 20 76 2e 31 2e 30 32 20 54 75 |ArmBob v.1.02 Tu| 00000010 74 6f 72 69 61 6c 20 31 20 20 20 20 20 20 20 20 |torial 1 | 00000020 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00000030 20 20 20 20 20 20 20 47 43 57 20 30 36 2f 30 36 | GCW 06/06| 00000040 2f 39 34 0a 0a 48 65 6c 6c 6f 20 57 6f 72 6c 64 |/94..Hello World| 00000050 0a 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0a 41 72 6d |.-----------.Arm| 00000060 42 6f 62 20 68 61 73 20 73 79 6e 74 61 78 20 74 |Bob has syntax t| 00000070 68 61 74 20 63 6f 6e 66 6f 72 6d 73 20 76 65 72 |hat conforms ver| 00000080 79 20 63 6c 6f 73 65 6c 79 20 74 6f 20 74 68 61 |y closely to tha| 00000090 74 20 6f 66 20 43 2e 20 54 68 65 20 0a 73 74 61 |t of C. The .sta| 000000a0 6e 64 61 72 64 20 74 65 78 74 62 6f 6f 6b 20 6f |ndard textbook o| 000000b0 6e 20 43 20 69 73 20 22 54 68 65 20 43 20 50 72 |n C is "The C Pr| 000000c0 6f 67 72 61 6d 6d 69 6e 67 20 4c 61 6e 67 75 61 |ogramming Langua| 000000d0 67 65 22 20 62 79 20 0a 42 2e 57 2e 4b 65 72 6e |ge" by .B.W.Kern| 000000e0 69 67 68 61 6e 20 61 6e 64 20 44 2e 4d 2e 52 69 |ighan and D.M.Ri| 000000f0 74 63 68 69 65 20 28 4b 52 29 2e 20 49 66 20 79 |tchie (KR). If y| 00000100 6f 75 20 61 72 65 20 6e 6f 74 20 61 63 71 75 61 |ou are not acqua| 00000110 69 6e 74 65 64 20 77 69 74 68 20 43 0a 79 6f 75 |inted with C.you| 00000120 20 77 69 6c 6c 20 66 69 6e 64 20 74 68 65 20 66 | will find the f| 00000130 69 72 73 74 20 66 65 77 20 63 68 61 70 74 65 72 |irst few chapter| 00000140 73 20 6f 66 20 74 68 69 73 20 62 6f 6f 6b 20 76 |s of this book v| 00000150 65 72 79 20 75 73 65 66 75 6c 2e 20 49 66 0a 79 |ery useful. If.y| 00000160 6f 75 20 61 72 65 20 61 63 71 75 61 69 6e 74 65 |ou are acquainte| 00000170 64 20 77 69 74 68 20 43 20 79 6f 75 20 6d 69 67 |d with C you mig| 00000180 68 74 20 66 69 6e 64 20 69 74 20 69 6e 74 65 72 |ht find it inter| 00000190 65 73 74 69 6e 67 20 74 6f 20 6e 6f 74 65 20 69 |esting to note i| 000001a0 6e 0a 77 68 69 63 68 20 72 65 73 70 65 63 74 73 |n.which respects| 000001b0 20 74 68 65 20 65 78 61 6d 70 6c 65 73 20 62 65 | the examples be| 000001c0 6c 6f 77 20 66 61 69 6c 20 74 6f 20 62 65 20 43 |low fail to be C| 000001d0 20 70 72 6f 67 72 61 6d 73 2e 0a 0a 4c 65 74 20 | programs...Let | 000001e0 75 73 20 66 6f 6c 6c 6f 77 20 4b 52 20 62 79 20 |us follow KR by | 000001f0 63 6f 6e 73 69 64 65 72 69 6e 67 20 74 68 65 20 |considering the | 00000200 22 66 69 72 73 74 20 70 72 6f 67 72 61 6d 22 20 |"first program" | 00000210 69 6e 20 61 6e 79 20 6c 61 6e 67 75 61 67 65 20 |in any language | 00000220 2d 0a 61 20 70 72 6f 67 72 61 6d 20 74 6f 20 70 |-.a program to p| 00000230 72 69 6e 74 20 74 68 65 20 77 6f 72 64 73 20 22 |rint the words "| 00000240 48 65 6c 6c 6f 2c 20 57 6f 72 6c 64 22 2e 20 48 |Hello, World". H| 00000250 65 72 65 20 69 74 20 69 73 20 69 6e 20 42 6f 62 |ere it is in Bob| 00000260 3a 0a 0a 20 20 6d 61 69 6e 28 29 0a 20 20 7b 0a |:.. main(). {.| 00000270 20 20 20 70 72 69 6e 74 28 22 48 65 6c 6c 6f 2c | print("Hello,| 00000280 20 57 6f 72 6c 64 5c 6e 22 29 3b 0a 20 20 7d 0a | World\n");. }.| 00000290 0a 54 6f 20 72 75 6e 20 74 68 69 73 20 70 72 6f |.To run this pro| 000002a0 67 72 61 6d 2c 20 63 72 65 61 74 65 20 61 20 74 |gram, create a t| 000002b0 65 78 74 20 66 69 6c 65 2c 20 74 79 70 65 20 74 |ext file, type t| 000002c0 68 65 20 70 72 6f 67 72 61 6d 20 69 6e 2c 20 61 |he program in, a| 000002d0 6e 64 0a 73 61 76 65 20 79 6f 75 72 20 66 69 6c |nd.save your fil| 000002e0 65 2e 20 54 68 65 6e 20 75 73 65 20 74 68 65 20 |e. Then use the | 000002f0 66 69 6c 65 72 20 6d 65 6e 75 20 74 6f 20 63 68 |filer menu to ch| 00000300 61 6e 67 65 20 69 74 73 20 66 69 6c 65 74 79 70 |ange its filetyp| 00000310 65 20 74 6f 0a 42 6f 62 54 61 73 6b 2e 20 49 66 |e to.BobTask. If| 00000320 20 79 6f 75 20 67 65 74 20 61 20 6d 65 73 73 61 | you get a messa| 00000330 67 65 20 62 6f 78 20 73 61 79 69 6e 67 20 22 42 |ge box saying "B| 00000340 61 64 20 66 69 6c 65 20 74 79 70 65 22 20 74 68 |ad file type" th| 00000350 61 74 20 6d 65 61 6e 73 0a 74 68 61 74 20 65 69 |at means.that ei| 00000360 74 68 65 72 20 74 68 65 20 73 79 73 74 65 6d 20 |ther the system | 00000370 68 61 73 20 6e 6f 74 20 22 73 65 65 6e 22 20 74 |has not "seen" t| 00000380 68 65 20 21 41 72 6d 42 6f 62 20 61 70 70 6c 69 |he !ArmBob appli| 00000390 63 61 74 69 6f 6e 20 6f 72 0a 79 6f 75 20 6d 69 |cation or.you mi| 000003a0 73 74 79 70 65 64 2e 20 44 6f 75 62 6c 65 2d 63 |styped. Double-c| 000003b0 6c 69 63 6b 20 6f 6e 20 21 41 72 6d 42 6f 62 20 |lick on !ArmBob | 000003c0 61 6e 64 20 74 72 79 20 61 67 61 69 6e 2e 20 59 |and try again. Y| 000003d0 6f 75 20 73 68 6f 75 6c 64 20 66 69 6e 64 20 0a |ou should find .| 000003e0 74 68 61 74 20 74 68 65 20 66 69 6c 65 27 73 20 |that the file's | 000003f0 69 63 6f 6e 20 68 61 73 20 63 68 61 6e 67 65 64 |icon has changed| 00000400 20 74 6f 20 6c 69 67 68 74 20 62 6c 75 65 20 77 | to light blue w| 00000410 69 74 68 20 79 65 6c 6c 6f 77 20 74 65 78 74 20 |ith yellow text | 00000420 0a 6c 69 6e 65 73 20 6f 6e 20 69 74 2c 20 77 69 |.lines on it, wi| 00000430 74 68 20 61 20 73 6d 61 6c 6c 20 77 69 6e 64 6f |th a small windo| 00000440 77 20 6f 76 65 72 6c 61 69 64 2e 20 44 6f 75 62 |w overlaid. Doub| 00000450 6c 65 2d 63 6c 69 63 6b 20 6f 6e 20 74 68 65 20 |le-click on the | 00000460 66 69 6c 65 27 73 20 0a 69 63 6f 6e 20 61 6e 64 |file's .icon and| 00000470 20 74 68 65 20 70 72 6f 67 72 61 6d 20 77 69 6c | the program wil| 00000480 6c 20 72 75 6e 20 69 6e 20 61 20 74 61 73 6b 20 |l run in a task | 00000490 77 69 6e 64 6f 77 20 28 77 65 20 70 72 65 73 75 |window (we presu| 000004a0 6d 65 20 79 6f 75 20 68 61 76 65 20 0a 52 69 73 |me you have .Ris| 000004b0 63 20 4f 53 20 33 29 2e 20 49 66 20 79 6f 75 20 |c OS 3). If you | 000004c0 63 68 61 6e 67 65 20 74 68 65 20 66 69 6c 65 27 |change the file'| 000004d0 73 20 74 79 70 65 20 74 6f 20 42 6f 62 46 69 6c |s type to BobFil| 000004e0 65 20 69 74 20 77 69 6c 6c 20 72 75 6e 20 69 6e |e it will run in| 000004f0 20 61 20 0a 63 6f 6d 6d 61 6e 64 20 77 69 6e 64 | a .command wind| 00000500 6f 77 2e 0a 0a 41 20 42 6f 62 20 70 72 6f 67 72 |ow...A Bob progr| 00000510 61 6d 20 63 6f 6e 73 69 73 74 73 20 6f 66 20 66 |am consists of f| 00000520 75 6e 63 74 69 6f 6e 73 20 61 6e 64 20 63 6c 61 |unctions and cla| 00000530 73 73 65 73 2e 20 57 65 20 68 61 76 65 20 64 65 |sses. We have de| 00000540 66 69 6e 65 64 20 0a 61 20 73 69 6e 67 6c 65 20 |fined .a single | 00000550 66 75 6e 63 74 69 6f 6e 20 27 6d 61 69 6e 27 2e |function 'main'.| 00000560 20 4e 6f 72 6d 61 6c 6c 79 20 61 20 66 75 6e 63 | Normally a func| 00000570 74 69 6f 6e 20 63 61 6e 20 68 61 76 65 20 61 6e |tion can have an| 00000580 79 20 6e 61 6d 65 20 79 6f 75 0a 6c 69 6b 65 20 |y name you.like | 00000590 28 73 75 62 6a 65 63 74 20 74 6f 20 74 68 65 20 |(subject to the | 000005a0 72 75 6c 65 73 20 6f 66 20 73 79 6e 74 61 78 20 |rules of syntax | 000005b0 2d 20 73 65 65 20 72 65 66 2e 53 79 6e 74 61 78 |- see ref.Syntax| 000005c0 29 2e 20 48 6f 77 65 76 65 72 2c 20 6d 61 69 6e |). However, main| 000005d0 0a 69 73 20 73 70 65 63 69 61 6c 2c 20 69 6e 20 |.is special, in | 000005e0 74 68 61 74 20 61 20 70 72 6f 67 72 61 6d 20 73 |that a program s| 000005f0 74 61 72 74 73 20 65 78 65 63 75 74 69 6e 67 20 |tarts executing | 00000600 61 74 20 6d 61 69 6e 27 73 20 66 69 72 73 74 20 |at main's first | 00000610 0a 73 74 61 74 65 6d 65 6e 74 2e 20 45 76 65 72 |.statement. Ever| 00000620 79 20 70 72 6f 67 72 61 6d 20 6d 75 73 74 20 68 |y program must h| 00000630 61 76 65 20 61 20 66 75 6e 63 74 69 6f 6e 20 63 |ave a function c| 00000640 61 6c 6c 65 64 20 27 6d 61 69 6e 27 2e 0a 54 68 |alled 'main'..Th| 00000650 65 20 6f 72 64 65 72 20 69 6e 20 77 68 69 63 68 |e order in which| 00000660 20 74 68 65 20 66 75 6e 63 74 69 6f 6e 73 20 61 | the functions a| 00000670 72 65 20 64 65 66 69 6e 65 64 20 6d 61 6b 65 73 |re defined makes| 00000680 20 6e 6f 20 64 69 66 66 65 72 65 6e 63 65 2e 0a | no difference..| 00000690 43 6c 61 73 73 65 73 20 6d 75 73 74 20 62 65 20 |Classes must be | 000006a0 64 65 66 69 6e 65 64 20 62 65 66 6f 72 65 20 74 |defined before t| 000006b0 68 65 69 72 20 69 6e 73 74 61 6e 63 65 20 6f 62 |heir instance ob| 000006c0 6a 65 63 74 73 20 61 72 65 20 63 72 65 61 74 65 |jects are create| 000006d0 64 2e 0a 0a 54 68 65 20 73 74 61 74 65 6d 65 6e |d...The statemen| 000006e0 74 73 20 69 6e 20 61 20 66 75 6e 63 74 69 6f 6e |ts in a function| 000006f0 20 61 72 65 20 65 6e 63 6c 6f 73 65 64 20 69 6e | are enclosed in| 00000700 20 62 72 61 63 65 73 20 28 7b 20 2e 2e 2e 20 7d | braces ({ ... }| 00000710 29 2e 20 4f 75 72 0a 70 72 6f 67 72 61 6d 20 68 |). Our.program h| 00000720 61 73 20 6f 6e 6c 79 20 6f 6e 65 20 73 74 61 74 |as only one stat| 00000730 65 6d 65 6e 74 2c 0a 0a 20 20 20 20 20 20 20 20 |ement,.. | 00000740 20 20 20 20 20 20 20 20 20 70 72 69 6e 74 28 22 | print("| 00000750 48 65 6c 6c 6f 2c 20 57 6f 72 6c 64 5c 6e 22 29 |Hello, World\n")| 00000760 3b 0a 0a 41 20 66 75 6e 63 74 69 6f 6e 20 69 73 |;..A function is| 00000770 20 63 61 6c 6c 65 64 20 28 69 2e 65 2e 20 75 73 | called (i.e. us| 00000780 65 64 29 20 62 79 20 6e 61 6d 69 6e 67 20 69 74 |ed) by naming it| 00000790 2c 20 66 6f 6c 6c 6f 77 65 64 20 62 79 20 61 20 |, followed by a | 000007a0 0a 70 61 72 65 6e 74 68 65 73 69 7a 65 64 20 6c |.parenthesized l| 000007b0 69 73 74 20 6f 66 20 61 72 67 75 6d 65 6e 74 20 |ist of argument | 000007c0 65 78 70 72 65 73 73 69 6f 6e 73 2e 20 48 65 72 |expressions. Her| 000007d0 65 20 77 65 20 63 61 6c 6c 20 74 68 65 20 62 75 |e we call the bu| 000007e0 69 6c 74 2d 69 6e 0a 66 75 6e 63 74 69 6f 6e 20 |ilt-in.function | 000007f0 27 70 72 69 6e 74 27 2e 20 4d 6f 73 74 20 66 75 |'print'. Most fu| 00000800 6e 63 74 69 6f 6e 73 20 74 61 6b 65 20 61 20 64 |nctions take a d| 00000810 65 66 69 6e 69 74 65 20 6e 75 6d 62 65 72 20 6f |efinite number o| 00000820 66 20 61 72 67 75 6d 65 6e 74 73 2c 0a 73 65 70 |f arguments,.sep| 00000830 61 72 61 74 65 64 20 62 79 20 63 6f 6d 6d 61 73 |arated by commas| 00000840 2c 20 62 75 74 20 27 70 72 69 6e 74 27 20 69 73 |, but 'print' is| 00000850 20 72 61 74 68 65 72 20 73 70 65 63 69 61 6c 20 | rather special | 00000860 69 6e 20 74 68 61 74 20 69 74 20 63 61 6e 0a 74 |in that it can.t| 00000870 61 6b 65 20 61 6e 20 69 6e 64 65 66 69 6e 69 74 |ake an indefinit| 00000880 65 20 6e 75 6d 62 65 72 20 6f 66 20 61 72 67 75 |e number of argu| 00000890 6d 65 6e 74 73 2e 20 49 6e 20 6f 75 72 20 65 78 |ments. In our ex| 000008a0 61 6d 70 6c 65 2c 20 74 68 65 72 65 20 77 61 73 |ample, there was| 000008b0 20 74 68 65 0a 73 69 6e 67 6c 65 20 61 72 67 75 | the.single argu| 000008c0 6d 65 6e 74 0a 0a 20 20 20 20 20 20 20 20 20 20 |ment.. | 000008d0 20 20 20 20 20 20 20 20 20 20 22 48 65 6c 6c 6f | "Hello| 000008e0 2c 20 57 6f 72 6c 64 5c 6e 22 0a 0a 77 68 69 63 |, World\n"..whic| 000008f0 68 20 69 73 20 61 20 27 73 74 72 69 6e 67 27 20 |h is a 'string' | 00000900 65 78 70 72 65 73 73 69 6f 6e 2e 20 53 74 72 69 |expression. Stri| 00000910 6e 67 73 20 61 72 65 20 73 65 71 75 65 6e 63 65 |ngs are sequence| 00000920 73 20 6f 66 20 63 68 61 72 61 63 74 65 72 73 0a |s of characters.| 00000930 65 6e 63 6c 6f 73 65 64 20 69 6e 20 64 6f 75 62 |enclosed in doub| 00000940 6c 65 2d 71 75 6f 74 65 73 20 28 22 29 2e 20 54 |le-quotes ("). T| 00000950 68 65 79 20 6d 61 79 20 6e 6f 74 20 63 6f 6e 74 |hey may not cont| 00000960 61 69 6e 20 64 6f 75 62 6c 65 2d 71 75 6f 74 65 |ain double-quote| 00000970 73 2e 0a 54 68 65 20 70 61 69 72 20 6f 66 20 63 |s..The pair of c| 00000980 68 61 72 61 63 74 65 72 73 20 27 5c 6e 27 20 64 |haracters '\n' d| 00000990 65 6e 6f 74 65 73 20 61 20 73 69 6e 67 6c 65 20 |enotes a single | 000009a0 63 68 61 72 61 63 74 65 72 20 2d 20 74 68 65 20 |character - the | 000009b0 6e 65 77 6c 69 6e 65 2e 0a 55 6e 6c 69 6b 65 20 |newline..Unlike | 000009c0 42 61 73 69 63 2c 20 42 6f 62 27 73 20 70 72 69 |Basic, Bob's pri| 000009d0 6e 74 20 66 75 6e 63 74 69 6f 6e 20 64 6f 65 73 |nt function does| 000009e0 20 6e 6f 74 20 70 72 6f 76 69 64 65 20 61 20 6e | not provide a n| 000009f0 65 77 6c 69 6e 65 20 0a 61 75 74 6f 6d 61 74 69 |ewline .automati| 00000a00 63 61 6c 6c 79 2e 20 57 65 20 63 6f 75 6c 64 20 |cally. We could | 00000a10 68 61 76 65 20 77 72 69 74 74 65 6e 20 6f 75 72 |have written our| 00000a20 20 70 72 6f 67 72 61 6d 20 61 73 0a 0a 20 20 20 | program as.. | 00000a30 6d 61 69 6e 28 29 0a 20 20 20 7b 0a 20 20 20 20 |main(). {. | 00000a40 70 72 69 6e 74 28 22 48 65 6c 6c 6f 2c 20 22 2c |print("Hello, ",| 00000a50 22 57 6f 72 6c 64 22 2c 22 5c 6e 22 29 3b 0a 20 |"World","\n");. | 00000a60 20 20 7d 0a 0a 6f 72 20 61 73 20 0a 0a 20 20 20 | }..or as .. | 00000a70 6d 61 69 6e 28 29 0a 20 20 20 7b 0a 20 20 20 20 |main(). {. | 00000a80 70 72 69 6e 74 28 22 48 65 6c 6c 6f 2c 20 22 29 |print("Hello, ")| 00000a90 3b 0a 20 20 20 20 70 72 69 6e 74 28 22 57 6f 72 |;. print("Wor| 00000aa0 6c 64 22 29 3b 0a 20 20 20 20 70 72 69 6e 74 28 |ld");. print(| 00000ab0 22 5c 6e 22 29 3b 0a 20 20 20 7d 0a 0a 42 6f 62 |"\n");. }..Bob| 00000ac0 20 68 61 73 20 61 6e 20 61 6c 74 65 72 6e 61 74 | has an alternat| 00000ad0 69 76 65 20 6e 6f 74 61 74 69 6f 6e 20 62 6f 72 |ive notation bor| 00000ae0 72 6f 77 65 64 20 66 72 6f 6d 20 43 2b 2b 2e 20 |rowed from C++. | 00000af0 57 65 20 63 6f 75 6c 64 20 61 6c 73 6f 0a 68 61 |We could also.ha| 00000b00 76 65 20 77 72 69 74 74 65 6e 0a 0a 20 20 6d 61 |ve written.. ma| 00000b10 69 6e 28 29 0a 20 20 7b 0a 20 20 20 73 74 64 6f |in(). {. stdo| 00000b20 75 74 20 3c 3c 20 22 48 65 6c 6c 6f 2c 20 57 6f |ut << "Hello, Wo| 00000b30 72 6c 64 5c 6e 22 3b 0a 20 20 7d 0a 0a 54 68 65 |rld\n";. }..The| 00000b40 20 65 78 70 72 65 73 73 69 6f 6e 20 27 73 74 64 | expression 'std| 00000b50 6f 75 74 27 20 73 74 61 6e 64 73 20 66 6f 72 20 |out' stands for | 00000b60 22 73 74 61 6e 64 61 72 64 20 6f 75 74 70 75 74 |"standard output| 00000b70 20 63 68 61 6e 6e 65 6c 22 2e 20 49 66 0a 27 6f | channel". If.'o| 00000b80 75 74 27 20 64 65 6e 6f 74 65 73 20 61 6e 79 20 |ut' denotes any | 00000b90 6f 75 74 70 75 74 20 63 68 61 6e 6e 65 6c 2c 20 |output channel, | 00000ba0 73 61 79 20 74 6f 20 61 20 66 69 6c 65 2c 20 61 |say to a file, a| 00000bb0 6e 64 20 27 6d 65 73 73 61 67 65 27 20 64 65 6e |nd 'message' den| 00000bc0 6f 74 65 73 20 0a 61 20 73 74 72 69 6e 67 2c 20 |otes .a string, | 00000bd0 74 68 65 20 73 74 61 74 65 6d 65 6e 74 0a 0a 20 |the statement.. | 00000be0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00000bf0 20 20 20 6f 75 74 20 3c 3c 20 6d 65 73 73 61 67 | out << messag| 00000c00 65 3b 0a 0a 63 61 75 73 65 73 20 6d 65 73 73 61 |e;..causes messa| 00000c10 67 65 20 74 6f 20 62 65 20 74 72 61 6e 73 6d 69 |ge to be transmi| 00000c20 74 74 65 64 20 61 6c 6f 6e 67 20 6f 75 74 2e 20 |tted along out. | 00000c30 4e 6f 77 20 74 68 65 20 65 78 70 72 65 73 73 69 |Now the expressi| 00000c40 6f 6e 0a 0a 20 20 20 20 20 20 20 20 20 20 20 20 |on.. | 00000c50 20 20 20 20 20 20 20 20 20 6f 75 74 20 3c 3c 20 | out << | 00000c60 6d 65 73 73 61 67 65 0a 0a 61 63 74 75 61 6c 6c |message..actuall| 00000c70 79 20 65 76 61 6c 75 61 74 65 73 20 74 6f 20 6f |y evaluates to o| 00000c80 75 74 20 69 74 73 65 6c 66 2e 20 54 68 65 20 70 |ut itself. The p| 00000c90 72 6f 63 65 73 73 20 6f 66 20 65 76 61 6c 75 61 |rocess of evalua| 00000ca0 74 69 6e 67 20 69 74 20 63 61 75 73 65 73 20 0a |ting it causes .| 00000cb0 74 68 65 20 74 72 61 6e 73 6d 69 73 73 69 6f 6e |the transmission| 00000cc0 20 6f 66 20 6d 65 73 73 61 67 65 20 61 6c 6f 6e | of message alon| 00000cd0 67 20 6f 75 74 20 61 73 20 61 20 73 69 64 65 2d |g out as a side-| 00000ce0 65 66 66 65 63 74 2e 20 49 74 20 66 6f 6c 6c 6f |effect. It follo| 00000cf0 77 73 0a 74 68 61 74 20 61 20 73 74 61 74 65 6d |ws.that a statem| 00000d00 65 6e 74 20 6f 66 20 74 68 65 20 66 6f 72 6d 0a |ent of the form.| 00000d10 0a 20 20 20 20 20 20 20 20 20 20 20 6f 75 74 20 |. out | 00000d20 3c 3c 20 6d 65 73 67 31 20 3c 3c 20 6d 65 73 67 |<< mesg1 << mesg| 00000d30 32 20 3c 3c 20 2e 2e 2e 2e 2e 20 3c 3c 20 6d 65 |2 << ..... << me| 00000d40 73 67 6e 3b 0a 0a 77 69 6c 6c 20 63 61 75 73 65 |sgn;..will cause| 00000d50 20 6d 65 73 67 31 2c 20 6d 65 73 67 32 2c 20 2e | mesg1, mesg2, .| 00000d60 2e 2e 20 6d 65 73 67 6e 20 61 6c 6c 20 74 6f 20 |.. mesgn all to | 00000d70 62 65 20 74 72 61 6e 73 6d 69 74 74 65 64 2c 20 |be transmitted, | 00000d80 69 6e 20 6f 72 64 65 72 2c 0a 61 6c 6f 6e 67 20 |in order,.along | 00000d90 6f 75 74 2e 20 53 6f 20 77 65 20 63 6f 75 6c 64 |out. So we could| 00000da0 20 61 6c 73 6f 20 68 61 76 65 20 77 72 69 74 74 | also have writt| 00000db0 65 6e 0a 0a 20 20 20 20 6d 61 69 6e 28 29 0a 20 |en.. main(). | 00000dc0 20 20 20 7b 0a 20 20 20 20 20 73 74 64 6f 75 74 | {. stdout| 00000dd0 20 3c 3c 20 22 48 65 6c 6c 6f 2c 20 22 20 3c 3c | << "Hello, " <<| 00000de0 20 22 57 6f 72 6c 64 22 20 3c 3c 20 22 5c 6e 22 | "World" << "\n"| 00000df0 3b 0a 20 20 20 20 7d 0a 0a 4e 6f 74 65 20 74 68 |;. }..Note th| 00000e00 65 20 64 69 73 74 69 6e 63 74 69 6f 6e 20 77 65 |e distinction we| 00000e10 20 6d 61 64 65 20 62 65 74 77 65 65 6e 20 74 68 | made between th| 00000e20 65 20 65 78 70 72 65 73 73 69 6f 6e 20 27 6f 75 |e expression 'ou| 00000e30 74 20 3c 3c 20 6d 65 73 73 61 67 65 27 0a 61 6e |t << message'.an| 00000e40 64 20 74 68 65 20 73 74 61 74 65 6d 65 6e 74 20 |d the statement | 00000e50 27 6f 75 74 20 3c 3c 20 6d 65 73 73 61 67 65 3b |'out << message;| 00000e60 27 2e 20 54 68 65 20 73 65 6d 69 63 6f 6c 6f 6e |'. The semicolon| 00000e70 20 28 3b 29 20 6d 61 72 6b 73 20 74 68 65 0a 74 | (;) marks the.t| 00000e80 65 72 6d 69 6e 61 74 69 6f 6e 20 6f 66 20 61 20 |ermination of a | 00000e90 73 69 6e 67 6c 65 20 73 74 61 74 65 6d 65 6e 74 |single statement| 00000ea0 2e 20 53 74 61 74 65 6d 65 6e 74 73 20 61 72 65 |. Statements are| 00000eb0 20 6c 69 6b 65 20 63 6f 6d 70 6c 65 74 65 0a 73 | like complete.s| 00000ec0 65 6e 74 65 6e 63 65 73 2c 20 62 75 74 20 65 78 |entences, but ex| 00000ed0 70 72 65 73 73 69 6f 6e 73 20 61 72 65 20 6c 69 |pressions are li| 00000ee0 6b 65 20 6e 6f 75 6e 73 3b 20 74 68 65 79 20 73 |ke nouns; they s| 00000ef0 74 61 6e 64 20 66 6f 72 20 73 6f 6d 65 74 68 69 |tand for somethi| 00000f00 6e 67 20 0a 62 75 74 20 6d 65 61 6e 20 6e 6f 74 |ng .but mean not| 00000f10 68 69 6e 67 20 62 79 20 74 68 65 6d 73 65 6c 76 |hing by themselv| 00000f20 65 73 2e 0a 0a 0a 0a 20 20 20 20 20 20 20 20 20 |es..... | 00000f30 0a 0a |..| 00000f32