View this PageEdit this PageAttachments to this PageHistory of this PageHomeRecent ChangesSearch the SwikiHelp Guide
Hotspots: Admin Pages | Turn-in Site |
Current Links: Case Final Project Summer 2007

BwL M7

The writeup for this milestone is here: Fall 2003 M7: Expand your Guide's functionality


Our Final UML


Uploaded Image: SqueakGuideUML.gif



Three things were required for this milestone, so it wasn't too bad. We were given a list of 5 tasks to create for our Guide (to show that our engine was flexible enough to be changed quickly to use other tasks). During a demonstration, we had to account for the fact that the user may not have performed the task, or did something crazy. Basically it meant we had to check for dependencies from previous steps in the task.

Parsing Free Form

We had to update our search feature with the ability to parse free-form text. Joe created a parser to do just that. He kept his already-written search parser to tokenate the search string by spaces:
           aString findTokens: ' '.
Then he wrote some methods to find all the punctuation in the tokens, then lowercase all, and finally omit frequently used words.

                   doParse: aCollection
                      "Parses the free-form text"

                      | parsed cur temp curChar |

                      parsed := OrderedCollection new.

                      1 to: (aCollection size) do: [:index |
                         cur := (aCollection at: index) asString.
                         temp := String new.
                         1 to: (cur size) do: [:pos |
                            curChar := (cur at: pos) asCharacter.
                            (self checkChar: curChar)  "Dropping out the punctuation"
                               ifTrue: [temp := temp copyWith: curChar asLowercase].
                         ].
                         (temp) ifNotNil: [
                            (temp isEmpty) ifFalse: [
                               (omitList includes: temp)
                                  ifFalse: [parsed add: temp].
                            ].
                         ].
                      ].
                      ^parsed.

                   checkChar: aChar
                      "Figures out whether a character should be in the list or not, and returns true/false"

                      | val |

                      val := aChar asCharacter asciiValue.

                      ((val>=33) and: [val<=47]) ifFalse: [
                         ((val>=58) and: [val<=64]) ifFalse: [
                            ((val>=91) and: [val<=96]) ifFalse: [
                               ((val>=123) and: [val<=126]) ifFalse: [
                                  ^true.
                               ].
                            ].
                         ].
                      ].
                      ^false.


Demonstration Engine

The way we set up our tasks involved putting a lot of code into the XML task files. The files actually made function calls to move the avatar around, open windows, and manipulate squeak in different ways. Some of these tasks were repetetive, so, rather than recoding them in each XML file, each repetetive task was put into the demonstration engine (basically used as a function library). Here are some of the ingenious functions found inside it:
blueClick
	"blue click the cursor"
	| mouseDownEvent mouseUpEvent |
	mouseDownEvent := MouseButtonEvent new
		setType: #mouseDown
		position: playHand position
		which: 0
		buttons: 0
		hand: playHand
		stamp: Time millisecondClockValue.
	mouseDownEvent toggleBlueButton.

	mouseUpEvent := MouseButtonEvent new
		setType: #mouseUp
		position: playHand position
		which: 0
		buttons: 0
		hand: playHand
		stamp: Time millisecondClockValue.
	mouseUpEvent toggleBlueButton.


	"click the button"
	playHand handleEvent: mouseDownEvent resetHandlerFields.
	DemoEngineLib wait: 50.
	playHand handleEvent: mouseUpEvent resetHandlerFields.


type: text buttons: buttons
	| typeKeyEvent |
	text do: [:char |
		DemoEngineLib wait: 100.
		typeKeyEvent := KeyboardEvent new
			setType: #keystroke
			buttons: buttons
			position: playHand position
			keyValue: char asciiValue
			hand: playHand
			stamp: Time millisecondClockValue.

			playHand handleEvent: typeKeyEvent.
	].

initialize: startPosition
	"init our cursor"
	playHand := HandMorph new.
	playHand position: startPosition.
	World addHand: playHand.
	playHand newKeyboardFocus: World.
	playHand userInitials: 'Demo' andPicture: nil.


To understand some of this, you really need to look at the XML syntax, some of which is right here -> Task 2

After a few tweaks to the step-viewing bubble's "showme" and "next" button code, Wes and Luigi worked on adding the "check" code (this code checked to see if the user had done what the step said, and if not it ran code to do it for the user).

Links to this Page