TrySmalltalk.js 62 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207
  1. smalltalk.addPackage('TrySmalltalk', {});
  2. smalltalk.addClass('AbstractTutorial', smalltalk.Object, [], 'TrySmalltalk');
  3. smalltalk.AbstractTutorial.comment="Parent class of all ProfStef tutorials.\x0a\x0aTo create your own tutorial:\x0a- subclass AbstractTutorial\x0a- implement a few methods which returns a Lesson instance\x0a- implement tutorial which returns a Collection of selectors to the methods you've created."
  4. smalltalk.addMethod(
  5. "_indexOfLesson_",
  6. smalltalk.method({
  7. selector: "indexOfLesson:",
  8. category: 'accessing',
  9. fn: function (aSelector){
  10. var self=this;
  11. return smalltalk.send(smalltalk.send(self, "_tableOfContents", []), "_indexOf_", [aSelector]);
  12. return self;},
  13. args: ["aSelector"],
  14. source: "indexOfLesson: aSelector\x0a\x09^self tableOfContents indexOf: aSelector.",
  15. messageSends: ["indexOf:", "tableOfContents"],
  16. referencedClasses: []
  17. }),
  18. smalltalk.AbstractTutorial);
  19. smalltalk.addMethod(
  20. "_lessonAt_",
  21. smalltalk.method({
  22. selector: "lessonAt:",
  23. category: 'accessing',
  24. fn: function (anInteger){
  25. var self=this;
  26. var lessonSelector=nil;
  27. (lessonSelector=smalltalk.send(smalltalk.send(self, "_tableOfContents", []), "_at_", [anInteger]));
  28. return smalltalk.send(self, "_perform_", [lessonSelector]);
  29. return self;},
  30. args: ["anInteger"],
  31. source: "lessonAt: anInteger\x0a\x09| lessonSelector |\x0a\x09lessonSelector := self tableOfContents at: anInteger.\x0a\x09^ self perform: lessonSelector.",
  32. messageSends: ["at:", "tableOfContents", "perform:"],
  33. referencedClasses: []
  34. }),
  35. smalltalk.AbstractTutorial);
  36. smalltalk.addMethod(
  37. "_size",
  38. smalltalk.method({
  39. selector: "size",
  40. category: 'accessing',
  41. fn: function (){
  42. var self=this;
  43. return smalltalk.send(smalltalk.send(self, "_tableOfContents", []), "_size", []);
  44. return self;},
  45. args: [],
  46. source: "size\x0a\x09^ self tableOfContents size",
  47. messageSends: ["size", "tableOfContents"],
  48. referencedClasses: []
  49. }),
  50. smalltalk.AbstractTutorial);
  51. smalltalk.addMethod(
  52. "_tableOfContents",
  53. smalltalk.method({
  54. selector: "tableOfContents",
  55. category: 'accessing',
  56. fn: function (){
  57. var self=this;
  58. return ["welcome", "testLesson", "theEnd"];
  59. return self;},
  60. args: [],
  61. source: "tableOfContents\x0a^ #(\x0a 'welcome'\x0a 'testLesson'\x0a 'theEnd'\x0a)",
  62. messageSends: [],
  63. referencedClasses: []
  64. }),
  65. smalltalk.AbstractTutorial);
  66. smalltalk.addMethod(
  67. "_testLesson",
  68. smalltalk.method({
  69. selector: "testLesson",
  70. category: 'pages',
  71. fn: function (){
  72. var self=this;
  73. return smalltalk.send((smalltalk.Lesson || Lesson), "_title_contents_", ["Test Lesson", "\x22This lesson is a test\x22"]);
  74. return self;},
  75. args: [],
  76. source: "testLesson\x0a\x09^ Lesson\x0a\x09\x09title: 'Test Lesson' \x0a\x09\x09contents: '\x22This lesson is a test\x22'",
  77. messageSends: ["title:contents:"],
  78. referencedClasses: ["Lesson"]
  79. }),
  80. smalltalk.AbstractTutorial);
  81. smalltalk.addMethod(
  82. "_theEnd",
  83. smalltalk.method({
  84. selector: "theEnd",
  85. category: 'pages',
  86. fn: function (){
  87. var self=this;
  88. return smalltalk.send((smalltalk.Lesson || Lesson), "_title_contents_", ["The End", "\x22And that'd be pretty much it :)\x22"]);
  89. return self;},
  90. args: [],
  91. source: "theEnd\x0a\x09^ Lesson\x0a\x09\x09title: 'The End' \x0a\x09\x09contents: '\x22And that''d be pretty much it :)\x22'",
  92. messageSends: ["title:contents:"],
  93. referencedClasses: ["Lesson"]
  94. }),
  95. smalltalk.AbstractTutorial);
  96. smalltalk.addMethod(
  97. "_welcome",
  98. smalltalk.method({
  99. selector: "welcome",
  100. category: 'pages',
  101. fn: function (){
  102. var self=this;
  103. return smalltalk.send((smalltalk.Lesson || Lesson), "_title_contents_", ["Welcome", "\x22Hi, this is a test tutorial.\x22"]);
  104. return self;},
  105. args: [],
  106. source: "welcome\x0a\x09^ Lesson\x0a\x09\x09title: 'Welcome' \x0a\x09\x09contents: '\x22Hi, this is a test tutorial.\x22'",
  107. messageSends: ["title:contents:"],
  108. referencedClasses: ["Lesson"]
  109. }),
  110. smalltalk.AbstractTutorial);
  111. smalltalk.addClass('SmalltalkSyntaxTutorial', smalltalk.AbstractTutorial, [], 'TrySmalltalk');
  112. smalltalk.SmalltalkSyntaxTutorial.comment="The default ProfStef tutorial to learn Smalltalk syntax"
  113. smalltalk.addMethod(
  114. "_basicTypesArray",
  115. smalltalk.method({
  116. selector: "basicTypesArray",
  117. category: 'pages',
  118. fn: function (){
  119. var self=this;
  120. return smalltalk.send((smalltalk.Lesson || Lesson), "_title_contents_", ["Basic types: Array", "\x22Literal arrays are created at parse time:\x22\x0a\x0a#(1 2 3).\x0a\x0a#( 1 2 3 #(4 5 6)) size.\x0a\x0a#(1 2 4) isEmpty.\x0a\x0a#(1 2 3) first.\x0a\x0a#('hello' 'Javascript') at: 2 put: 'Smalltalk'; yourself.\x0a\x0aProfStef next."]);
  121. return self;},
  122. args: [],
  123. source: "basicTypesArray\x0a\x09^ Lesson\x0atitle: 'Basic types: Array' \x0acontents: \x0a'\x22Literal arrays are created at parse time:\x22\x0a\x0a#(1 2 3).\x0a\x0a#( 1 2 3 #(4 5 6)) size.\x0a\x0a#(1 2 4) isEmpty.\x0a\x0a#(1 2 3) first.\x0a\x0a#(''hello'' ''Javascript'') at: 2 put: ''Smalltalk''; yourself.\x0a\x0aProfStef next.'",
  124. messageSends: ["title:contents:"],
  125. referencedClasses: ["Lesson"]
  126. }),
  127. smalltalk.SmalltalkSyntaxTutorial);
  128. smalltalk.addMethod(
  129. "_basicTypesCharacters",
  130. smalltalk.method({
  131. selector: "basicTypesCharacters",
  132. category: 'pages',
  133. fn: function (){
  134. var self=this;
  135. return smalltalk.send((smalltalk.Lesson || Lesson), "_title_contents_", ["Basic types: Characters", "\x22A Character can be instantiated using $ operator:\x22\x0a\x0a$A.\x0a\x0a$A class.\x0a\x0a$B charCode.\x0a\x0aCharacter cr.\x0a\x0aCharacter space.\x0a\x0a\x22You can print all 256 characters of the ASCII extended set:\x22\x0a\x0aCharacter allByteCharacters.\x0a\x0aProfStef next."]);
  136. return self;},
  137. args: [],
  138. source: "basicTypesCharacters\x0a\x09^ Lesson\x0atitle: 'Basic types: Characters' \x0acontents: \x0a'\x22A Character can be instantiated using $ operator:\x22\x0a\x0a$A.\x0a\x0a$A class.\x0a\x0a$B charCode.\x0a\x0aCharacter cr.\x0a\x0aCharacter space.\x0a\x0a\x22You can print all 256 characters of the ASCII extended set:\x22\x0a\x0aCharacter allByteCharacters.\x0a\x0aProfStef next.'",
  139. messageSends: ["title:contents:"],
  140. referencedClasses: ["Lesson"]
  141. }),
  142. smalltalk.SmalltalkSyntaxTutorial);
  143. smalltalk.addMethod(
  144. "_basicTypesDynamicArray",
  145. smalltalk.method({
  146. selector: "basicTypesDynamicArray",
  147. category: 'pages',
  148. fn: function (){
  149. var self=this;
  150. return smalltalk.send((smalltalk.Lesson || Lesson), "_title_contents_", ["Basic types: Dynamic Array", "\x22Dynamic Arrays are created at execution time:\x22\x0a\x0a{ (2+3) . (6*6) }.\x0a\x0a{ (2+3) . (6*6) . 'hello', ' Stef'} size.\x0a\x0a\x0a{ ProfStef } first next."]);
  151. return self;},
  152. args: [],
  153. source: "basicTypesDynamicArray\x0a\x09^ Lesson\x0atitle: 'Basic types: Dynamic Array' \x0acontents: \x0a'\x22Dynamic Arrays are created at execution time:\x22\x0a\x0a{ (2+3) . (6*6) }.\x0a\x0a{ (2+3) . (6*6) . ''hello'', '' Stef''} size.\x0a\x0a\x0a{ ProfStef } first next.'",
  154. messageSends: ["title:contents:"],
  155. referencedClasses: ["Lesson"]
  156. }),
  157. smalltalk.SmalltalkSyntaxTutorial);
  158. smalltalk.addMethod(
  159. "_basicTypesNumbers",
  160. smalltalk.method({
  161. selector: "basicTypesNumbers",
  162. category: 'pages',
  163. fn: function (){
  164. var self=this;
  165. return smalltalk.send((smalltalk.Lesson || Lesson), "_title_contents_", ["Basic types: Numbers", "\x22You now know how to execute Smalltalk code. \x0a\x0aNow let's talk about basic objects.\x0a\x0a1, 2, 100, 2/3 ... are Numbers, and respond to many messages evaluating mathematical expressions.\x0aEvaluate these ones:\x22\x0a\x0a2.\x0a\x0a(1/3).\x0a\x0a(1/3) + (4/5).\x0a\x0a(18/5) rounded.\x0a\x0a1 class.\x0a\x0a1 negated.\x0a\x0a1 negated negated.\x0a\x0a(1 + 3) odd.\x0a\x0aProfStef next."]);
  166. return self;},
  167. args: [],
  168. source: "basicTypesNumbers\x0a\x09^ Lesson\x0atitle: 'Basic types: Numbers' \x0acontents: \x0a'\x22You now know how to execute Smalltalk code. \x0a\x0aNow let''s talk about basic objects.\x0a\x0a1, 2, 100, 2/3 ... are Numbers, and respond to many messages evaluating mathematical expressions.\x0aEvaluate these ones:\x22\x0a\x0a2.\x0a\x0a(1/3).\x0a\x0a(1/3) + (4/5).\x0a\x0a(18/5) rounded.\x0a\x0a1 class.\x0a\x0a1 negated.\x0a\x0a1 negated negated.\x0a\x0a(1 + 3) odd.\x0a\x0aProfStef next.'",
  169. messageSends: ["title:contents:"],
  170. referencedClasses: ["Lesson"]
  171. }),
  172. smalltalk.SmalltalkSyntaxTutorial);
  173. smalltalk.addMethod(
  174. "_basicTypesString",
  175. smalltalk.method({
  176. selector: "basicTypesString",
  177. category: 'pages',
  178. fn: function (){
  179. var self=this;
  180. return smalltalk.send((smalltalk.Lesson || Lesson), "_title_contents_", ["Basic types: Strings", "\x22A String is a collection of characters. Use single quotes to create a String object. Print these expressions:\x22\x0a\x0a'ProfStef'.\x0a\x0a'ProfStef' size.\x0a\x0a'abc' asUppercase.\x0a\x0a'Hello World' reversed. \x0a\x0a\x22You can access each character using at: message\x22\x0a\x0a'ProfStef' at: 1.\x0a\x0a\x22String concatenation uses the comma operator:\x22\x0a\x0a'ProfStef', ' is cool'.\x0a\x0aProfStef next."]);
  181. return self;},
  182. args: [],
  183. source: "basicTypesString\x0a\x09^ Lesson\x0atitle: 'Basic types: Strings' \x0acontents: \x0a'\x22A String is a collection of characters. Use single quotes to create a String object. Print these expressions:\x22\x0a\x0a''ProfStef''.\x0a\x0a''ProfStef'' size.\x0a\x0a''abc'' asUppercase.\x0a\x0a''Hello World'' reversed. \x0a\x0a\x22You can access each character using at: message\x22\x0a\x0a''ProfStef'' at: 1.\x0a\x0a\x22String concatenation uses the comma operator:\x22\x0a\x0a''ProfStef'', '' is cool''.\x0a\x0aProfStef next.'",
  184. messageSends: ["title:contents:"],
  185. referencedClasses: ["Lesson"]
  186. }),
  187. smalltalk.SmalltalkSyntaxTutorial);
  188. smalltalk.addMethod(
  189. "_basicTypesSymbol",
  190. smalltalk.method({
  191. selector: "basicTypesSymbol",
  192. category: 'pages',
  193. fn: function (){
  194. var self=this;
  195. return smalltalk.send((smalltalk.Lesson || Lesson), "_title_contents_", ["Basic types: Symbols", "\x22A Symbol is a String which is guaranteed to be globally unique. \x0a\x0aThere is one and only one Symbol #ProfStef. There may be several 'ProfStef' String objects.\x0a\x0a(Message == returns true if the two objects are the SAME)\x22\x0a\x0a'ProfStef' asSymbol.\x0a\x0a#ProfStef asString.\x0a\x0a(2 asString) == (2 asString).\x0a\x0a(2 asString) asSymbol == (2 asString) asSymbol.\x0a\x0a\x0a(Smalltalk at: #ProfStef) next."]);
  196. return self;},
  197. args: [],
  198. source: "basicTypesSymbol\x0a\x09^ Lesson\x0atitle: 'Basic types: Symbols' \x0acontents: \x0a'\x22A Symbol is a String which is guaranteed to be globally unique. \x0a\x0aThere is one and only one Symbol #ProfStef. There may be several ''ProfStef'' String objects.\x0a\x0a(Message == returns true if the two objects are the SAME)\x22\x0a\x0a''ProfStef'' asSymbol.\x0a\x0a#ProfStef asString.\x0a\x0a(2 asString) == (2 asString).\x0a\x0a(2 asString) asSymbol == (2 asString) asSymbol.\x0a\x0a\x0a(Smalltalk at: #ProfStef) next.'",
  199. messageSends: ["title:contents:"],
  200. referencedClasses: ["Lesson"]
  201. }),
  202. smalltalk.SmalltalkSyntaxTutorial);
  203. smalltalk.addMethod(
  204. "_blocks",
  205. smalltalk.method({
  206. selector: "blocks",
  207. category: 'pages',
  208. fn: function (){
  209. var self=this;
  210. return smalltalk.send((smalltalk.Lesson || Lesson), "_title_contents_", ["Blocks", "\x22Cascade is cool ! Let's talk about blocks.\x0a\x0aBlocks are anonymous methods that can be stored into variables and executed on demand.\x0a\x0aBlocks are delimited by square brackets: []\x22\x0a\x0a[Transcript open].\x0a\x0a\x22does not open a Transcript because the block is not executed.\x0a\x0aHere is a block that adds 2 to its argument (its argument is named x):\x22\x0a\x0a[:x | x+2].\x0a\x0a\x22We can execute a block by sending it value messages.\x22\x0a\x0a[:x | x+2] value: 5.\x0a\x0a[Transcript open] value.\x0a\x0a[:x | x+2] value: 10.\x0a\x0a[:x :y| x + y] value:3 value:5.\x0a\x0a[ProfStef next] value."]);
  211. return self;},
  212. args: [],
  213. source: "blocks\x0a\x09^ Lesson\x0atitle: 'Blocks' \x0acontents: \x0a'\x22Cascade is cool ! Let''s talk about blocks.\x0a\x0aBlocks are anonymous methods that can be stored into variables and executed on demand.\x0a\x0aBlocks are delimited by square brackets: []\x22\x0a\x0a[Transcript open].\x0a\x0a\x22does not open a Transcript because the block is not executed.\x0a\x0aHere is a block that adds 2 to its argument (its argument is named x):\x22\x0a\x0a[:x | x+2].\x0a\x0a\x22We can execute a block by sending it value messages.\x22\x0a\x0a[:x | x+2] value: 5.\x0a\x0a[Transcript open] value.\x0a\x0a[:x | x+2] value: 10.\x0a\x0a[:x :y| x + y] value:3 value:5.\x0a\x0a[ProfStef next] value.'",
  214. messageSends: ["title:contents:"],
  215. referencedClasses: ["Lesson"]
  216. }),
  217. smalltalk.SmalltalkSyntaxTutorial);
  218. smalltalk.addMethod(
  219. "_blocksAssignation",
  220. smalltalk.method({
  221. selector: "blocksAssignation",
  222. category: 'pages',
  223. fn: function (){
  224. var self=this;
  225. return smalltalk.send((smalltalk.Lesson || Lesson), "_title_contents_", ["Block assignation", "\x22Blocks can be assigned to a variable then executed later.\x0a\x0aNote that |b| is the declaration of a variable named 'b' and that ':=' assigns a value to a variable.\x0a\x0aSelect the three lines then Print It:\x22\x0a\x0a|b|\x0ab := [:x | x+2].\x0ab value: 12.\x0a\x0a\x0aProfStef next."]);
  226. return self;},
  227. args: [],
  228. source: "blocksAssignation\x0a\x09^ Lesson\x0atitle: 'Block assignation' \x0acontents: \x0a'\x22Blocks can be assigned to a variable then executed later.\x0a\x0aNote that |b| is the declaration of a variable named ''b'' and that '':='' assigns a value to a variable.\x0a\x0aSelect the three lines then Print It:\x22\x0a\x0a|b|\x0ab := [:x | x+2].\x0ab value: 12.\x0a\x0a\x0aProfStef next.'",
  229. messageSends: ["title:contents:"],
  230. referencedClasses: ["Lesson"]
  231. }),
  232. smalltalk.SmalltalkSyntaxTutorial);
  233. smalltalk.addMethod(
  234. "_conditionals",
  235. smalltalk.method({
  236. selector: "conditionals",
  237. category: 'pages',
  238. fn: function (){
  239. var self=this;
  240. return smalltalk.send((smalltalk.Lesson || Lesson), "_title_contents_", ["Conditionals", "\x22Conditionals are just messages sent to Boolean objects\x22\x0a\x0a1 < 2\x0a ifTrue: [100]\x0a ifFalse: [42].\x0a\x0a\x22Here the message is ifTrue:ifFalse\x0a\x0aTry this:\x22\x0a\x0aTranscript open.\x0a\x0a3 > 10 \x0a\x09ifTrue: [Transcript show: 'maybe there''s a bug ....']\x0a\x09ifFalse: [Transcript show: 'No : 3 is less than 10'].\x0a\x0a3 = 3 ifTrue: [ProfStef next]."]);
  241. return self;},
  242. args: [],
  243. source: "conditionals\x0a\x09^ Lesson\x0atitle: 'Conditionals' \x0acontents: \x0a'\x22Conditionals are just messages sent to Boolean objects\x22\x0a\x0a1 < 2\x0a ifTrue: [100]\x0a ifFalse: [42].\x0a\x0a\x22Here the message is ifTrue:ifFalse\x0a\x0aTry this:\x22\x0a\x0aTranscript open.\x0a\x0a3 > 10 \x0a\x09ifTrue: [Transcript show: ''maybe there''''s a bug ....'']\x0a\x09ifFalse: [Transcript show: ''No : 3 is less than 10''].\x0a\x0a3 = 3 ifTrue: [ProfStef next].'.",
  244. messageSends: ["title:contents:"],
  245. referencedClasses: ["Lesson"]
  246. }),
  247. smalltalk.SmalltalkSyntaxTutorial);
  248. smalltalk.addMethod(
  249. "_debugger",
  250. smalltalk.method({
  251. selector: "debugger",
  252. category: 'pages',
  253. fn: function (){
  254. var self=this;
  255. return smalltalk.send((smalltalk.Lesson || Lesson), "_title_contents_", ["Debugger", "\x22The Debugger may be the most famous tool of Smalltalk environments. It will open as soon as an unmanaged Exception occurs. \x0a\x0aThe following code will open the debugger.\x0a\x0a***This should be rethought completely***\x22\x0a\x0a\x0a "]);
  256. return self;},
  257. args: [],
  258. source: "debugger\x0a\x09^ Lesson\x0atitle: 'Debugger' \x0acontents: '\x22The Debugger may be the most famous tool of Smalltalk environments. It will open as soon as an unmanaged Exception occurs. \x0a\x0aThe following code will open the debugger.\x0a\x0a***This should be rethought completely***\x22\x0a\x0a\x0a '",
  259. messageSends: ["title:contents:"],
  260. referencedClasses: ["Lesson"]
  261. }),
  262. smalltalk.SmalltalkSyntaxTutorial);
  263. smalltalk.addMethod(
  264. "_doingVSPrinting",
  265. smalltalk.method({
  266. selector: "doingVSPrinting",
  267. category: 'pages',
  268. fn: function (){
  269. var self=this;
  270. return smalltalk.send((smalltalk.Lesson || Lesson), "_title_contents_", ["Doing VS Printing: Doing", "\x22Cool ! (I like to say Cooool :) ).\x0aYou've just executed a Smalltalk expression.\x0aMore precisely, you sent the message 'next' to ProfStef class (it's me !).\x0a\x0aNote you can run this tutorial again by evaluating: 'ProfStef go'. \x0a'ProfStef previous' returns to the previous lesson.\x0a\x0aYou can also Do It using the keyboard shortcut 'CTRL d'\x0a\x0aTry to evaluate this expression:\x22\x0a\x0awindow alert: 'hello world!'.\x0a\x0a\x22Then go to the next lesson:\x22\x0a\x0aProfStef next."]);
  271. return self;},
  272. args: [],
  273. source: "doingVSPrinting \x0a\x09^ Lesson\x0atitle: 'Doing VS Printing: Doing' \x0acontents: \x0a'\x22Cool ! (I like to say Cooool :) ).\x0aYou''ve just executed a Smalltalk expression.\x0aMore precisely, you sent the message ''next'' to ProfStef class (it''s me !).\x0a\x0aNote you can run this tutorial again by evaluating: ''ProfStef go''. \x0a''ProfStef previous'' returns to the previous lesson.\x0a\x0aYou can also Do It using the keyboard shortcut ''CTRL d''\x0a\x0aTry to evaluate this expression:\x22\x0a\x0awindow alert: ''hello world!''.\x0a\x0a\x22Then go to the next lesson:\x22\x0a\x0aProfStef next.'",
  274. messageSends: ["title:contents:"],
  275. referencedClasses: ["Lesson"]
  276. }),
  277. smalltalk.SmalltalkSyntaxTutorial);
  278. smalltalk.addMethod(
  279. "_instanciation",
  280. smalltalk.method({
  281. selector: "instanciation",
  282. category: 'pages',
  283. fn: function (){
  284. var self=this;
  285. return smalltalk.send((smalltalk.Lesson || Lesson), "_title_contents_", ["Instanciation", "\x22Objects are instances of their class. Usually, we send the message #new to a class for creating an instance of this class.\x0a\x0aFor example, let's create an instance of the class Array:\x22\x0a\x0aArray new\x0a\x09add: 'Some text';\x0a\x09add: 3.;\x0a\x09yourself.\x0a\x0a\x22See the array we've created? Actually, #('Some text' 3) is just a shorthand for instantiating arrays.\x22\x0a\x0a\x22If we use a variable to keep track of this object, we'll be able to do stuff with it.\x22\x0a\x0a\x22The following code must be ran all at one, as the 'anArray' variable will cease to exist once the execution finishes:\x22\x0a\x0a|anArray|\x0a\x0aanArray := Array new\x0a\x09add: 'Some text';\x0a\x09add: 3;\x0a\x09yourself.\x0a\x0aTranscript show: anArray; cr.\x0a\x0aanArray remove: 3.\x0a\x0aTranscript show: anArray; cr.\x0a\x0aanArray add: 'Some more text!'.\x0a\x0aTranscript show: anArray; cr.\x0a\x09\x0a\x22I'll put myself in an instance of a class named Dictionary and go to the next lesson:\x22\x0a\x0a((Dictionary new add: ('move on!' -> ProfStef)) at: 'move on!') next"]);
  286. return self;},
  287. args: [],
  288. source: "instanciation\x0a\x09^ Lesson\x0atitle: 'Instanciation' \x0acontents: \x0a'\x22Objects are instances of their class. Usually, we send the message #new to a class for creating an instance of this class.\x0a\x0aFor example, let''s create an instance of the class Array:\x22\x0a\x0aArray new\x0a\x09add: ''Some text'';\x0a\x09add: 3.;\x0a\x09yourself.\x0a\x0a\x22See the array we''ve created? Actually, #(''Some text'' 3) is just a shorthand for instantiating arrays.\x22\x0a\x0a\x22If we use a variable to keep track of this object, we''ll be able to do stuff with it.\x22\x0a\x0a\x22The following code must be ran all at one, as the ''anArray'' variable will cease to exist once the execution finishes:\x22\x0a\x0a|anArray|\x0a\x0aanArray := Array new\x0a\x09add: ''Some text'';\x0a\x09add: 3;\x0a\x09yourself.\x0a\x0aTranscript show: anArray; cr.\x0a\x0aanArray remove: 3.\x0a\x0aTranscript show: anArray; cr.\x0a\x0aanArray add: ''Some more text!''.\x0a\x0aTranscript show: anArray; cr.\x0a\x09\x0a\x22I''ll put myself in an instance of a class named Dictionary and go to the next lesson:\x22\x0a\x0a((Dictionary new add: (''move on!'' -> ProfStef)) at: ''move on!'') next'",
  289. messageSends: ["title:contents:"],
  290. referencedClasses: ["Lesson"]
  291. }),
  292. smalltalk.SmalltalkSyntaxTutorial);
  293. smalltalk.addMethod(
  294. "_iterators",
  295. smalltalk.method({
  296. selector: "iterators",
  297. category: 'pages',
  298. fn: function (){
  299. var self=this;
  300. return smalltalk.send((smalltalk.Lesson || Lesson), "_title_contents_", ["Iterators", "\x22The message do: is sent to a collection of objects (Array, Dictionary, String, etc), evaluating the block for each element.\x0a\x0aHere we want to print all the numbers on the Transcript (a console)\x22\x0a\x0a#(11 38 3 -2 10) do: [:each |\x0a Transcript show: each printString; cr].\x0a\x0a\x22Some other really nice iterators\x22\x0a\x0a#(11 38 3 -2 10) collect: [:each | each negated].\x0a\x0a#(11 38 3 -2 10) collect: [:each | each odd].\x0a\x0a#(11 38 3 -2 10) select: [:each | each odd].\x0a\x0a#(11 38 3 -2 10) select: [:each | each > 10].\x0a\x0a#(11 38 3 -2 10) reject: [:each | each > 10].\x0a\x0a#(11 38 3 -2 10) \x0a do: [:each | Transcript show: each printString]\x0a separatedBy: [Transcript show: '.'].\x0a\x0a\x0a(Smalltalk current classes select: [:eachClass | eachClass name = 'ProfStef']) do: [:eachProfstef | eachProfstef next]."]);
  301. return self;},
  302. args: [],
  303. source: "iterators\x0a\x09^ Lesson\x0atitle: 'Iterators' \x0acontents: \x0a'\x22The message do: is sent to a collection of objects (Array, Dictionary, String, etc), evaluating the block for each element.\x0a\x0aHere we want to print all the numbers on the Transcript (a console)\x22\x0a\x0a#(11 38 3 -2 10) do: [:each |\x0a Transcript show: each printString; cr].\x0a\x0a\x22Some other really nice iterators\x22\x0a\x0a#(11 38 3 -2 10) collect: [:each | each negated].\x0a\x0a#(11 38 3 -2 10) collect: [:each | each odd].\x0a\x0a#(11 38 3 -2 10) select: [:each | each odd].\x0a\x0a#(11 38 3 -2 10) select: [:each | each > 10].\x0a\x0a#(11 38 3 -2 10) reject: [:each | each > 10].\x0a\x0a#(11 38 3 -2 10) \x0a do: [:each | Transcript show: each printString]\x0a separatedBy: [Transcript show: ''.''].\x0a\x0a\x0a(Smalltalk current classes select: [:eachClass | eachClass name = ''ProfStef'']) do: [:eachProfstef | eachProfstef next].'",
  304. messageSends: ["title:contents:"],
  305. referencedClasses: ["Lesson"]
  306. }),
  307. smalltalk.SmalltalkSyntaxTutorial);
  308. smalltalk.addMethod(
  309. "_loops",
  310. smalltalk.method({
  311. selector: "loops",
  312. category: 'pages',
  313. fn: function (){
  314. var self=this;
  315. return smalltalk.send((smalltalk.Lesson || Lesson), "_title_contents_", ["Loops", "\x22Loops are high-level collection iterators, implemented as regular methods.\x22\x0a\x0a\x22Basic loops:\x0a to:do:\x0a to:by:do\x22\x0a\x0a1 to: 100 do:\x0a [:i | Transcript show: i asString; cr ].\x0a\x0a1 to: 100 by: 3 do: [:i | Transcript show: i asString; cr].\x0a\x0a100 to: 0 by: -2 do: \x0a [:i | Transcript show: i asString; cr].\x0a\x0a1 to: 1 do: [:i | ProfStef next]."]);
  316. return self;},
  317. args: [],
  318. source: "loops\x0a\x09^ Lesson\x0atitle: 'Loops' \x0acontents: \x0a'\x22Loops are high-level collection iterators, implemented as regular methods.\x22\x0a\x0a\x22Basic loops:\x0a to:do:\x0a to:by:do\x22\x0a\x0a1 to: 100 do:\x0a [:i | Transcript show: i asString; cr ].\x0a\x0a1 to: 100 by: 3 do: [:i | Transcript show: i asString; cr].\x0a\x0a100 to: 0 by: -2 do: \x0a [:i | Transcript show: i asString; cr].\x0a\x0a1 to: 1 do: [:i | ProfStef next].'",
  319. messageSends: ["title:contents:"],
  320. referencedClasses: ["Lesson"]
  321. }),
  322. smalltalk.SmalltalkSyntaxTutorial);
  323. smalltalk.addMethod(
  324. "_mathematicalPrecedence",
  325. smalltalk.method({
  326. selector: "mathematicalPrecedence",
  327. category: 'pages',
  328. fn: function (){
  329. var self=this;
  330. return smalltalk.send((smalltalk.Lesson || Lesson), "_title_contents_", ["Mathematical precedence", "\x22Traditional precedence rules from mathematics do not follow in Smalltalk.\x22\x0a\x0a2 * 10 + 2.\x0a\x0a\x22Here the message * is sent to 2, which answers 20, then 20 receive the message +\x0a\x0aRemember that all messages always follow a simple left-to-right precedence rule, * without exceptions *.\x22\x0a\x0a2 + 2 * 10.\x0a\x0a2 + (2 * 10).\x0a\x0a8 - 5 / 2.\x0a\x0a(8 - 5) / 2.\x0a\x0a8 - (5 / 2).\x0a\x0aProfStef next."]);
  331. return self;},
  332. args: [],
  333. source: "mathematicalPrecedence\x0a\x09^ Lesson\x0atitle: 'Mathematical precedence'\x0acontents: \x0a'\x22Traditional precedence rules from mathematics do not follow in Smalltalk.\x22\x0a\x0a2 * 10 + 2.\x0a\x0a\x22Here the message * is sent to 2, which answers 20, then 20 receive the message +\x0a\x0aRemember that all messages always follow a simple left-to-right precedence rule, * without exceptions *.\x22\x0a\x0a2 + 2 * 10.\x0a\x0a2 + (2 * 10).\x0a\x0a8 - 5 / 2.\x0a\x0a(8 - 5) / 2.\x0a\x0a8 - (5 / 2).\x0a\x0aProfStef next.'",
  334. messageSends: ["title:contents:"],
  335. referencedClasses: ["Lesson"]
  336. }),
  337. smalltalk.SmalltalkSyntaxTutorial);
  338. smalltalk.addMethod(
  339. "_messageSyntaxBinary",
  340. smalltalk.method({
  341. selector: "messageSyntaxBinary",
  342. category: 'pages',
  343. fn: function (){
  344. var self=this;
  345. return smalltalk.send((smalltalk.Lesson || Lesson), "_title_contents_", ["Message syntax: Binary messages", "\x22Binary messages have the following form:\x0a anObject + anotherObject\x22\x0a\x0a3 * 2.\x0a\x0aDate today year = 2011.\x0a\x0afalse | false.\x0a\x0atrue & true.\x0a\x0atrue & false.\x0a\x0a10 @ 100.\x0a\x0a10 <= 12.\x0a\x0a'ab', 'cd'.\x0a\x0aProfStef next."]);
  346. return self;},
  347. args: [],
  348. source: "messageSyntaxBinary\x0a\x09^ Lesson\x0atitle: 'Message syntax: Binary messages' \x0acontents: \x0a'\x22Binary messages have the following form:\x0a anObject + anotherObject\x22\x0a\x0a3 * 2.\x0a\x0aDate today year = 2011.\x0a\x0afalse | false.\x0a\x0atrue & true.\x0a\x0atrue & false.\x0a\x0a10 @ 100.\x0a\x0a10 <= 12.\x0a\x0a''ab'', ''cd''.\x0a\x0aProfStef next.'",
  349. messageSends: ["title:contents:"],
  350. referencedClasses: ["Lesson"]
  351. }),
  352. smalltalk.SmalltalkSyntaxTutorial);
  353. smalltalk.addMethod(
  354. "_messageSyntaxCascade",
  355. smalltalk.method({
  356. selector: "messageSyntaxCascade",
  357. category: 'pages',
  358. fn: function (){
  359. var self=this;
  360. return smalltalk.send((smalltalk.Lesson || Lesson), "_title_contents_", ["Message syntax: Cascade", "\x22; is the cascade operator. It's useful to send message to the SAME receiver\x0aOpen a Transcript (console):\x22\x0a\x0aTranscript open.\x0a\x0a\x22Then:\x22\x0a\x0aTranscript show: 'hello'.\x0aTranscript show: 'Smalltalk'.\x0aTranscript cr.\x0a\x0a\x22is equivalent to:\x22\x0a\x0aTranscript \x0a\x09 show: 'hello';\x0a\x09 show: 'Smalltalk' ;\x0a\x09 cr.\x0a\x0a\x22You can close the development tools by clicking on the red circle with a cross at the bottom left of the website.\x0aTry to go to the next lesson with a cascade of two 'next' messages:\x22\x0a\x0aProfStef"]);
  361. return self;},
  362. args: [],
  363. source: "messageSyntaxCascade\x0a\x09^ Lesson\x0atitle: 'Message syntax: Cascade' \x0acontents: \x0a'\x22; is the cascade operator. It''s useful to send message to the SAME receiver\x0aOpen a Transcript (console):\x22\x0a\x0aTranscript open.\x0a\x0a\x22Then:\x22\x0a\x0aTranscript show: ''hello''.\x0aTranscript show: ''Smalltalk''.\x0aTranscript cr.\x0a\x0a\x22is equivalent to:\x22\x0a\x0aTranscript \x0a\x09 show: ''hello'';\x0a\x09 show: ''Smalltalk'' ;\x0a\x09 cr.\x0a\x0a\x22You can close the development tools by clicking on the red circle with a cross at the bottom left of the website.\x0aTry to go to the next lesson with a cascade of two ''next'' messages:\x22\x0a\x0aProfStef'.",
  364. messageSends: ["title:contents:"],
  365. referencedClasses: ["Lesson"]
  366. }),
  367. smalltalk.SmalltalkSyntaxTutorial);
  368. smalltalk.addMethod(
  369. "_messageSyntaxCascadeShouldNotBeHere",
  370. smalltalk.method({
  371. selector: "messageSyntaxCascadeShouldNotBeHere",
  372. category: 'pages',
  373. fn: function (){
  374. var self=this;
  375. return smalltalk.send((smalltalk.Lesson || Lesson), "_title_contents_", ["Lost ?", "\x22Hey, you should not be here !! \x0a\x0aGo back and use a cascade !\x22\x0a\x0aProfStef previous."]);
  376. return self;},
  377. args: [],
  378. source: "messageSyntaxCascadeShouldNotBeHere\x0a\x09^ Lesson\x0atitle: 'Lost ?' \x0acontents: \x0a'\x22Hey, you should not be here !! \x0a\x0aGo back and use a cascade !\x22\x0a\x0aProfStef previous.'.",
  379. messageSends: ["title:contents:"],
  380. referencedClasses: ["Lesson"]
  381. }),
  382. smalltalk.SmalltalkSyntaxTutorial);
  383. smalltalk.addMethod(
  384. "_messageSyntaxExecutionOrder",
  385. smalltalk.method({
  386. selector: "messageSyntaxExecutionOrder",
  387. category: 'pages',
  388. fn: function (){
  389. var self=this;
  390. return smalltalk.send((smalltalk.Lesson || Lesson), "_title_contents_", ["Message syntax: Execution order", "\x22Unary messages are executed first, then binary messages and finally keyword messages:\x0a Unary > Binary > Keywords\x22\x0a\x0a2.5 + 3.8 rounded.\x0a\x0a3 max: 2 + 2.\x0a \x0a(0@0) class.\x0a\x0a0@0 x: 100.\x0a\x0a(0@0 x: 100) class.\x0a\x0a\x22Between messages of similar precedence, expressions are executed from left to right\x22\x0a\x0a-12345 negated asString reversed.\x0a\x0aProfStef next."]);
  391. return self;},
  392. args: [],
  393. source: "messageSyntaxExecutionOrder\x0a\x09^ Lesson\x0atitle: 'Message syntax: Execution order' \x0acontents: \x0a'\x22Unary messages are executed first, then binary messages and finally keyword messages:\x0a Unary > Binary > Keywords\x22\x0a\x0a2.5 + 3.8 rounded.\x0a\x0a3 max: 2 + 2.\x0a \x0a(0@0) class.\x0a\x0a0@0 x: 100.\x0a\x0a(0@0 x: 100) class.\x0a\x0a\x22Between messages of similar precedence, expressions are executed from left to right\x22\x0a\x0a-12345 negated asString reversed.\x0a\x0aProfStef next.'",
  394. messageSends: ["title:contents:"],
  395. referencedClasses: ["Lesson"]
  396. }),
  397. smalltalk.SmalltalkSyntaxTutorial);
  398. smalltalk.addMethod(
  399. "_messageSyntaxExecutionOrderParentheses",
  400. smalltalk.method({
  401. selector: "messageSyntaxExecutionOrderParentheses",
  402. category: 'pages',
  403. fn: function (){
  404. var self=this;
  405. return smalltalk.send((smalltalk.Lesson || Lesson), "_title_contents_", ["Message syntax: Parentheses", "\x22Use parentheses to change order of evaluation\x22\x0a\x0a(2.5 + 3.8) rounded.\x0a\x0a(3 max: 2) + 2.\x0a\x0aProfStef next."]);
  406. return self;},
  407. args: [],
  408. source: "messageSyntaxExecutionOrderParentheses\x0a\x09^ Lesson\x0atitle: 'Message syntax: Parentheses'\x0acontents: \x0a'\x22Use parentheses to change order of evaluation\x22\x0a\x0a(2.5 + 3.8) rounded.\x0a\x0a(3 max: 2) + 2.\x0a\x0aProfStef next.'",
  409. messageSends: ["title:contents:"],
  410. referencedClasses: ["Lesson"]
  411. }),
  412. smalltalk.SmalltalkSyntaxTutorial);
  413. smalltalk.addMethod(
  414. "_messageSyntaxKeyword",
  415. smalltalk.method({
  416. selector: "messageSyntaxKeyword",
  417. category: 'pages',
  418. fn: function (){
  419. var self=this;
  420. return smalltalk.send((smalltalk.Lesson || Lesson), "_title_contents_", ["Message syntax: Keyword messages", "\x22Keyword Messages are messages with arguments. They have the following form:\x0a anObject akey: anotherObject akey2: anotherObject2\x22\x0a\x0a'Web development is a good deal of pain' copyFrom: 1 to: 30\x0a\x0a\x22The message is copyFrom:to: sent to the String 'Web development is a good deal of pain'\x22\x0a\x0a1 max: 3.\x0a\x0aArray with: 'hello' with: 2 with: Smalltalk.\x0a\x0a\x22The message is with:with:with: implemented on class Array. Note you can also write\x22\x0a\x0aArray\x0a\x09with: 'Hi there!'\x0a\x09with: 2\x0a\x09with: Smalltalk.\x0a\x09\x0aProfStef perform: 'next'."]);
  421. return self;},
  422. args: [],
  423. source: "messageSyntaxKeyword\x0a\x09^ Lesson\x0atitle: 'Message syntax: Keyword messages' \x0acontents: \x0a'\x22Keyword Messages are messages with arguments. They have the following form:\x0a anObject akey: anotherObject akey2: anotherObject2\x22\x0a\x0a''Web development is a good deal of pain'' copyFrom: 1 to: 30\x0a\x0a\x22The message is copyFrom:to: sent to the String ''Web development is a good deal of pain''\x22\x0a\x0a1 max: 3.\x0a\x0aArray with: ''hello'' with: 2 with: Smalltalk.\x0a\x0a\x22The message is with:with:with: implemented on class Array. Note you can also write\x22\x0a\x0aArray\x0a\x09with: ''Hi there!''\x0a\x09with: 2\x0a\x09with: Smalltalk.\x0a\x09\x0aProfStef perform: ''next''.'",
  424. messageSends: ["title:contents:"],
  425. referencedClasses: ["Lesson"]
  426. }),
  427. smalltalk.SmalltalkSyntaxTutorial);
  428. smalltalk.addMethod(
  429. "_messageSyntaxUnary",
  430. smalltalk.method({
  431. selector: "messageSyntaxUnary",
  432. category: 'pages',
  433. fn: function (){
  434. var self=this;
  435. return smalltalk.send((smalltalk.Lesson || Lesson), "_title_contents_", ["Message syntax: Unary messages", "\x22Messages are sent to objects. There are three types of message: Unary, Binary and Keyword.\x0a\x0aUnary messages have the following form:\x0a anObject aMessage \x0a\x0aYou've already sent unary messages. For example:\x22\x0a\x0a1 class.\x0a\x0afalse not.\x0a\x0aDate today.\x0a\x0aNumber pi.\x0a\x0a\x22And of course: \x22\x0a\x0aProfStef next."]);
  436. return self;},
  437. args: [],
  438. source: "messageSyntaxUnary\x0a\x09^ Lesson\x0atitle: 'Message syntax: Unary messages' \x0acontents: \x0a'\x22Messages are sent to objects. There are three types of message: Unary, Binary and Keyword.\x0a\x0aUnary messages have the following form:\x0a anObject aMessage \x0a\x0aYou''ve already sent unary messages. For example:\x22\x0a\x0a1 class.\x0a\x0afalse not.\x0a\x0aDate today.\x0a\x0aNumber pi.\x0a\x0a\x22And of course: \x22\x0a\x0aProfStef next.'",
  439. messageSends: ["title:contents:"],
  440. referencedClasses: ["Lesson"]
  441. }),
  442. smalltalk.SmalltalkSyntaxTutorial);
  443. smalltalk.addMethod(
  444. "_pharoEnvironment",
  445. smalltalk.method({
  446. selector: "pharoEnvironment",
  447. category: 'pages',
  448. fn: function (){
  449. var self=this;
  450. return smalltalk.send((smalltalk.Lesson || Lesson), "_title_contents_", ["Pharo environment", "\x22Every Smalltalk system is full of objects.\x0aThere are windows, text, numbers, dates, colors, points and much more.\x0aYou can interact with objects in a much more direct way than is possible with other programming languages.\x0a\x0aEvery object understands the message 'explore'. As a result, you get an Explorer window that shows details about the object.\x22\x0a\x0aDate today explore.\x0a\x0a\x22This shows that the date object consists of a point in time (start) and a duration (one day long).\x22\x0a\x0aProfStef explore.\x0a\x0a\x22You see, ProfStef class has a lot of objects. Let's take a look at my code:\x22\x0a\x0aProfStef browse.\x0a\x0aProfStef next."]);
  451. return self;},
  452. args: [],
  453. source: "pharoEnvironment\x0a\x09^ Lesson\x0atitle: 'Pharo environment' \x0acontents: \x0a'\x22Every Smalltalk system is full of objects.\x0aThere are windows, text, numbers, dates, colors, points and much more.\x0aYou can interact with objects in a much more direct way than is possible with other programming languages.\x0a\x0aEvery object understands the message ''explore''. As a result, you get an Explorer window that shows details about the object.\x22\x0a\x0aDate today explore.\x0a\x0a\x22This shows that the date object consists of a point in time (start) and a duration (one day long).\x22\x0a\x0aProfStef explore.\x0a\x0a\x22You see, ProfStef class has a lot of objects. Let''s take a look at my code:\x22\x0a\x0aProfStef browse.\x0a\x0aProfStef next.'",
  454. messageSends: ["title:contents:"],
  455. referencedClasses: ["Lesson"]
  456. }),
  457. smalltalk.SmalltalkSyntaxTutorial);
  458. smalltalk.addMethod(
  459. "_printing",
  460. smalltalk.method({
  461. selector: "printing",
  462. category: 'pages',
  463. fn: function (){
  464. var self=this;
  465. return smalltalk.send((smalltalk.Lesson || Lesson), "_title_contents_", ["Doing VS Printing: Printing", "\x22Now you're a Do It master ! Let's talk about printing.\x0aIt's a Do It which prints the result next to the expression you've selected.\x0aFor example, select the text below, and click on 'PrintIt':\x22\x0a\x0a1 + 2.\x0a\x0a\x22As with 'DoIt', there is also a shortcut to execute this command.\x0a\x0aTry CTRL-p on the following expressions:\x22\x0a\x0aDate today.\x0a\x0a\x22The result is selected, so you can erase it using the backspace key. Try it !\x22\x0a\x0aDate today asDateString.\x0a\x0aDate today asTimeString.\x0a\x0aProfStef next."]);
  466. return self;},
  467. args: [],
  468. source: "printing \x0a\x09^ Lesson\x0atitle: 'Doing VS Printing: Printing' \x0acontents: \x0a'\x22Now you''re a Do It master ! Let''s talk about printing.\x0aIt''s a Do It which prints the result next to the expression you''ve selected.\x0aFor example, select the text below, and click on ''PrintIt'':\x22\x0a\x0a1 + 2.\x0a\x0a\x22As with ''DoIt'', there is also a shortcut to execute this command.\x0a\x0aTry CTRL-p on the following expressions:\x22\x0a\x0aDate today.\x0a\x0a\x22The result is selected, so you can erase it using the backspace key. Try it !\x22\x0a\x0aDate today asDateString.\x0a\x0aDate today asTimeString.\x0a\x0aProfStef next.'",
  469. messageSends: ["title:contents:"],
  470. referencedClasses: ["Lesson"]
  471. }),
  472. smalltalk.SmalltalkSyntaxTutorial);
  473. smalltalk.addMethod(
  474. "_reflection",
  475. smalltalk.method({
  476. selector: "reflection",
  477. category: 'pages',
  478. fn: function (){
  479. var self=this;
  480. return smalltalk.send((smalltalk.Lesson || Lesson), "_title_contents_", ["Reflection", "\x22You can inspect and change the system at runtime.\x0a\x0aTake a look at the source code of the method #and: of the class Boolean:\x22\x0a\x0a(Boolean methodDictionary at: 'and:') source.\x0a\x0a\x22Or all the methods it sends:\x22\x0a\x0a(Boolean methodDictionary at: 'and:') messageSends.\x0a\x0a\x22Here's all the methods I implement:\x22\x0a\x0aProfStef methodDictionary.\x0a\x0a\x22Let's create a new method to go to the next lesson:\x22\x0a\x0a|newMethod|\x0anewMethod := Compiler new load: 'goToNextLesson ProfStef next.' forClass: ProfStef.\x0aProfStef class addCompiledMethod: newMethod\x0a\x0a\x22Wow! I can't wait to use my new method!\x22\x0a\x0aProfStef goToNextLesson."]);
  481. return self;},
  482. args: [],
  483. source: "reflection\x0a\x09^ Lesson\x0atitle: 'Reflection' \x0acontents: \x0a'\x22You can inspect and change the system at runtime.\x0a\x0aTake a look at the source code of the method #and: of the class Boolean:\x22\x0a\x0a(Boolean methodDictionary at: ''and:'') source.\x0a\x0a\x22Or all the methods it sends:\x22\x0a\x0a(Boolean methodDictionary at: ''and:'') messageSends.\x0a\x0a\x22Here''s all the methods I implement:\x22\x0a\x0aProfStef methodDictionary.\x0a\x0a\x22Let''s create a new method to go to the next lesson:\x22\x0a\x0a|newMethod|\x0anewMethod := Compiler new load: ''goToNextLesson ProfStef next.'' forClass: ProfStef.\x0aProfStef class addCompiledMethod: newMethod\x0a\x0a\x22Wow! I can''t wait to use my new method!\x22\x0a\x0aProfStef goToNextLesson.'",
  484. messageSends: ["title:contents:"],
  485. referencedClasses: ["Lesson"]
  486. }),
  487. smalltalk.SmalltalkSyntaxTutorial);
  488. smalltalk.addMethod(
  489. "_reflectionContinued",
  490. smalltalk.method({
  491. selector: "reflectionContinued",
  492. category: 'pages',
  493. fn: function (){
  494. var self=this;
  495. return smalltalk.send((smalltalk.Lesson || Lesson), "_title_contents_", ["Reflection continued", "\x22So cool, isn't it ? Before going further, let's remove this method:\x22\x0a\x0aProfStef class methodAt: #goToNextLesson.\x0a\x0aProfStef class removeCompiledMethod: (ProfStef class methodAt: #goToNextLesson).\x0a\x0aProfStef class methodAt: #goToNextLesson.\x0a\x0a\x0a\x22Then move forward:\x22\x0a\x0aProfStef perform:#next"]);
  496. return self;},
  497. args: [],
  498. source: "reflectionContinued\x0a\x09^ Lesson\x0atitle: 'Reflection continued' \x0acontents: \x0a'\x22So cool, isn''t it ? Before going further, let''s remove this method:\x22\x0a\x0aProfStef class methodAt: #goToNextLesson.\x0a\x0aProfStef class removeCompiledMethod: (ProfStef class methodAt: #goToNextLesson).\x0a\x0aProfStef class methodAt: #goToNextLesson.\x0a\x0a\x0a\x22Then move forward:\x22\x0a\x0aProfStef perform:#next'",
  499. messageSends: ["title:contents:"],
  500. referencedClasses: ["Lesson"]
  501. }),
  502. smalltalk.SmalltalkSyntaxTutorial);
  503. smalltalk.addMethod(
  504. "_tableOfContents",
  505. smalltalk.method({
  506. selector: "tableOfContents",
  507. category: 'contents',
  508. fn: function (){
  509. var self=this;
  510. return ["welcome", "doingVSPrinting", "printing", "basicTypesNumbers", "basicTypesString", "basicTypesArray", "basicTypesDynamicArray", "messageSyntaxUnary", "messageSyntaxBinary", "messageSyntaxKeyword", "messageSyntaxExecutionOrder", "messageSyntaxExecutionOrderParentheses", "mathematicalPrecedence", "messageSyntaxCascade", "messageSyntaxCascadeShouldNotBeHere", "blocks", "blocksAssignation", "conditionals", "loops", "iterators", "instanciation", "reflection", "reflectionContinued", "theEnd"];
  511. return self;},
  512. args: [],
  513. source: "tableOfContents\x0a^ #(\x09'welcome'\x0a\x09'doingVSPrinting'\x0a\x09'printing'\x0a\x0a\x09'basicTypesNumbers'\x0a\x09\x22'basicTypesCharacters'\x22\x0a\x09'basicTypesString'\x0a\x09\x22'basicTypesSymbol'\x22\x0a\x09'basicTypesArray'\x0a\x09'basicTypesDynamicArray'\x0a\x0a\x09'messageSyntaxUnary'\x0a\x09'messageSyntaxBinary'\x0a\x09'messageSyntaxKeyword'\x0a\x09'messageSyntaxExecutionOrder'\x0a\x09'messageSyntaxExecutionOrderParentheses'\x0a\x09'mathematicalPrecedence'\x0a\x09'messageSyntaxCascade'\x0a\x09'messageSyntaxCascadeShouldNotBeHere'\x0a\x0a\x09'blocks'\x0a\x09'blocksAssignation'\x0a\x09'conditionals'\x0a\x09'loops'\x0a\x09'iterators'\x0a\x0a\x09'instanciation'\x0a\x0a\x09'reflection'\x0a\x09'reflectionContinued'\x0a\x09\x22'pharoEnvironment'\x22\x0a\x0a\x09\x22'debugger'\x22\x0a\x09'theEnd' )",
  514. messageSends: [],
  515. referencedClasses: []
  516. }),
  517. smalltalk.SmalltalkSyntaxTutorial);
  518. smalltalk.addMethod(
  519. "_theEnd",
  520. smalltalk.method({
  521. selector: "theEnd",
  522. category: 'pages',
  523. fn: function (){
  524. var self=this;
  525. return smalltalk.send((smalltalk.Lesson || Lesson), "_title_contents_", ["Tutorial done !", "\x22This tutorial is done. Enjoy programming Smalltalk with Amber. \x0a\x0aYou can run this tutorial again by evaluating: ProfStef go.\x0a\x0aSee you soon !\x22\x0a"]);
  526. return self;},
  527. args: [],
  528. source: "theEnd\x0a\x09^ Lesson\x0atitle: 'Tutorial done !' \x0acontents: \x0a'\x22This tutorial is done. Enjoy programming Smalltalk with Amber. \x0a\x0aYou can run this tutorial again by evaluating: ProfStef go.\x0a\x0aSee you soon !\x22\x0a'",
  529. messageSends: ["title:contents:"],
  530. referencedClasses: ["Lesson"]
  531. }),
  532. smalltalk.SmalltalkSyntaxTutorial);
  533. smalltalk.addMethod(
  534. "_welcome",
  535. smalltalk.method({
  536. selector: "welcome",
  537. category: 'pages',
  538. fn: function (){
  539. var self=this;
  540. return smalltalk.send((smalltalk.Lesson || Lesson), "_title_contents_", ["Welcome", " \x22Hello! I'm Professor Stef. \x0a\x0aYou must want me to help you learn Smalltalk.\x0a\x0aSo let's go to the first lesson. Select the text below and click on the 'DoIt' button\x22\x0a\x0aProfStef next."]);
  541. return self;},
  542. args: [],
  543. source: "welcome\x0a\x09^ Lesson\x0atitle: 'Welcome' \x0acontents: \x0a' \x22Hello! I''m Professor Stef. \x0a\x0aYou must want me to help you learn Smalltalk.\x0a\x0aSo let''s go to the first lesson. Select the text below and click on the ''DoIt'' button\x22\x0a\x0aProfStef next.'",
  544. messageSends: ["title:contents:"],
  545. referencedClasses: ["Lesson"]
  546. }),
  547. smalltalk.SmalltalkSyntaxTutorial);
  548. smalltalk.addClass('Lesson', smalltalk.Object, ['title', 'contents'], 'TrySmalltalk');
  549. smalltalk.addMethod(
  550. "_contents",
  551. smalltalk.method({
  552. selector: "contents",
  553. category: 'accessing',
  554. fn: function (){
  555. var self=this;
  556. return (($receiver = self['@contents']) == nil || $receiver == undefined) ? (function(){return (self['@contents']="");})() : $receiver;
  557. return self;},
  558. args: [],
  559. source: "contents\x0a\x09^ contents ifNil: [contents := '']",
  560. messageSends: ["ifNil:"],
  561. referencedClasses: []
  562. }),
  563. smalltalk.Lesson);
  564. smalltalk.addMethod(
  565. "_contents_",
  566. smalltalk.method({
  567. selector: "contents:",
  568. category: 'accessing',
  569. fn: function (aString){
  570. var self=this;
  571. (self['@contents']=aString);
  572. return self;},
  573. args: ["aString"],
  574. source: "contents: aString\x0a\x09contents := aString",
  575. messageSends: [],
  576. referencedClasses: []
  577. }),
  578. smalltalk.Lesson);
  579. smalltalk.addMethod(
  580. "_title",
  581. smalltalk.method({
  582. selector: "title",
  583. category: 'accessing',
  584. fn: function (){
  585. var self=this;
  586. return (($receiver = self['@title']) == nil || $receiver == undefined) ? (function(){return (self['@title']="");})() : $receiver;
  587. return self;},
  588. args: [],
  589. source: "title\x0a\x09^ title ifNil: [title := '']",
  590. messageSends: ["ifNil:"],
  591. referencedClasses: []
  592. }),
  593. smalltalk.Lesson);
  594. smalltalk.addMethod(
  595. "_title_",
  596. smalltalk.method({
  597. selector: "title:",
  598. category: 'accessing',
  599. fn: function (aString){
  600. var self=this;
  601. (self['@title']=aString);
  602. return self;},
  603. args: ["aString"],
  604. source: "title: aString\x0a\x09title := aString",
  605. messageSends: [],
  606. referencedClasses: []
  607. }),
  608. smalltalk.Lesson);
  609. smalltalk.addMethod(
  610. "_title_contents_",
  611. smalltalk.method({
  612. selector: "title:contents:",
  613. category: 'instance creation',
  614. fn: function (aTitle, someContents){
  615. var self=this;
  616. return (function($rec){smalltalk.send($rec, "_title_", [aTitle]);return smalltalk.send($rec, "_contents_", [someContents]);})(smalltalk.send(self, "_new", []));
  617. return self;},
  618. args: ["aTitle", "someContents"],
  619. source: "title: aTitle contents: someContents\x0a\x09^ (self new)\x0a\x09\x09title: aTitle;\x0a\x09\x09contents: someContents",
  620. messageSends: ["title:", "contents:", "new"],
  621. referencedClasses: []
  622. }),
  623. smalltalk.Lesson.klass);
  624. smalltalk.addClass('ProfStef', smalltalk.Object, ['tutorialPlayer', 'widget'], 'TrySmalltalk');
  625. smalltalk.ProfStef.comment="A ProfStef is the Smalltalk teacher. To start the tutorial, evaluate:\x0aProfStef go.\x0a\x0aTo go to the next lesson evaluate:\x0aProfStef next.\x0a\x0aTo execute your own tutorial:\x0aProfStef goOn: MyOwnTutorial\x0a\x0aTo see a table of contents with all defined tutorials:\x0aProfStef contents"
  626. smalltalk.addMethod(
  627. "_first",
  628. smalltalk.method({
  629. selector: "first",
  630. category: 'navigation',
  631. fn: function (){
  632. var self=this;
  633. smalltalk.send(smalltalk.send(self, "_tutorialPlayer", []), "_first", []);
  634. return smalltalk.send(self, "_showCurrentLesson", []);
  635. return self;},
  636. args: [],
  637. source: "first\x0a\x09self tutorialPlayer first.\x0a\x09^ self showCurrentLesson.",
  638. messageSends: ["first", "tutorialPlayer", "showCurrentLesson"],
  639. referencedClasses: []
  640. }),
  641. smalltalk.ProfStef);
  642. smalltalk.addMethod(
  643. "_next",
  644. smalltalk.method({
  645. selector: "next",
  646. category: 'navigation',
  647. fn: function (){
  648. var self=this;
  649. smalltalk.send(smalltalk.send(self, "_tutorialPlayer", []), "_next", []);
  650. return smalltalk.send(self, "_showCurrentLesson", []);
  651. return self;},
  652. args: [],
  653. source: "next\x0a\x09self tutorialPlayer next.\x0a\x09^ self showCurrentLesson.",
  654. messageSends: ["next", "tutorialPlayer", "showCurrentLesson"],
  655. referencedClasses: []
  656. }),
  657. smalltalk.ProfStef);
  658. smalltalk.addMethod(
  659. "_previous",
  660. smalltalk.method({
  661. selector: "previous",
  662. category: 'navigation',
  663. fn: function (){
  664. var self=this;
  665. smalltalk.send(smalltalk.send(self, "_tutorialPlayer", []), "_previous", []);
  666. return smalltalk.send(self, "_showCurrentLesson", []);
  667. return self;},
  668. args: [],
  669. source: "previous\x0a\x09self tutorialPlayer previous.\x0a\x09^ self showCurrentLesson.",
  670. messageSends: ["previous", "tutorialPlayer", "showCurrentLesson"],
  671. referencedClasses: []
  672. }),
  673. smalltalk.ProfStef);
  674. smalltalk.addMethod(
  675. "_progress",
  676. smalltalk.method({
  677. selector: "progress",
  678. category: 'accessing',
  679. fn: function (){
  680. var self=this;
  681. return smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send("(", "__comma", [smalltalk.send(self, "_tutorialPositionString", [])]), "__comma", ["/"]), "__comma", [smalltalk.send(self, "_tutorialSizeString", [])]), "__comma", [")"]);
  682. return self;},
  683. args: [],
  684. source: "progress\x0a\x09^ '(', self tutorialPositionString, '/', self tutorialSizeString, ')'.",
  685. messageSends: [",", "tutorialPositionString", "tutorialSizeString"],
  686. referencedClasses: []
  687. }),
  688. smalltalk.ProfStef);
  689. smalltalk.addMethod(
  690. "_showCurrentLesson",
  691. smalltalk.method({
  692. selector: "showCurrentLesson",
  693. category: 'accessing',
  694. fn: function (){
  695. var self=this;
  696. var lesson=nil;
  697. (lesson=smalltalk.send(smalltalk.send(self, "_tutorialPlayer", []), "_currentLesson", []));
  698. smalltalk.send(self['@widget'], "_contents_", [smalltalk.send(lesson, "_contents", [])]);
  699. smalltalk.send(self['@widget'], "_setTitle_", [smalltalk.send(smalltalk.send(smalltalk.send(lesson, "_title", []), "__comma", [" "]), "__comma", [smalltalk.send(self, "_progress", [])])]);
  700. return self;},
  701. args: [],
  702. source: "showCurrentLesson\x0a\x09| lesson |\x0a\x09lesson := self tutorialPlayer currentLesson.\x0a\x09widget contents: lesson contents.\x0a\x09widget setTitle: lesson title , ' ' , self progress.",
  703. messageSends: ["currentLesson", "tutorialPlayer", "contents:", "contents", "setTitle:", ",", "title", "progress"],
  704. referencedClasses: []
  705. }),
  706. smalltalk.ProfStef);
  707. smalltalk.addMethod(
  708. "_tutorialPlayer",
  709. smalltalk.method({
  710. selector: "tutorialPlayer",
  711. category: 'accessing',
  712. fn: function (){
  713. var self=this;
  714. return (($receiver = self['@tutorialPlayer']) == nil || $receiver == undefined) ? (function(){return (self['@tutorialPlayer']=smalltalk.send((smalltalk.TutorialPlayer || TutorialPlayer), "_new", []));})() : $receiver;
  715. return self;},
  716. args: [],
  717. source: "tutorialPlayer\x0a\x09^ tutorialPlayer ifNil: [tutorialPlayer := TutorialPlayer new]",
  718. messageSends: ["ifNil:", "new"],
  719. referencedClasses: ["TutorialPlayer"]
  720. }),
  721. smalltalk.ProfStef);
  722. smalltalk.addMethod(
  723. "_tutorialPositionString",
  724. smalltalk.method({
  725. selector: "tutorialPositionString",
  726. category: 'accessing',
  727. fn: function (){
  728. var self=this;
  729. return smalltalk.send(smalltalk.send(smalltalk.send(self, "_tutorialPlayer", []), "_tutorialPosition", []), "_asString", []);
  730. return self;},
  731. args: [],
  732. source: "tutorialPositionString\x0a\x09^ self tutorialPlayer tutorialPosition asString.",
  733. messageSends: ["asString", "tutorialPosition", "tutorialPlayer"],
  734. referencedClasses: []
  735. }),
  736. smalltalk.ProfStef);
  737. smalltalk.addMethod(
  738. "_tutorialSizeString",
  739. smalltalk.method({
  740. selector: "tutorialSizeString",
  741. category: 'accessing',
  742. fn: function (){
  743. var self=this;
  744. return smalltalk.send(smalltalk.send(smalltalk.send(self, "_tutorialPlayer", []), "_size", []), "_asString", []);
  745. return self;},
  746. args: [],
  747. source: "tutorialSizeString\x0a\x09^ self tutorialPlayer size asString",
  748. messageSends: ["asString", "size", "tutorialPlayer"],
  749. referencedClasses: []
  750. }),
  751. smalltalk.ProfStef);
  752. smalltalk.addMethod(
  753. "_widget_",
  754. smalltalk.method({
  755. selector: "widget:",
  756. category: 'accessing',
  757. fn: function (aWidget){
  758. var self=this;
  759. (self['@widget']=aWidget);
  760. return self;},
  761. args: ["aWidget"],
  762. source: "widget: aWidget\x0a\x09widget := aWidget",
  763. messageSends: [],
  764. referencedClasses: []
  765. }),
  766. smalltalk.ProfStef);
  767. smalltalk.ProfStef.klass.iVarNames = ['instance'];
  768. smalltalk.addMethod(
  769. "_default",
  770. smalltalk.method({
  771. selector: "default",
  772. category: 'initialize',
  773. fn: function (){
  774. var self=this;
  775. return (($receiver = self['@instance']) == nil || $receiver == undefined) ? (function(){return (self['@instance']=smalltalk.send(self, "_new", []));})() : $receiver;
  776. return self;},
  777. args: [],
  778. source: "default \x0a\x09^ instance ifNil: [instance := self new]",
  779. messageSends: ["ifNil:", "new"],
  780. referencedClasses: []
  781. }),
  782. smalltalk.ProfStef.klass);
  783. smalltalk.addMethod(
  784. "_first",
  785. smalltalk.method({
  786. selector: "first",
  787. category: 'navigation',
  788. fn: function (){
  789. var self=this;
  790. return smalltalk.send(smalltalk.send(self, "_default", []), "_first", []);
  791. return self;},
  792. args: [],
  793. source: "first\x0a\x09^ self default first.",
  794. messageSends: ["first", "default"],
  795. referencedClasses: []
  796. }),
  797. smalltalk.ProfStef.klass);
  798. smalltalk.addMethod(
  799. "_go",
  800. smalltalk.method({
  801. selector: "go",
  802. category: 'navigation',
  803. fn: function (){
  804. var self=this;
  805. smalltalk.send(self, "_first", []);
  806. return self;},
  807. args: [],
  808. source: "go\x0a\x09self first.",
  809. messageSends: ["first"],
  810. referencedClasses: []
  811. }),
  812. smalltalk.ProfStef.klass);
  813. smalltalk.addMethod(
  814. "_next",
  815. smalltalk.method({
  816. selector: "next",
  817. category: 'navigation',
  818. fn: function (){
  819. var self=this;
  820. return smalltalk.send(smalltalk.send(self, "_default", []), "_next", []);
  821. return self;},
  822. args: [],
  823. source: "next\x0a\x09^ self default next.",
  824. messageSends: ["next", "default"],
  825. referencedClasses: []
  826. }),
  827. smalltalk.ProfStef.klass);
  828. smalltalk.addMethod(
  829. "_previous",
  830. smalltalk.method({
  831. selector: "previous",
  832. category: 'navigation',
  833. fn: function (){
  834. var self=this;
  835. return smalltalk.send(smalltalk.send(self, "_default", []), "_previous", []);
  836. return self;},
  837. args: [],
  838. source: "previous\x0a\x09^ self default previous.",
  839. messageSends: ["previous", "default"],
  840. referencedClasses: []
  841. }),
  842. smalltalk.ProfStef.klass);
  843. smalltalk.addClass('TrySmalltalkWidget', smalltalk.Widget, ['workspace', 'contents', 'header'], 'TrySmalltalk');
  844. smalltalk.addMethod(
  845. "_contents",
  846. smalltalk.method({
  847. selector: "contents",
  848. category: 'accessing',
  849. fn: function (){
  850. var self=this;
  851. return smalltalk.send(smalltalk.send(self, "_workspace", []), "_val", []);
  852. return self;},
  853. args: [],
  854. source: "contents\x0a\x09^self workspace val",
  855. messageSends: ["val", "workspace"],
  856. referencedClasses: []
  857. }),
  858. smalltalk.TrySmalltalkWidget);
  859. smalltalk.addMethod(
  860. "_contents_",
  861. smalltalk.method({
  862. selector: "contents:",
  863. category: 'accessing',
  864. fn: function (aString){
  865. var self=this;
  866. smalltalk.send(smalltalk.send(self, "_workspace", []), "_val_", [aString]);
  867. return self;},
  868. args: ["aString"],
  869. source: "contents: aString\x0a\x09self workspace val: aString",
  870. messageSends: ["val:", "workspace"],
  871. referencedClasses: []
  872. }),
  873. smalltalk.TrySmalltalkWidget);
  874. smalltalk.addMethod(
  875. "_renderButtonsOn_",
  876. smalltalk.method({
  877. selector: "renderButtonsOn:",
  878. category: 'rendering',
  879. fn: function (html){
  880. var self=this;
  881. (function($rec){smalltalk.send($rec, "_with_", ["DoIt"]);smalltalk.send($rec, "_title_", ["ctrl+d"]);return smalltalk.send($rec, "_onClick_", [(function(){return smalltalk.send(smalltalk.send(self, "_workspace", []), "_doIt", []);})]);})(smalltalk.send(html, "_button", []));
  882. (function($rec){smalltalk.send($rec, "_with_", ["PrintIt"]);smalltalk.send($rec, "_title_", ["ctrl+p"]);return smalltalk.send($rec, "_onClick_", [(function(){return smalltalk.send(smalltalk.send(self, "_workspace", []), "_printIt", []);})]);})(smalltalk.send(html, "_button", []));
  883. (function($rec){smalltalk.send($rec, "_with_", ["InspectIt"]);smalltalk.send($rec, "_title_", ["ctrl+i"]);return smalltalk.send($rec, "_onClick_", [(function(){return smalltalk.send(smalltalk.send(self, "_workspace", []), "_inspectIt", []);})]);})(smalltalk.send(html, "_button", []));
  884. return self;},
  885. args: ["html"],
  886. source: "renderButtonsOn: html\x0a html button\x0a\x09with: 'DoIt';\x0a\x09title: 'ctrl+d';\x0a\x09onClick: [self workspace doIt].\x0a html button\x0a\x09with: 'PrintIt';\x0a\x09title: 'ctrl+p';\x0a\x09onClick: [self workspace printIt].\x0a html button\x0a\x09with: 'InspectIt';\x0a\x09title: 'ctrl+i';\x0a\x09onClick: [self workspace inspectIt]",
  887. messageSends: ["with:", "title:", "onClick:", "doIt", "workspace", "button", "printIt", "inspectIt"],
  888. referencedClasses: []
  889. }),
  890. smalltalk.TrySmalltalkWidget);
  891. smalltalk.addMethod(
  892. "_renderOn_",
  893. smalltalk.method({
  894. selector: "renderOn:",
  895. category: 'rendering',
  896. fn: function (html){
  897. var self=this;
  898. (function($rec){smalltalk.send($rec, "_class_", ["profStef"]);smalltalk.send($rec, "_with_", [(function(){return (self['@header']=smalltalk.send(html, "_h2", []));})]);smalltalk.send($rec, "_with_", [(function(){return smalltalk.send(smalltalk.send(self, "_workspace", []), "_renderOn_", [html]);})]);return smalltalk.send($rec, "_with_", [(function(){return smalltalk.send(self, "_renderButtonsOn_", [html]);})]);})(smalltalk.send(html, "_div", []));
  899. (function($rec){smalltalk.send($rec, "_widget_", [self]);return smalltalk.send($rec, "_showCurrentLesson", []);})(smalltalk.send((smalltalk.ProfStef || ProfStef), "_default", []));
  900. return self;},
  901. args: ["html"],
  902. source: "renderOn: html\x0a\x09html div \x0a\x09\x09class: 'profStef'; \x0a\x09\x09with: [header := html h2];\x0a\x09\x09with: [self workspace renderOn: html];\x0a\x09\x09with: [self renderButtonsOn: html].\x0a ProfStef default \x0a\x09\x09widget: self;\x0a\x09\x09showCurrentLesson",
  903. messageSends: ["class:", "with:", "h2", "renderOn:", "workspace", "renderButtonsOn:", "div", "widget:", "showCurrentLesson", "default"],
  904. referencedClasses: ["ProfStef"]
  905. }),
  906. smalltalk.TrySmalltalkWidget);
  907. smalltalk.addMethod(
  908. "_setTitle_",
  909. smalltalk.method({
  910. selector: "setTitle:",
  911. category: 'accessing',
  912. fn: function (aString){
  913. var self=this;
  914. smalltalk.send(self['@header'], "_contents_", [(function(html){return smalltalk.send(html, "_with_", [aString]);})]);
  915. return self;},
  916. args: ["aString"],
  917. source: "setTitle: aString\x0a\x09header contents: [:html | html with: aString]",
  918. messageSends: ["contents:", "with:"],
  919. referencedClasses: []
  920. }),
  921. smalltalk.TrySmalltalkWidget);
  922. smalltalk.addMethod(
  923. "_workspace",
  924. smalltalk.method({
  925. selector: "workspace",
  926. category: 'accessing',
  927. fn: function (){
  928. var self=this;
  929. return (($receiver = self['@workspace']) == nil || $receiver == undefined) ? (function(){return (self['@workspace']=smalltalk.send((smalltalk.SourceArea || SourceArea), "_new", []));})() : $receiver;
  930. return self;},
  931. args: [],
  932. source: "workspace\x0a\x09^ workspace ifNil: [\x0a \x09workspace := SourceArea new]",
  933. messageSends: ["ifNil:", "new"],
  934. referencedClasses: ["SourceArea"]
  935. }),
  936. smalltalk.TrySmalltalkWidget);
  937. smalltalk.addMethod(
  938. "_open",
  939. smalltalk.method({
  940. selector: "open",
  941. category: 'initialize',
  942. fn: function (){
  943. var self=this;
  944. smalltalk.send(smalltalk.send(self, "_new", []), "_appendToJQuery_", [smalltalk.send("body", "_asJQuery", [])]);
  945. return self;},
  946. args: [],
  947. source: "open\x0a\x09self new appendToJQuery: 'body' asJQuery.",
  948. messageSends: ["appendToJQuery:", "new", "asJQuery"],
  949. referencedClasses: []
  950. }),
  951. smalltalk.TrySmalltalkWidget.klass);
  952. smalltalk.addClass('TutorialPlayer', smalltalk.Object, ['tutorialPosition', 'tutorial'], 'TrySmalltalk');
  953. smalltalk.TutorialPlayer.comment="I can navigate through an AbstractTutorial subclass. With #next and #previous you can go forward and backward through the tutorial."
  954. smalltalk.addMethod(
  955. "_currentLesson",
  956. smalltalk.method({
  957. selector: "currentLesson",
  958. category: 'accessing',
  959. fn: function (){
  960. var self=this;
  961. return smalltalk.send(smalltalk.send(self, "_tutorial", []), "_lessonAt_", [smalltalk.send(self, "_tutorialPosition", [])]);
  962. return self;},
  963. args: [],
  964. source: "currentLesson\x0a\x09^ self tutorial lessonAt: self tutorialPosition.",
  965. messageSends: ["lessonAt:", "tutorial", "tutorialPosition"],
  966. referencedClasses: []
  967. }),
  968. smalltalk.TutorialPlayer);
  969. smalltalk.addMethod(
  970. "_first",
  971. smalltalk.method({
  972. selector: "first",
  973. category: 'navigation',
  974. fn: function (){
  975. var self=this;
  976. smalltalk.send(self, "_rewind", []);
  977. return smalltalk.send(self, "_currentLesson", []);
  978. return self;},
  979. args: [],
  980. source: "first\x0a\x09self rewind.\x0a\x09^ self currentLesson",
  981. messageSends: ["rewind", "currentLesson"],
  982. referencedClasses: []
  983. }),
  984. smalltalk.TutorialPlayer);
  985. smalltalk.addMethod(
  986. "_last",
  987. smalltalk.method({
  988. selector: "last",
  989. category: 'navigation',
  990. fn: function (){
  991. var self=this;
  992. (self['@tutorialPosition']=smalltalk.send(self, "_size", []));
  993. return smalltalk.send(self, "_currentLesson", []);
  994. return self;},
  995. args: [],
  996. source: "last\x0a\x09tutorialPosition := self size.\x0a\x09^ self currentLesson",
  997. messageSends: ["size", "currentLesson"],
  998. referencedClasses: []
  999. }),
  1000. smalltalk.TutorialPlayer);
  1001. smalltalk.addMethod(
  1002. "_next",
  1003. smalltalk.method({
  1004. selector: "next",
  1005. category: 'navigation',
  1006. fn: function (){
  1007. var self=this;
  1008. ((($receiver = ((($receiver = smalltalk.send(self, "_tutorialPosition", [])).klass === smalltalk.Number) ? $receiver <smalltalk.send(self, "_size", []) : smalltalk.send($receiver, "__lt", [smalltalk.send(self, "_size", [])]))).klass === smalltalk.Boolean) ? ($receiver ? (function(){return (self['@tutorialPosition']=((($receiver = self['@tutorialPosition']).klass === smalltalk.Number) ? $receiver +(1) : smalltalk.send($receiver, "__plus", [(1)])));})() : nil) : smalltalk.send($receiver, "_ifTrue_", [(function(){return (self['@tutorialPosition']=((($receiver = self['@tutorialPosition']).klass === smalltalk.Number) ? $receiver +(1) : smalltalk.send($receiver, "__plus", [(1)])));})]));
  1009. return smalltalk.send(self, "_currentLesson", []);
  1010. return self;},
  1011. args: [],
  1012. source: "next\x0a\x09self tutorialPosition < self size\x0a\x09\x09ifTrue: [tutorialPosition := tutorialPosition + 1].\x0a\x09^ self currentLesson",
  1013. messageSends: ["ifTrue:", "<", "tutorialPosition", "size", "+", "currentLesson"],
  1014. referencedClasses: []
  1015. }),
  1016. smalltalk.TutorialPlayer);
  1017. smalltalk.addMethod(
  1018. "_previous",
  1019. smalltalk.method({
  1020. selector: "previous",
  1021. category: 'navigation',
  1022. fn: function (){
  1023. var self=this;
  1024. ((($receiver = ((($receiver = self['@tutorialPosition']).klass === smalltalk.Number) ? $receiver >(1) : smalltalk.send($receiver, "__gt", [(1)]))).klass === smalltalk.Boolean) ? ($receiver ? (function(){return (self['@tutorialPosition']=((($receiver = self['@tutorialPosition']).klass === smalltalk.Number) ? $receiver -(1) : smalltalk.send($receiver, "__minus", [(1)])));})() : nil) : smalltalk.send($receiver, "_ifTrue_", [(function(){return (self['@tutorialPosition']=((($receiver = self['@tutorialPosition']).klass === smalltalk.Number) ? $receiver -(1) : smalltalk.send($receiver, "__minus", [(1)])));})]));
  1025. return smalltalk.send(self, "_currentLesson", []);
  1026. return self;},
  1027. args: [],
  1028. source: "previous\x0a\x09tutorialPosition > 1 ifTrue: [tutorialPosition := tutorialPosition - 1].\x0a\x09^ self currentLesson",
  1029. messageSends: ["ifTrue:", ">", "-", "currentLesson"],
  1030. referencedClasses: []
  1031. }),
  1032. smalltalk.TutorialPlayer);
  1033. smalltalk.addMethod(
  1034. "_rewind",
  1035. smalltalk.method({
  1036. selector: "rewind",
  1037. category: 'navigation',
  1038. fn: function (){
  1039. var self=this;
  1040. (self['@tutorialPosition']=(1));
  1041. return self;},
  1042. args: [],
  1043. source: "rewind\x0a\x09tutorialPosition := 1.",
  1044. messageSends: [],
  1045. referencedClasses: []
  1046. }),
  1047. smalltalk.TutorialPlayer);
  1048. smalltalk.addMethod(
  1049. "_size",
  1050. smalltalk.method({
  1051. selector: "size",
  1052. category: 'accessing',
  1053. fn: function (){
  1054. var self=this;
  1055. return smalltalk.send(smalltalk.send(self, "_tutorial", []), "_size", []);
  1056. return self;},
  1057. args: [],
  1058. source: "size\x0a\x09^ self tutorial size",
  1059. messageSends: ["size", "tutorial"],
  1060. referencedClasses: []
  1061. }),
  1062. smalltalk.TutorialPlayer);
  1063. smalltalk.addMethod(
  1064. "_tutorial",
  1065. smalltalk.method({
  1066. selector: "tutorial",
  1067. category: 'accessing',
  1068. fn: function (){
  1069. var self=this;
  1070. return (($receiver = self['@tutorial']) == nil || $receiver == undefined) ? (function(){return (self['@tutorial']=smalltalk.send((smalltalk.SmalltalkSyntaxTutorial || SmalltalkSyntaxTutorial), "_new", []));})() : $receiver;
  1071. return self;},
  1072. args: [],
  1073. source: "tutorial\x0a\x09^ tutorial ifNil: [tutorial := SmalltalkSyntaxTutorial new]",
  1074. messageSends: ["ifNil:", "new"],
  1075. referencedClasses: ["SmalltalkSyntaxTutorial"]
  1076. }),
  1077. smalltalk.TutorialPlayer);
  1078. smalltalk.addMethod(
  1079. "_tutorial_",
  1080. smalltalk.method({
  1081. selector: "tutorial:",
  1082. category: 'accessing',
  1083. fn: function (aTutorial){
  1084. var self=this;
  1085. (self['@tutorial']=aTutorial);
  1086. return self;},
  1087. args: ["aTutorial"],
  1088. source: "tutorial: aTutorial\x0a\x09tutorial := aTutorial",
  1089. messageSends: [],
  1090. referencedClasses: []
  1091. }),
  1092. smalltalk.TutorialPlayer);
  1093. smalltalk.addMethod(
  1094. "_tutorialPosition",
  1095. smalltalk.method({
  1096. selector: "tutorialPosition",
  1097. category: 'accessing',
  1098. fn: function (){
  1099. var self=this;
  1100. return (($receiver = self['@tutorialPosition']) == nil || $receiver == undefined) ? (function(){smalltalk.send(self, "_rewind", []);return self['@tutorialPosition'];})() : $receiver;
  1101. return self;},
  1102. args: [],
  1103. source: "tutorialPosition \x0a\x09^ tutorialPosition ifNil: [\x0a\x09\x09self rewind.\x0a\x09\x09tutorialPosition.\x0a\x09].",
  1104. messageSends: ["ifNil:", "rewind"],
  1105. referencedClasses: []
  1106. }),
  1107. smalltalk.TutorialPlayer);
  1108. smalltalk.addMethod(
  1109. "_tutorialPosition_",
  1110. smalltalk.method({
  1111. selector: "tutorialPosition:",
  1112. category: 'accessing',
  1113. fn: function (aTutorialPosition){
  1114. var self=this;
  1115. (self['@tutorialPosition']=aTutorialPosition);
  1116. return self;},
  1117. args: ["aTutorialPosition"],
  1118. source: "tutorialPosition: aTutorialPosition \x0a\x09tutorialPosition := aTutorialPosition",
  1119. messageSends: [],
  1120. referencedClasses: []
  1121. }),
  1122. smalltalk.TutorialPlayer);