Eliot Miranda uploaded a new version of Compiler to project The Trunk:
http://source.squeak.org/trunk/Compiler-eem.381.mcz
==================== Summary ====================
Name: Compiler-eem.381
Author: eem
Time: 31 May 2018, 4:59:26.014435 pm
UUID: 6612bdf4-e29a-4cc5-a550-139de9e3c42d
Ancestors: Compiler-eem.380
Fix typedScanTokens: for underscore-prefixed symbols such as #_WIN32.
=============== Diff against Compiler-eem.380 ===============
Item was changed:
----- Method: Scanner>>initScannerForTokenization (in category 'initialize-release') -----
initScannerForTokenization
"Use a version of typeTable that doesn't raise xIllegal when enocuntering an _"
| underscoreIndex |
underscoreIndex := typeTable identityIndexOf: #xUnderscore ifAbsent: [^self].
typeTable := typeTable copy.
+ typeTable at: underscoreIndex put: #xUnderscoreForTokenization.
+ typeTable at: (typeTable identityIndexOf: #xLitQuote) put: #xLitQuoteForTokenization!
- typeTable at: underscoreIndex put: #xUnderscoreForTokenization!
Item was added:
+ ----- Method: Scanner>>xLitQuoteForTokenization (in category 'multi-character scans') -----
+ xLitQuoteForTokenization
+ "Parse underscores as per the regular parser when following a # symbol, so that e.g. #_WIN32 is correctly tokenized."
+ | index |
+ index := typeTable identityIndexOf: #xUnderscoreForTokenization.
+ typeTable at: index put: #xUnderscore.
+ [self xLitQuote] ensure:
+ [typeTable at: index put: #xUnderscoreForTokenization]!
Item was changed:
----- Method: Scanner>>xUnderscoreForTokenization (in category 'multi-character scans') -----
xUnderscoreForTokenization
+ "Parse underscores as assignments so as to be able to correctly tokenize ancient source code."
self step.
tokenType := #leftArrow.
^token := #'_'!
Eliot Miranda uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-eem.1174.mcz
==================== Summary ====================
Name: Kernel-eem.1174
Author: eem
Time: 31 May 2018, 4:28:54.683734 pm
UUID: 08eb9e3c-2fe3-40e5-8733-4a95f8d9cd0b
Ancestors: Kernel-topa.1173
Fix a bug in Pragma printing; immedatey after a parse but before a method is created, a pragma's method will be nil. Printing assumed it never would be; hence havoc was caused in the debugger when looking at parse trees.
=============== Diff against Kernel-topa.1173 ===============
Item was changed:
----- Method: Pragma>>printOn: (in category 'printing') -----
printOn: aStream
aStream
nextPut: $<;
+ print: self message.
+ method ifNotNil:
+ [:m|
+ aStream nextPutAll: ' "in '.
+ m printReferenceOn: aStream.
+ aStream nextPut: $"].
+ aStream nextPut: $>!
- print: self message;
- nextPutAll: ' "in '.
- method printReferenceOn: aStream.
- aStream nextPutAll: '">'!
Karl Ramberg uploaded a new version of MorphicExtras to project The Trunk:
http://source.squeak.org/trunk/MorphicExtras-kfr.237.mcz
==================== Summary ====================
Name: MorphicExtras-kfr.237
Author: kfr
Time: 31 May 2018, 8:38:11.47978 pm
UUID: cd5f12e9-d70d-0848-875e-69d68177210f
Ancestors: MorphicExtras-mt.236
Moved some conversion up from TextMorph to TextPlusMorph
=============== Diff against MorphicExtras-mt.236 ===============
Item was added:
+ ----- Method: TextPlusMorph>>convertToCurrentVersion:refStream: (in category 'objects from disk') -----
+ convertToCurrentVersion: varDict refStream: smartRefStrm
+ "Fix up misaligned entries from varDict in old project"
+ varDict at: 'slotName' ifPresent: [ :x | text:= x]. "Not sure why the text is in 'slotName'"
+ varDict at: 'model' ifPresent: [ :x | textStyle:= x]."Or why textStyle is in 'model'"
+ self releaseParagraphReally.
+ ^ super convertToCurrentVersion: varDict refStream: smartRefStrm.
+
+ !
Marcel Taeumel uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-mt.1446.mcz
==================== Summary ====================
Name: Morphic-mt.1446
Author: mt
Time: 31 May 2018, 11:05:49.723667 am
UUID: 44cfc002-66ac-2041-9339-ede4e61a1b58
Ancestors: Morphic-mt.1445
Small compatibility fix to make older system windows load. Those windows do not user SstemWindowButton but IconicButton instances.
=============== Diff against Morphic-mt.1445 ===============
Item was added:
+ ----- Method: IconicButton>>dim (in category 'compatibility') -----
+ dim
+ "backwards compability for old system windows"
+ !
Item was added:
+ ----- Method: IconicButton>>undim (in category 'compatibility') -----
+ undim
+ "backwards compability for old system windows"
+ !
Marcel Taeumel uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-mt.1445.mcz
==================== Summary ====================
Name: Morphic-mt.1445
Author: mt
Time: 31 May 2018, 10:32:00.706975 am
UUID: 5bb479eb-ac7f-4d42-a614-96468d8dd517
Ancestors: Morphic-mt.1444
Refactor the halo-navigation improvement from Morphic-cmm.1443. The actual change is not in the initial halo invocation but in the transferring of halos between morphs. Thus, still exit the event filter in PasteUpMorph as early as possible to just deal with regular event dispatch. See the line "anEvent hand halo ifNotNil: [^ self]" in #tryInvokeHalo.
=============== Diff against Morphic-mt.1444 ===============
Item was changed:
----- Method: PasteUpMorph>>tryInvokeHalo: (in category 'events-processing') -----
+ tryInvokeHalo: anEvent
+
+ | innerMost target |
+ anEvent hand halo ifNotNil: [^ self "No invocation needed. Halo will handle transfer itself."].
+ Preferences noviceMode ifTrue: [^ self "No halo in novice mode."].
+ Morph haloForAll ifFalse: [^ self].
+
+ innerMost := (self morphsAt: anEvent position unlocked: true) first.
+
+ "1) Try to use innermost morph but skip all the ones that do not want to show a halo along the owner chain."
+ target := innerMost.
+ [target isNil or: [target wantsHaloFromClick]]
+ whileFalse: [target := target owner].
+ target ifNil: [^ self].
+
+ "2) Without a modifier, which is normal, find the outermost container for that inner morph."
+ (innerMost == self or: [anEvent shiftPressed]) ifFalse: [
+ | previousTargets |
+ previousTargets := OrderedCollection new.
+ [target notNil and: [target owner ~~ self]] whileTrue: [
+ previousTargets add: target.
+ target := target owner].
+ target ifNil: [^ self].
+ [previousTargets isEmpty or: [target wantsHaloFromClick]] whileFalse: [
+ target := previousTargets removeLast].
+ target wantsHaloFromClick ifFalse: [^ self]].
+
+ "3) Now that we have the target, show the halo. Abort event dispatching, too, to avoid confusion."
+ anEvent hand newMouseFocus: target event: anEvent.
+ target invokeHaloOrMove: anEvent.
+ anEvent ignore.!
- tryInvokeHalo: aUserInputEvent
- "Invoke halos around the top-most world container at aUserInputEvent's #position. If it was already halo'd, zero-in on its next inward component morph at that position. Holding Shift during the click reverses this traversal order."
- | stack target owners |
- Preferences noviceMode ifTrue: [^self ].
- Morph haloForAll ifFalse: [^self].
- "the stack is the top-most morph to bottom-most."
- stack := (self morphsAt: aUserInputEvent position unlocked: true) select: [ : each | each wantsHaloFromClick ].
- stack ifEmpty: [^self].
- target :=
- aUserInputEvent hand halo
- ifNil: [ stack first ]
- ifNotNil:
- [ : existingHalo |
- stack allButFirst "halo's are always topmost on the stack"
- detect: [ : each | each owner == self ]
- ifFound:
- [ : topMostWhereClicked |
- (existingHalo target withAllOwners includes: topMostWhereClicked)
- ifTrue: [ "No invocation needed. Halo will handle transfer itself." ^self ]
- ifFalse:
- [ "Transfer halo to new world container."
- aUserInputEvent hand removeHalo.
- aUserInputEvent shiftPressed
- ifTrue: [ stack second ]
- ifFalse: [ topMostWhereClicked ] ] ]
- ifNone: ["Okay, invoke halos on the world." self ] ].
- "With a modifier, we want the innermost, otherwise the outermost."
- owners := target withAllOwners select: [ : each | each wantsHaloFromClick ].
- "the last owner is expected to be self."
- target := aUserInputEvent shiftPressed ifTrue: [ owners first ] ifFalse: [ owners at: owners size-1 ifAbsent: [self] ].
- "Now that we have the target, show the halo. Abort event dispatching, too, to avoid confusion."
- aUserInputEvent hand newMouseFocus: target event: aUserInputEvent.
- target invokeHaloOrMove: aUserInputEvent.
- "aUserInputEvent has been consumed, don't let it cause any further side-effects."
- aUserInputEvent ignore!
Item was changed:
----- Method: SimpleHaloMorph>>transferHalo: (in category 'pop up') -----
transferHalo: event
+ "Transfer the halo to the next likely recipient. Switch between siblings if overlapping."
- "Transfer the halo to the next likely recipient"
+ (self target world morphsAt: event position) allButFirst "... the halo itself"
+ detect: [:morph |
+ "Sibling found?"
+ (morph owner == self target owner
+ and: [morph ~~ self target])
+ ifTrue: [
+ ^ morph invokeHaloOrMove: event].
+ "No sibling possible anymore?"
+ morph == self target].
+
self target
transferHalo: (event transformedBy: (self target transformedFrom: self))
from: self target.!
Marcel Taeumel uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-mt.1444.mcz
==================== Summary ====================
Name: Morphic-mt.1444
Author: mt
Time: 31 May 2018, 9:28:12.813323 am
UUID: d41ef171-b992-1a4e-b2d5-009f0e9e3134
Ancestors: Morphic-cmm.1443
Reverts the change from Morphic-cmm.1443 about borderStyle to make test04InnerBounds in BorderedMorphTests green again.
=============== Diff against Morphic-cmm.1443 ===============
Item was changed:
----- Method: Morph>>borderStyle: (in category 'accessing') -----
borderStyle: aBorderStyle
+
aBorderStyle = self borderStyle ifTrue: [^ self].
+
"If we cannot draw the new border, accept at least its color and width."
((self canDrawBorder: aBorderStyle) or: [aBorderStyle isNil])
ifTrue: [self setProperty: #borderStyle toValue: aBorderStyle]
ifFalse: [
self borderStyle
width: aBorderStyle width;
baseColor: aBorderStyle baseColor].
+
self borderStyle trackColorFrom: self.
+
+ self
+ layoutChanged;
+ changed.!
- self isInWorld ifTrue:
- [ self
- layoutChanged;
- changed ]!
Marcel Taeumel uploaded a new version of MorphicTests to project The Trunk:
http://source.squeak.org/trunk/MorphicTests-mt.47.mcz
==================== Summary ====================
Name: MorphicTests-mt.47
Author: mt
Time: 31 May 2018, 9:26:39.508323 am
UUID: 8c7b340d-5fcf-6346-8ed0-609d2e1c21f4
Ancestors: MorphicTests-mt.46
Adds a test for the interplay between layouts and border styles.
=============== Diff against MorphicTests-mt.46 ===============
Item was added:
+ ----- Method: BorderedMorphTests>>test04InnerBounds (in category 'tests') -----
+ test04InnerBounds
+ "Check whether a changed border width triggers a layout re-computation."
+
+ | sut |
+ sut := Morph new.
+ sut changeTableLayout.
+ sut addMorph: (Morph new
+ hResizing: #spaceFill;
+ vResizing: #spaceFill;
+ yourself).
+
+ self
+ assert: 0 equals: sut borderWidth;
+ assert: sut fullBounds equals: sut bounds;
+ assert: sut bounds equals: sut innerBounds;
+ assert: sut bounds equals: sut firstSubmorph bounds.
+
+ sut borderStyle: (BorderStyle raised width: 10).
+
+ self
+ assert: 10 equals: sut borderWidth;
+ assert: sut fullBounds equals: sut bounds;
+ assert: (sut bounds insetBy: 10) equals: sut innerBounds;
+ assert: sut innerBounds equals: sut firstSubmorph bounds.!
tim Rowledge uploaded a new version of HelpSystem-Core to project The Trunk:
http://source.squeak.org/trunk/HelpSystem-Core-tpr.104.mcz
==================== Summary ====================
Name: HelpSystem-Core-tpr.104
Author: tpr
Time: 30 May 2018, 4:37:34.320801 pm
UUID: f5c3b7ee-73f1-44c2-b379-af5934ffe16d
Ancestors: HelpSystem-Core-mt.103
Update some help related methods
=============== Diff against HelpSystem-Core-mt.103 ===============
Item was changed:
----- Method: ClassBasedHelpTopic>>updateSubtopics (in category 'updating') -----
updateSubtopics
+ "build a list of subtopics; start with the list of page names specified by the helpClass' #pages method, remembering that it is an ordered list of
+ - selectors that return a HelpTopic,
+ - or the name of a class that must in turn provide help topics etc. This allows for hierarchies with 'subtrees in the middle'.
+ The order of the pages reflects the order of the selectors and class names given.
+ Then all the subclasses that are not #ignore'd and not already included are added.
+ Finally the list of class names and messages is used to assemble the actual help topics.
+
+ Questions:
+ is it actually useful to include the possibility of class names as per the CustomHelpHelpBuilder>createTopicFrom: code?
+ is the #ignore testing worth keeping?"
+
-
| pages |
pages := (self helpClass pages collect: [:pageSelectorOrClassName |
(Smalltalk hasClassNamed: pageSelectorOrClassName asString)
ifTrue: [Smalltalk classNamed: pageSelectorOrClassName asString]
ifFalse: [pageSelectorOrClassName]]) asOrderedCollection.
self helpClass subclasses
select: [:cls | cls ignore not]
thenDo: [:cls | pages addIfNotPresent: cls].
^ subtopics := pages withIndexCollect: [:pageSelectorOrClass :priority |
pageSelectorOrClass isBehavior
ifFalse: [(self helpClass perform: pageSelectorOrClass) priority: priority - pages size; key: pageSelectorOrClass; yourself]
ifTrue: [pageSelectorOrClass asHelpTopic]]!
Item was changed:
----- Method: CustomHelpHelpBuilder>>createTopicFrom: (in category 'private') -----
createTopicFrom: aDescription
+ "Create a help topic from a description provided by a class.
+ aDescription must provide (via #pages) an ordered list of
+ - selectors that return a HelpTopic,
+ - or the name of a class that must in turn provide help topics etc. This allows for hierarchies with 'subtrees in the middle'.
+ The order of the pages reflects the order of the selectors and class names given"
- "Create a topic from a description stored on a class.
- aDescription can specify (via #pages) the name of a class and not
- only a selector. This allows for hierarchies with 'subtrees in the middle'"
|topic page pageClasses |
topic := HelpTopic named: aDescription bookName.
topic key: aDescription key.
topic icon: aDescription icon.
pageClasses := Set new.
aDescription pages do: [:pageSelectorOrClass|
page:= (Smalltalk hasClassNamed: pageSelectorOrClass asString)
ifFalse: [aDescription perform: pageSelectorOrClass]
ifTrue: [pageClasses add: (Smalltalk classNamed: pageSelectorOrClass asString).
(Smalltalk classNamed: pageSelectorOrClass asString) asHelpTopic].
topic addSubtopic: page.
].
((aDescription subclasses asSet)
removeAllFoundIn: pageClasses;
yourself) do: [:subclass | topic subtopics add: subclass asHelpTopic ].
^topic!
Item was changed:
----- Method: HelpHowToHelpTopics class>>overview (in category 'pages') -----
overview
+ "This method was automatically generated. Edit it using:"
+ "HelpHowToHelpTopics edit: #overview"
+ ^HelpTopic
- ^HelpTopic
title: 'Overview'
+ contents:
+ 'THE IMPLEMENTATION
- contents:
- 'THE IMPLEMENTATION
The help system typically consists of help books including one or more pages. A book or page is therefore a "topic of interest" providing contents for help to a user. A topic has a title and an icon and is able to have subtopics forming a hierarchy of topics. This simple model is reflected in the class HelpTopic.
Since this model forms a hierarchical structure of help topics there is a browser with a tree to display the help contents. This browser is implemented in class HelpBrowser.
You can open this browser programmatically using:
HelpBrowser open
+ !!' readStream nextChunkText!
- ' !
Item was changed:
----- Method: HelpHowToHelpTopics class>>page1 (in category 'pages') -----
page1
+ "This method was automatically generated. Edit it using:"
+ "HelpHowToHelpTopics edit: #page1"
^HelpTopic
title: '1. Simple help topics'
contents: 'The help browser usually operates on a hierarchy of help topics with one help topic at the root level. Evaluate the following expression in a workspace to contruct a simple help topic and open it as a root topic in the help browser.
|root|
root := HelpTopic
title: ''My first topic''
contents: ''A simple topic of interest''.
HelpBrowser openOn: root
Note that the help browser displays the contents of our topic in the right page and uses the topics title as the title for the help browser window.
'!
Item was changed:
----- Method: HelpHowToHelpTopics class>>page2 (in category 'pages') -----
page2
+ "This method was automatically generated. Edit it using:"
+ "HelpHowToHelpTopics edit: #page2"
^HelpTopic
title: '2. Forming a hierarchy'
contents: 'To form a hierarchy we just have to add new subtopics on our root topic.
|root sub1 sub2|
root := HelpTopic
title: ''My first topic''
contents: ''A simple topic of interest''.
sub1 := HelpTopic
title: ''My first subtopic''
contents: ''First subsection''.
sub2 := HelpTopic
title: ''My second subtopic''
contents: ''Second subsection''.
root
addSubtopic: sub1;
addSubtopic: sub2.
HelpBrowser openOn: root
'!
Item was changed:
----- Method: HelpHowToHelpTopics class>>page3 (in category 'pages') -----
page3
+ "This method was automatically generated. Edit it using:"
+ "HelpHowToHelpTopics edit: #page3"
^HelpTopic
title: '3. Adding icons'
contents: 'If you dont like the default icon you can add own custom icons to the topics. See the class HelpIcons for more details.
|root sub1 sub2|
root := HelpTopic
title: ''My first topic''
contents: ''A simple topic of interest''.
sub1 := HelpTopic
title: ''My first subtopic''
contents: ''First subsection''.
sub2 := HelpTopic
title: ''My second subtopic''
icon: (HelpIcons iconNamed: #packageIcon)
contents: ''Second subsection''.
root
addSubtopic: sub1;
addSubtopic: sub2.
HelpBrowser openOn: root
'!
Item was changed:
----- Method: HelpHowToHelpTopics class>>page4 (in category 'pages') -----
page4
+ "This method was automatically generated. Edit it using:"
+ "HelpHowToHelpTopics edit: #page4"
^HelpTopic
title: '4. Own help objects'
contents:
'You can open this help browser directly on an instance of HelpTopic, but it is more common to open it on any object that understands the message #asHelpTopic.
So you can write for instance:
HelpBrowser openOn: Integer
opening a short API help/system reference on the Integer class.
The above expression is the short form for:
HelpBrowser openOn: (SystemReference forClass: Integer)
If you want you can include the subclasses:
HelpBrowser openOn: (SystemReference hierarchyFor: Integer)
or even methods
HelpBrowser openOn: (SystemReference hierarchyWithMethodsFor: Integer)
You can browse the whole system reference documentation using:
HelpBrowser openOn: SystemReference
But these are only a few examples what we can extract from the
system.
However - the major goal is NOT an API browser, the idea is to
provide a simple architecture to provide browsable help contents
depending on the context. For instance it should also be possible
to use the help system to provide end user help on any commercial
application that is written with the Smalltalk system.
' !
Item was changed:
----- Method: HelpHowToHelpTopics class>>page5 (in category 'pages') -----
page5
+ "This method was automatically generated. Edit it using:"
+ "HelpHowToHelpTopics edit: #page5"
^HelpTopic
title: '5. Help sources'
contents:
'Since the underlying model is very simple you can easily fill it with nearly any information from different sources. Try this:
|topic day url sub|
topic := HelpTopic named: ''Last week on Squeak IRC''.
0 to: 7 do: [:index |
day := (Date today subtractDays: index) printFormat: #(3 2 1 $. 1 2 2).
url := ''http://tunes.org/~nef/logs/squeak/'' , day.
sub := HelpTopic
title: day contents: (HTTPLoader default retrieveContentsFor: url) contents.
topic addSubtopic: sub.
].
HelpBrowser openOn: topic
' !
Item was changed:
----- Method: HelpHowToHelpTopicsFromCode class>>overview (in category 'pages') -----
overview
+ "This method was automatically generated. Edit it using:"
+ "HelpHowToHelpTopicsFromCode edit: #overview"
^HelpTopic
title: 'Overview'
contents:
'OVERVIEW
The help system allows you to provide own books and help texts. You can open the help browser on any object that is able to understand #asHelpTopic.
This method returns the root node of the displayed topic hierarchy:
HelpBrowser openOn: myObject
Typically the object does not convert itself to a help topic structure, usually it dispatches to a builder (see HelpBuilder and subclasses) who does all this.
A much more convenient and reproducable way is to implement custom help classes. This allows you to implement and manage your help texts using the standard development and code management tools. These custom help classes are subclasses of "CustomHelp" and are automatically included into the standard help browser. '!
Item was changed:
----- Method: HelpHowToHelpTopicsFromCode class>>step1 (in category 'pages') -----
step1
+ "This method was automatically generated. Edit it using:"
+ "HelpHowToHelpTopicsFromCode edit: #step1"
^HelpTopic
title: 'Step 1 - Create a class for the book'
contents:
'STEP 1 - CREATE A CLASS FOR THE BOOK
There is a predefined class CustomHelp which you have to subclass for a custom help book to show up as a book in the Help browser:
CustomHelp subclass: #MyAppHelp
instanceVariableNames: ''''
classVariableNames: ''''
poolDictionaries: ''''
category: ''MyApp-Help''
Class methods on this class can reflect pages and if you want to provide nested help books just subclass your own help class to form a hierarchy. Any new subclass of MyAppHelp will then be a new book in your hierarchy.
The class category used should end with "-Help" so it is easy to recognize that it includes the help support of your project.'
!
Item was changed:
----- Method: HelpHowToHelpTopicsFromCode class>>step2 (in category 'pages') -----
step2
+ "This method was automatically generated. Edit it using:"
+ "HelpHowToHelpTopicsFromCode edit: #step2"
^HelpTopic
title: 'Step 2 - Provide a book name'
contents:
'STEP 2 - PROVIDE A BOOK NAME
Now implement the class method #bookName to return the name of your help book.
bookName
^''My App help''
By implementing this method the system knows how you would like to name your book and uses the given string as a label in the HelpBrowser later.'
!
Item was changed:
----- Method: HelpHowToHelpTopicsFromCode class>>step3 (in category 'pages') -----
step3
+ "This method was automatically generated. Edit it using:"
+ "HelpHowToHelpTopicsFromCode edit: #step3"
^HelpTopic
title: 'Step 3 - Implement pages using methods'
contents:
'STEP 3 - IMPLEMENT PAGES USING METHODS
Implement a page by defining a method that returns an instance of HelpPage defining a page title and a help text displayed in the help browser.
firstPage
^HelpTopic
title: ''First Page''
contents: ''Hello world''
Define a new method for each page of your book. Please group the pages in a method category called "pages".
You can also define an icon for the specific page:
secondPage
^HelpTopic
title: ''Second Page''
icon: (HelpIcons iconNamed: #packageIcon)
contents: ''More to come''
Note:
=====
Later we may add support for better help contents than just plain text (markup descriptions, active morphs, ...) '
!
Item was changed:
----- Method: HelpHowToHelpTopicsFromCode class>>step4 (in category 'pages') -----
step4
+ "This method was automatically generated. Edit it using:"
+ "HelpHowToHelpTopicsFromCode edit: #step4"
^HelpTopic
title: 'Step 4 - Defining the page order'
contents:
'STEP 4 - DEFINING THE PAGE ORDER
By implementing the class method #pages you return a collection of method selectors to define the order in which the pages appear in your book:
pages
^#(firstPage secondPage)
'
!
Item was changed:
----- Method: HelpHowToHelpTopicsFromCode class>>step5 (in category 'pages') -----
step5
+ "This method was automatically generated. Edit it using:"
+ "HelpHowToHelpTopicsFromCode edit: #step5"
^HelpTopic
title: 'Step 5 - Test your help'
contents:
'STEP 5 - TEST YOUR HELP
By using
HelpBrowser open
'
!
Item was changed:
----- Method: HelpHowToHelpTopicsFromCode class>>step6 (in category 'pages') -----
step6
+ "This method was automatically generated. Edit it using:"
+ "HelpHowToHelpTopicsFromCode edit: #step6"
^HelpTopic
title: 'Step 6 - Add more structure'
contents:
'STEP 6 - ADD MORE STRUCTURE
If you add a new subclass to your custom help class and repeating step 2 to 4 you can
profide new substructures (subbooks) since the help books are mapped to the
class hierarchy. Example:
MyAppHelp subclass: #MyAppTutorial
instanceVariableNames: ''''
classVariableNames: ''''
poolDictionaries: ''''
category: ''MyApp-Help''
then implement a #bookName, the pages and a #pages method as before on this new
class and reopen the help browser.
'
!
Item was changed:
----- Method: HelpHowToHelpTopicsFromCode class>>step7 (in category 'pages') -----
step7
+ "This method was automatically generated. Edit it using:"
+ "HelpHowToHelpTopicsFromCode edit: #step7"
^HelpTopic
title: 'Step 7 - Tips and Tricks'
contents:
'STEP 7 - TIPS AND TRICKS
Tip1:
If you implement the #pages method you can also
use the name of a custom help class that should be
integrated between the specific pages:
#pages
^(firstPage MyAppTutorial secondPage)
Tip2:
You can easily edit the help contents of a page by
using the #edit: message. For our example just evaluate:
MyAppHelp edit: #firstPage
This will open a workspace with the help contents and
when you accept it it will be saved back to the help
method defining the topic.
'
!
tim Rowledge uploaded a new version of Help-Squeak-TerseGuide to project The Trunk:
http://source.squeak.org/trunk/Help-Squeak-TerseGuide-tpr.8.mcz
==================== Summary ====================
Name: Help-Squeak-TerseGuide-tpr.8
Author: tpr
Time: 30 May 2018, 4:36:43.105355 pm
UUID: 9754754a-173e-4793-b0c0-1dc047ec9bf6
Ancestors: Help-Squeak-TerseGuide-topa.7
Update some help related methods; plenty more to come in this class.
=============== Diff against Help-Squeak-TerseGuide-topa.7 ===============
Item was changed:
----- Method: TerseGuideHelp class>>arithmetic (in category 'pages') -----
arithmetic
+ "This method was automatically generated. Edit it using:"
+ "TerseGuideHelp edit: #arithmetic"
-
^HelpTopic
title: 'Arithmetic Expressions'
contents:
'"************************************************************************
* Arithmetic expressions: *
************************************************************************"
| x |
x := 6 + 3. "addition"
x := 6 - 3. "subtraction"
x := 6 * 3. "multiplication"
x := 1 + 2 * 3. "evaluation always left to right (1 + 2) * 3"
x := 5 / 3. "division with fractional result"
x := 5.0 / 3.0. "division with float result"
x := 5.0 // 3.0. "integer divide"
x := 5.0 \\ 3.0. "integer remainder"
x := -5. "unary minus"
x := 5 sign. "numeric sign (1, -1 or 0)"
x := 5 negated. "negate receiver"
x := 1.2 integerPart. "integer part of number (1.0)"
x := 1.2 fractionPart. "fractional part of number (0.2)"
x := 5 reciprocal. "reciprocal function"
x := 6 * 3.1. "auto convert to float"
x := 5 squared. "square function"
x := 25 sqrt. "square root"
x := 5 raisedTo: 2. "power function"
x := 5 raisedToInteger: 2. "power function with integer"
x := 5 exp. "exponential"
x := -5 abs. "absolute value"
x := 3.99 rounded. "round"
x := 3.99 truncated. "truncate"
x := 3.99 roundTo: 1. "round to specified decimal places"
x := 3.99 truncateTo: 1. "truncate to specified decimal places"
x := 3.99 floor. "truncate"
x := 3.99 ceiling. "round up"
x := 5 factorial. "factorial"
x := -5 quo: 3. "integer divide rounded toward zero"
x := -5 rem: 3. "integer remainder rounded toward zero"
x := 28 gcd: 12. "greatest common denominator"
x := 28 lcm: 12. "least common multiple"
x := 100 ln. "natural logarithm"
x := 100 log. "base 10 logarithm"
x := 100 log: 10 . "logarithm with specified base"
x := 100 floorLog: 10. "floor of the log"
x := 180 degreesToRadians. "convert degrees to radians"
x := 3.14 radiansToDegrees. "convert radians to degrees"
x := 0.7 sin. "sine"
x := 0.7 cos. "cosine"
x := 0.7 tan. "tangent"
x := 0.7 arcSin. "arcsine"
x := 0.7 arcCos. "arccosine"
x := 0.7 arcTan. "arctangent"
x := 10 max: 20. "get maximum of two numbers"
x := 10 min: 20. "get minimum of two numbers"
x := Float pi. "pi"
x := Float e. "exp constant"
x := Float infinity. "infinity"
x := Float nan. "not-a-number"
x := Random new next; yourself. x next. "random number stream (0.0 to 1.0)"
x := 100 atRandom. "quick random number"
'!
Item was changed:
----- Method: TerseGuideHelp class>>array (in category 'pages') -----
array
+ "This method was automatically generated. Edit it using:"
+ "TerseGuideHelp edit: #array"
-
^HelpTopic
title: 'Array'
contents:
'"************************************************************************
* Array: Fixed length collection *
* ByteArray: Array limited to byte elements (0-255) *
* WordArray: Array limited to word elements (0-2^32) *
************************************************************************"
| b x y sum max |
x := #(4 3 2 1). "constant array"
x := Array with: 5 with: 4 with: 3 with: 2. "create array with up to 4 elements"
x := Array new: 4. "allocate an array with specified size"
x "set array elements"
at: 1 put: 5;
at: 2 put: 4;
at: 3 put: 3;
at: 4 put: 2.
b := x isEmpty. "test if array is empty"
y := x size. "array size"
y := x at: 4. "get array element at index"
b := x includes: 3. "test if element is in array"
y := x copyFrom: 2 to: 4. "subarray"
y := x indexOf: 3 ifAbsent: [0]. "first position of element within array"
y := x occurrencesOf: 3. "number of times object in collection"
x do: [:a | Transcript show: a printString; cr]. "iterate over the array"
b := x allSatisfy: [:a | (a >= 1) & (a <= 4)]. "test if all elements meet condition"
y := x select: [:a | a > 2]. "return collection of elements that pass test"
y := x reject: [:a | a < 2]. "return collection of elements that fail test"
y := x collect: [:a | a + a]. "transform each element for new collection"
y := x detect: [:a | a > 3] ifNone: []. "return first element that passes test"
y := x findFirst: [:a | a < 3]. "find position of first element that passes test"
sum := 0. x do: [:a | sum := sum + a]. sum. "sum array elements"
sum := 0. 1 to: (x size) do: [:a | sum := sum + (x at: a)]. "sum array elements"
sum := x inject: 0 into: [:a :c | a + c]. "sum array elements"
max := x inject: 0 into: [:a :c | (a > c) "find max element in array"
ifTrue: [a]
ifFalse: [c]].
y := x shuffled. "randomly shuffle collection"
y := x asArray. "convert to array"
y := x asByteArray. "convert to byte array"
y := x asWordArray. "convert to word array"
y := x asOrderedCollection. "convert to ordered collection"
y := x asSortedCollection. "convert to sorted collection"
y := x asBag. "convert to bag collection"
y := x asSet. "convert to set collection"
'!
Item was changed:
----- Method: TerseGuideHelp class>>assignment (in category 'pages') -----
assignment
+ "This method was automatically generated. Edit it using:"
+ "TerseGuideHelp edit: #assignment"
-
^HelpTopic
title: 'Assignment'
contents:
'"************************************************************************
* Assignment: *
************************************************************************"
| x y z |
x _ 4. "assignment (Squeak) <-"
x := 5. "assignment"
x := y := z := 6. "compound assignment"
x := (y := 6) + 1.
x := Object new. "bind to allocated instance of a class"
x := 123 class. "discover the object class"
x := Integer superclass. "discover the superclass of a class"
x := Object allInstances. "get an array of all instances of a class"
x := Integer allSuperclasses. "get all superclasses of a class"
x := 1.2 hash. "hash value for object"
y := x copy. "copy object"
y := x shallowCopy. "copy object (not overridden)"
y := x deepCopy. "copy object and instance vars"
y := x veryDeepCopy. "complete tree copy using a dictionary"
'!
Item was changed:
----- Method: TerseGuideHelp class>>association (in category 'pages') -----
association
+ "This method was automatically generated. Edit it using:"
+ "TerseGuideHelp edit: #association"
-
^HelpTopic
title: 'Association'
contents:
'"************************************************************************
* Associations: *
************************************************************************"
| x y |
x := #myVar->''hello''.
y := x key.
y := x value.
'!
Item was changed:
----- Method: TerseGuideHelp class>>bag (in category 'pages') -----
bag
+ "This method was automatically generated. Edit it using:"
+ "TerseGuideHelp edit: #bag"
-
^HelpTopic
title: 'Bag'
contents:
'"************************************************************************
* Bag: like OrderedCollection except elements are in no *
* particular order *
************************************************************************"
| b x y sum max |
x := Bag with: 4 with: 3 with: 2 with: 1. "create collection with up to 4 elements"
x := Bag new. "allocate collection"
x add: 4; add: 3; add: 1; add: 2; yourself. "add element to collection"
x add: 3 withOccurrences: 2. "add multiple copies to collection"
y := x addAll: #(7 8 9). "add multiple elements to collection"
y := x removeAll: #(7 8 9). "remove multiple elements from collection"
y := x remove: 4 ifAbsent: []. "remove element from collection"
b := x isEmpty. "test if empty"
y := x size. "number of elements"
b := x includes: 3. "test if element is in collection"
y := x occurrencesOf: 3. "number of times object in collection"
x do: [:a | Transcript show: a printString; cr]. "iterate over the collection"
b := x allSatisfy: [:a | (a >= 1) & (a <= 4)]. "test if all elements meet condition"
y := x select: [:a | a > 2]. "return collection of elements that pass test"
y := x reject: [:a | a < 2]. "return collection of elements that fail test"
y := x collect: [:a | a + a]. "transform each element for new collection"
y := x detect: [:a | a > 3] ifNone: []. "return first element that passes test"
sum := 0. x do: [:a | sum := sum + a]. sum. "sum elements"
sum := x inject: 0 into: [:a :c | a + c]. "sum elements"
max := x inject: 0 into: [:a :c | (a > c) "find max element in collection"
ifTrue: [a]
ifFalse: [c]].
y := x asOrderedCollection. "convert to ordered collection"
y := x asSortedCollection. "convert to sorted collection"
y := x asBag. "convert to bag collection"
y := x asSet. "convert to set collection"
'!
Item was changed:
----- Method: TerseGuideHelp class>>bitwise (in category 'pages') -----
bitwise
+ "This method was automatically generated. Edit it using:"
+ "TerseGuideHelp edit: #bitwise"
-
^HelpTopic
title: 'Bitwise Manipulation'
contents:
'"************************************************************************
* Bitwise Manipulation: *
************************************************************************"
| b x |
x := 16rFF bitAnd: 16r0F. "and bits"
x := 16rF0 bitOr: 16r0F. "or bits"
x := 16rFF bitXor: 16r0F. "xor bits"
x := 16rFF bitInvert. "invert bits"
x := 16r0F bitShift: 4. "left shift"
x := 16rF0 bitShift: -4. "right shift"
x := 16r80 bitAt: 8. "bit at position (0|1)"
x := 16r80 highBit. "position of highest bit set"
b := 16rFF allMask: 16r0F. "test if all bits set in mask set in receiver"
b := 16rFF anyMask: 16r0F. "test if any bits set in mask set in receiver"
b := 16rFF noMask: 16r0F. "test if all bits set in mask clear in receiver"
'!
Item was changed:
----- Method: TerseGuideHelp class>>block (in category 'pages') -----
block
+ "This method was automatically generated. Edit it using:"
+ "TerseGuideHelp edit: #block"
-
^HelpTopic
title: 'Blocks'
contents:
'"************************************************************************
* Blocks: *
* - blocks are objects and may be assigned to a variable *
* - value is last expression evaluated unless explicit return *
* - blocks may be nested *
* - specification [ arguments | | localvars | expressions ] *
* - ^expression terminates block & method (exits all nested blocks) *
* - blocks intended for long term storage should not contain ^ *
************************************************************************"
| x y z fac |
x := [ y := 1. z := 2. ]. x value. "simple block usage"
x := [ :argOne :argTwo | argOne, '' and '' , argTwo.]. "set up block with argument passing"
Transcript show: (x value: ''First'' value: ''Second''); cr. "use block with argument passing"
x := [:e | | v | v := 1. e + v] value: 2. "localvar in a block"
fac := [ :n | n > 1 ifTrue: [n * (fac value: n-1)] ifFalse: [1]]. "closure on block variable"
fac value: 5. "closure variable scoped to its block"
'!
Item was changed:
----- Method: TerseGuideHelp class>>boolean (in category 'pages') -----
boolean
+ "This method was automatically generated. Edit it using:"
+ "TerseGuideHelp edit: #boolean"
-
^HelpTopic
title: 'Boolean'
contents:
'"************************************************************************
* Booleans: *
************************************************************************"
| b x y |
x := 1. y := 2.
b := (x = y). "equals"
b := (x ~= y). "not equals"
b := (x == y). "identical"
b := (x ~~ y). "not identical"
b := (x > y). "greater than"
b := (x < y). "less than"
b := (x >= y). "greater than or equal"
b := (x <= y). "less than or equal"
b := b not. "boolean not"
b := (x < 5) & (y > 1). "boolean and"
b := (x < 5) | (y > 1). "boolean or"
b := (x < 5) and: [y > 1]. "boolean and (short-circuit)"
b := (x < 5) or: [y > 1]. "boolean or (short-circuit)"
b := (x < 5) eqv: (y > 1). "test if both true or both false"
b := (x < 5) xor: (y > 1). "test if one true and other false"
b := 5 between: 3 and: 12. "between (inclusive)"
b := 123 isKindOf: Number. "test if object is class or subclass of"
b := 123 isMemberOf: SmallInteger. "test if object is type of class"
b := 123 respondsTo: #sqrt. "test if object responds to message"
b := x isNil. "test if object is nil"
b := x isZero. "test if number is zero"
b := x positive. "test if number is positive"
b := x strictlyPositive. "test if number is greater than zero"
b := x negative. "test if number is negative"
b := x even. "test if number is even"
b := x odd. "test if number is odd"
b := x isLiteral. "test if literal constant"
b := x isInteger. "test if object is integer"
b := x isFloat. "test if object is float"
b := x isNumber. "test if object is number"
b := $A isUppercase. "test if upper case character"
b := $A isLowercase. "test if lower case character"
'!
Item was changed:
----- Method: TerseGuideHelp class>>character (in category 'pages') -----
character
+ "This method was automatically generated. Edit it using:"
+ "TerseGuideHelp edit: #character"
-
^HelpTopic
title: 'Character'
contents:
'"************************************************************************
* Character: *
************************************************************************"
| x y b |
x := $A. "character assignment"
y := x isLowercase. "test if lower case"
y := x isUppercase. "test if upper case"
y := x isLetter. "test if letter"
y := x isDigit. "test if digit"
y := x isAlphaNumeric. "test if alphanumeric"
y := x isSeparator. "test if seperator char"
y := x isVowel. "test if vowel"
y := x digitValue. "convert to numeric digit value"
y := x asLowercase. "convert to lower case"
y := x asUppercase. "convert to upper case"
y := x asciiValue. "convert to numeric ascii value"
y := x asString. "convert to string"
b := $A <= $B. "comparison"
y := $A max: $B.
'!
Item was changed:
----- Method: TerseGuideHelp class>>conditionalStatement (in category 'pages') -----
conditionalStatement
+ "This method was automatically generated. Edit it using:"
+ "TerseGuideHelp edit: #conditionalStatement"
-
^HelpTopic
title: 'Conditional Statement'
contents:
'"************************************************************************
* Conditional Statements: *
************************************************************************"
| x switch result |
x := 11.
x > 10 ifTrue: [Transcript show: ''ifTrue''; cr]. "if then"
x > 10 ifFalse: [Transcript show: ''ifFalse''; cr]. "if else"
x > 10 "if then else"
ifTrue: [Transcript show: ''ifTrue''; cr]
ifFalse: [Transcript show: ''ifFalse''; cr].
x > 10 "if else then"
ifFalse: [Transcript show: ''ifFalse''; cr]
ifTrue: [Transcript show: ''ifTrue''; cr].
Transcript
show:
(x > 10
ifTrue: [''ifTrue'']
ifFalse: [''ifFalse'']);
cr.
Transcript "nested if then else"
show:
(x > 10
ifTrue: [x > 5
ifTrue: [''A'']
ifFalse: [''B'']]
ifFalse: [''C'']);
cr.
switch := Dictionary new. "switch functionality"
switch at: $A put: [Transcript show: ''Case A''; cr].
switch at: $B put: [Transcript show: ''Case B''; cr].
switch at: $C put: [Transcript show: ''Case C''; cr].
result := (switch at: $B) value.
'!
Item was changed:
----- Method: TerseGuideHelp class>>constants (in category 'pages') -----
constants
+ "This method was automatically generated. Edit it using:"
+ "TerseGuideHelp edit: #constants"
-
^HelpTopic
title: 'Constants'
contents:
'"************************************************************************
* Constants: *
************************************************************************"
| b x |
b := true. "true constant"
b := false. "false constant"
x := nil. "nil object constant"
x := 1. "integer constants"
x := 3.14. "float constants"
x := 2e-2. "fractional constants"
x := 16r0F. "hex constant".
x := -1. "negative constants"
x := ''Hello''. "string constant"
x := ''I''''m here''. "single quote escape"
x := $A. "character constant"
x := $ . "character constant (space)"
x := #aSymbol. "symbol constants"
x := #(3 2 1). "array constants"
x := #(''abc'' 2 $a). "mixing of types allowed"
'!
Item was changed:
----- Method: TerseGuideHelp class>>conversion (in category 'pages') -----
conversion
+ "This method was automatically generated. Edit it using:"
+ "TerseGuideHelp edit: #conversion"
-
^HelpTopic
title: 'Conversion'
contents:
'"************************************************************************
* Conversion: *
************************************************************************"
| x |
x := 3.99 asInteger. "convert number to integer (truncates in Squeak)"
x := 3.99 asFraction. "convert number to fraction"
x := 3 asFloat. "convert number to float"
x := 65 asCharacter. "convert integer to character"
x := $A asciiValue. "convert character to integer"
x := 3.99 printString. "convert object to string via printOn:"
x := 3.99 storeString. "convert object to string via storeOn:"
x := 15 radix: 16. "convert to string in given base"
x := 15 printStringBase: 16.
x := 15 storeStringBase: 16.
'!
Item was changed:
----- Method: TerseGuideHelp class>>date (in category 'pages') -----
date
+ "This method was automatically generated. Edit it using:"
+ "TerseGuideHelp edit: #date"
-
^HelpTopic
title: 'Date'
contents:
'"************************************************************************
* Date: *
************************************************************************"
| x y b |
x := Date today. "create date for today"
x := Date dateAndTimeNow. "create date from current time/date"
x := Date readFromString: ''01/02/1999''. "create date from formatted string"
x := Date newDay: 12 month: #July year: 1999. "create date from parts"
x := Date fromDays: 36000. "create date from elapsed days since 1/1/1901"
y := Date dayOfWeek: #Monday. "day of week as int (1-7)"
y := Date indexOfMonth: #January. "month of year as int (1-12)"
y := Date daysInMonth: 2 forYear: 1996. "day of month as int (1-31)"
y := Date daysInYear: 1996. "days in year (365|366)"
y := Date nameOfDay: 1. "weekday name (#Monday,...)"
y := Date nameOfMonth: 1. "month name (#January,...)"
y := Date leapYear: 1996. "1 if leap year; 0 if not leap year"
y := x weekday. "day of week (#Monday,...)"
y := x previous: #Monday. "date for previous day of week"
y := x dayOfMonth. "day of month (1-31)"
y := x day. "day of year (1-366)"
y := x firstDayOfMonth. "day of year for first day of month"
y := x monthName. "month of year (#January,...)"
y := x monthIndex. "month of year (1-12)"
y := x daysInMonth. "days in month (1-31)"
y := x year. "year (19xx)"
y := x daysInYear. "days in year (365|366)"
y := x daysLeftInYear. "days left in year (364|365)"
y := x asSeconds. "seconds elapsed since 1/1/1901"
y := x addDays: 10. "add days to date object"
y := x subtractDays: 10. "subtract days to date object"
y := x subtractDate: (Date today). "subtract date (result in days)"
y := x printFormat: #(2 1 3 $/ 1 1). "print formatted date"
b := (x <= Date today). "comparison"
'!
Item was changed:
----- Method: TerseGuideHelp class>>debugging (in category 'pages') -----
debugging
+ "This method was automatically generated. Edit it using:"
+ "TerseGuideHelp edit: #debugging"
-
^HelpTopic
title: 'Debugging'
contents:
'"************************************************************************
* debugging: *
************************************************************************"
| a b x |
x := Object new.
x yourself. "returns receiver"
String browse. "browse specified class"
x inspect. "open object inspector window"
x confirm: ''Is this correct?''.
x halt. "breakpoint to open debugger window"
x halt: ''Halt message''.
x notify: ''Notify text''.
x error: ''Error string''. "open up error window with title"
x shouldNotImplement. "flag message should not be implemented"
x subclassResponsibility. "flag message as abstract"
x errorImproperStore. "flag an improper store into indexable object"
x errorNonIntegerIndex. "flag only integers should be used as index"
x errorSubscriptBounds: 13. "flag subscript out of bounds"
x primitiveFailed. "system primitive failed"
a := ''A1''. b := ''B2''. a become: b. "switch two objects"
Transcript show: a, b; cr.
x doesNotUnderstand: (Message selector: #foo). "flag message is not handled"
'!
Item was changed:
----- Method: TerseGuideHelp class>>dictionary (in category 'pages') -----
dictionary
+ "This method was automatically generated. Edit it using:"
+ "TerseGuideHelp edit: #dictionary"
-
^HelpTopic
title: 'Dictionary'
contents:
'"************************************************************************
* Dictionary: *
* IdentityDictionary: uses identity test (== rather than =) *
************************************************************************"
| b x y sum max |
x := Dictionary new. "allocate collection"
x add: #a->4; add: #b->3; add: #c->1; add: #d->2; yourself. "add element to collection"
x at: #e put: 3. "set element at index"
b := x isEmpty. "test if empty"
y := x size. "number of elements"
y := x at: #a ifAbsent: []. "retrieve element at index"
y := x keyAtValue: 3 ifAbsent: []. "retrieve key for given value with error block"
y := x removeKey: #e ifAbsent: []. "remove element from collection"
b := x includes: 3. "test if element is in values collection"
b := x includesKey: #a. "test if element is in keys collection"
y := x occurrencesOf: 3. "number of times object in collection"
y := x keys. "set of keys"
y := x values. "bag of values"
x do: [:a | Transcript show: a printString; cr]. "iterate over the values collection"
x keysDo: [:a | Transcript show: a printString; cr]. "iterate over the keys collection"
x associationsDo: [:a | Transcript show: a printString; cr]. "iterate over the associations"
x keysAndValuesDo: [:aKey :aValue | Transcript "iterate over keys and values"
show: aKey printString; space;
show: aValue printString; cr].
b := x allSatisfy: [:a | (a >= 1) & (a <= 4)]. "test if all elements meet condition"
y := x select: [:a | a > 2]. "return collection of elements that pass test"
y := x reject: [:a | a < 2]. "return collection of elements that fail test"
y := x collect: [:a | a + a]. "transform each element for new collection"
y := x detect: [:a | a > 3] ifNone: []. "return first element that passes test"
sum := 0. x do: [:a | sum := sum + a]. sum. "sum elements"
sum := x inject: 0 into: [:a :c | a + c]. "sum elements"
max := x inject: 0 into: [:a :c | (a > c) "find max element in collection"
ifTrue: [a]
ifFalse: [c]].
y := x asArray. "convert to array"
y := x asOrderedCollection. "convert to ordered collection"
y := x asSortedCollection. "convert to sorted collection"
y := x asBag. "convert to bag collection"
y := x asSet. "convert to set collection"
Smalltalk at: #CMRGlobal put: ''CMR entry''. "put global in Smalltalk Dictionary"
x := Smalltalk at: #CMRGlobal. "read global from Smalltalk Dictionary"
Transcript show: (CMRGlobal printString). "entries are directly accessible by name"
Smalltalk keys do: [ :k | "print out all classes"
((Smalltalk at: k) isKindOf: Class)
ifFalse: [Transcript show: k printString; cr]].
Smalltalk at: #CMRDictionary put: (Dictionary new). "set up user defined dictionary"
CMRDictionary at: #MyVar1 put: ''hello1''. "put entry in dictionary"
CMRDictionary add: #MyVar2->''hello2''. "add entry to dictionary use key->value combo"
CMRDictionary size. "dictionary size"
CMRDictionary keys do: [ :k | "print out keys in dictionary"
Transcript show: k printString; cr].
CMRDictionary values do: [ :k | "print out values in dictionary"
Transcript show: k printString; cr].
CMRDictionary keysAndValuesDo: [:aKey :aValue | "print out keys and values"
Transcript
show: aKey printString;
space;
show: aValue printString;
cr].
CMRDictionary associationsDo: [:aKeyValue | "another iterator for printing key values"
Transcript show: aKeyValue printString; cr].
Smalltalk removeKey: #CMRGlobal ifAbsent: []. "remove entry from Smalltalk dictionary"
Smalltalk removeKey: #CMRDictionary ifAbsent: []. "remove user dictionary from Smalltalk dictionary"
'!
Item was changed:
----- Method: TerseGuideHelp class>>dynamic (in category 'pages') -----
dynamic
+ "This method was automatically generated. Edit it using:"
+ "TerseGuideHelp edit: #dynamic"
-
^HelpTopic
title: 'Dynamic Message Calling/Compiling'
contents:
'"************************************************************************
* Dynamic Message Calling/Compiling: *
************************************************************************"
| receiver message result argument keyword1 keyword2 argument1 argument2 |
"unary message"
receiver := 5.
message := ''factorial'' asSymbol.
result := receiver perform: message.
result := Compiler evaluate: ((receiver storeString), '' '', message).
result := (Message new setSelector: message arguments: #()) sentTo: receiver.
"binary message"
receiver := 1.
message := ''+'' asSymbol.
argument := 2.
result := receiver perform: message withArguments: (Array with: argument).
result := Compiler evaluate: ((receiver storeString), '' '', message, '' '', (argument storeString)).
result := (Message new setSelector: message arguments: (Array with: argument)) sentTo: receiver.
"keyword messages"
receiver := 12.
keyword1 := ''between:'' asSymbol.
keyword2 := ''and:'' asSymbol.
argument1 := 10.
argument2 := 20.
result := receiver
perform: (keyword1, keyword2) asSymbol
withArguments: (Array with: argument1 with: argument2).
result := Compiler evaluate:
((receiver storeString), '' '', keyword1, (argument1 storeString) , '' '', keyword2, (argument2 storeString)).
result := (Message
new
setSelector: (keyword1, keyword2) asSymbol
arguments: (Array with: argument1 with: argument2))
sentTo: receiver.
'!
Item was changed:
----- Method: TerseGuideHelp class>>exceptionHandling (in category 'pages') -----
exceptionHandling
+ "This method was automatically generated. Edit it using:"
+ "TerseGuideHelp edit: #exceptionHandling"
-
^HelpTopic
title: 'Exception Handling'
contents:
'"************************************************************************
* Exceptions: *
************************************************************************"
| x |
x := Object new.
x error: ''Throwing an error''.
NotFound signal. "simply throwing a specific exception"
NotFound signal: ''Throwing with a message''. "throwing an exception with a custom text"
x := [ 5 / 0 ] "simple exception handler"
on: ZeroDivide do: [ 10 ].
x := [ 5 / 0 ] "processing the exception in an exception handler"
on: Error do: [:e | Transcript showln: e printString ].
x := [ 5 / 0 ] "different exception handlers for the same block"
on: ZeroDivide do: [ 10 ]
on: MessageNotUnderstood do: [ 20 ].
x := [ 5 / 0 ] "one exception handler for two different exceptions"
on: ZeroDivide , ArithmeticError do: [ 10 ].
'!
Item was changed:
----- Method: TerseGuideHelp class>>fileStream (in category 'pages') -----
fileStream
+ "This method was automatically generated. Edit it using:"
+ "TerseGuideHelp edit: #fileStream"
-
^HelpTopic
title: 'File Stream'
contents:
'"************************************************************************
* FileStream: *
************************************************************************"
| b x ios |
ios := FileStream newFileNamed: ''ios.txt''.
ios nextPut: $H; cr.
ios nextPutAll: ''Hello File''; cr.
''Hello File'' printOn: ios.
''Hello File'' storeOn: ios.
ios close.
ios := FileStream oldFileNamed: ''ios.txt''.
[(x := ios nextLine) notNil]
whileTrue: [Transcript show: x; cr].
ios position: 3.
x := ios position.
x := ios next.
x := ios peek.
b := ios atEnd.
ios close.
'!
Item was changed:
----- Method: TerseGuideHelp class>>internalStream (in category 'pages') -----
internalStream
+ "This method was automatically generated. Edit it using:"
+ "TerseGuideHelp edit: #internalStream"
-
^HelpTopic
title: 'Internal Stream'
contents:
'"************************************************************************
* Internal Stream: *
************************************************************************"
| b x ios |
ios := ReadStream on: ''Hello read stream''.
ios := ReadStream on: ''Hello read stream'' from: 1 to: 5.
[(x := ios nextLine) notNil]
whileTrue: [Transcript show: x; cr].
ios position: 3.
ios position.
x := ios next.
x := ios peek.
x := ios contents.
b := ios atEnd.
ios := ReadWriteStream on: ''Hello read stream''.
ios := ReadWriteStream on: ''Hello read stream'' from: 1 to: 5.
ios := ReadWriteStream with: ''Hello read stream''.
ios := ReadWriteStream with: ''Hello read stream'' from: 1 to: 10.
ios position: 0.
[(x := ios nextLine) notNil]
whileTrue: [Transcript show: x; cr].
ios position: 6.
ios position.
ios nextPutAll: ''Chris''.
x := ios next.
x := ios peek.
x := ios contents.
b := ios atEnd.
'!
Item was changed:
----- Method: TerseGuideHelp class>>interval (in category 'pages') -----
interval
+ "This method was automatically generated. Edit it using:"
+ "TerseGuideHelp edit: #interval"
-
^HelpTopic
title: 'Interval'
contents:
'"************************************************************************
* Interval: *
************************************************************************"
| b x y sum max |
x := Interval from: 5 to: 10. "create interval object"
x := 5 to: 10.
x := Interval from: 5 to: 10 by: 2. "create interval object with specified increment"
x := 5 to: 10 by: 2.
b := x isEmpty. "test if empty"
y := x size. "number of elements"
x includes: 9. "test if element is in collection"
x do: [:k | Transcript show: k printString; cr]. "iterate over interval"
b := x allSatisfy: [:a | (a >= 1) & (a <= 4)]. "test if all elements meet condition"
y := x select: [:a | a > 7]. "return collection of elements that pass test"
y := x reject: [:a | a < 2]. "return collection of elements that fail test"
y := x collect: [:a | a + a]. "transform each element for new collection"
y := x detect: [:a | a > 3] ifNone: []. "return first element that passes test"
y := x findFirst: [:a | a > 6]. "find position of first element that passes test"
sum := 0. x do: [:a | sum := sum + a]. sum. "sum elements"
sum := 0. 1 to: (x size) do: [:a | sum := sum + (x at: a)]. "sum elements"
sum := x inject: 0 into: [:a :c | a + c]. "sum elements"
max := x inject: 0 into: [:a :c | (a > c) "find max element in collection"
ifTrue: [a]
ifFalse: [c]].
y := x asArray. "convert to array"
y := x asOrderedCollection. "convert to ordered collection"
y := x asSortedCollection. "convert to sorted collection"
y := x asBag. "convert to bag collection"
y := x asSet. "convert to set collection"
'!
Item was changed:
----- Method: TerseGuideHelp class>>introduction (in category 'pages') -----
introduction
+ "This method was automatically generated. Edit it using:"
+ "TerseGuideHelp edit: #introduction"
-
^HelpTopic
title: 'General'
contents:
'"************************************************************************
* Allowable characters: *
* - a-z *
* - A-Z *
* - 0-9 *
* - .+/\*~<>@%|&? *
* - blank, tab, cr, ff, lf *
* *
* Variables: *
* - variables must be declared before use *
* - shared vars must begin with uppercase *
* - local vars must begin with lowercase *
* - reserved names: nil, true, false, self, super, and Smalltalk *
* *
* Variable scope: *
* - Global: defined in Dictionary Smalltalk and accessible by all *
* objects in system *
* - Special: (reserved) Smalltalk, super, self, true, false, & nil *
* - Method Temporary: local to a method *
* - Block Temporary: local to a block *
* - Pool: variables in a Dictionary object *
* - Method Parameters: automatic local vars created as a result of *
* message call with params *
* - Block Parameters: automatic local vars created as a result of *
* value: message call *
* - Class: shared with all instances of one class & its subclasses *
* - Class Instance: unique to each instance of a class *
* - Instance Variables: unique to each instance *
************************************************************************"
"Comments are enclosed in quotes"
"Period (.) is the statement seperator"
'!