Today's Smalltalk 4 You looks at "scratch" editions in VA Smalltalk. If you just grab an application and start coding, it's what you get - and today we'll look at what that means. If you have trouble viewing it here in the browser, you can also navigate directly to YouTube. To watch now, click on the image below:
If you have trouble viewing that directly, you can click here to download the video directly. If you need the video in a Windows Media format, then download that here.
You can also watch it on YouTube:
Today we'll look at what a "scratch" edition in VA Smalltalk means. Recall that ENVY tracks every change you make in VA; that means that a version of your code always lands in the repository. So if you don't create a new edition, one gets created for you. Make a small change in some application:
You'll get prompted about creating a scratch edition. That's simply a new edition you haven't named. Go ahead and do so; you'll see this:
Now all you need to do is tell ENVY to make that a new edition:
And you'll have a new "clean" edition to work with.
Need more help? There's a screencast for other topics like this which you may want to watch. Questions? Try the "Chat with James" Google gadget over in the sidebar.
Today's Smalltalk 4 You looks at using XML in Pharo Smalltalk. If you have trouble viewing it here in the browser, you can also navigate directly to YouTube. To watch now, click on the image below:
If you have trouble viewing that directly, you can click here to download the video directly. If you need the video in a Windows Media format, then download that here.
Today's Smalltalk 4 You looks at using our simple case statement class from last time. If you have trouble viewing it here in the browser, you can also navigate directly to YouTube. To watch now, click on the image below:
If you have trouble viewing that directly, you can click here to download the video directly. If you need the video in a Windows Media format, then download that here.
You can also watch it on YouTube:
Today we'll make use of the case statement code we built last time. Here's the workspace we'll use:
dict := Dictionary new.
dict at: 1 put: [Transcript show: 'This is One'].
dict at: 2 put: [Transcript show: 'This is Two'].
case := CaseStatement new.
case addAll: dict.
case caseAt: 1.
case caseAt: 2.
case caseAt: 3.
case removeCase: 2.
case caseAt: 2.
That creates a simple case statement with two cases (and at the end, removes one of them). Try the first three lines after defining the dictionary and adding it to the CaseStatement - you should see this in the Transcript:
Now execute the removal, and try the last line:
After removing the second case, we get the default case when trying it (as expected). That's it - we now have a working Case Statement object in Smalltalk. Next time you run into someone asking about one, you'll have it
Need more help? There's a screencast for other topics like this which you may want to watch. Questions? Try the "Chat with James" Google gadget over in the sidebar.
Today's Smalltalk 4 You looks at implementing a case statement construct in VA Smalltalk. If you would like to download the code, links are below, in the walkthrough section. If you have trouble viewing it here in the browser, you can also navigate directly to YouTube. To watch now, click on the image below:
If you have trouble viewing that directly, you can click here to download the video directly. If you need the video in a Windows Media format, then download that here.
You can also watch it on YouTube:
Today we'll build a simple case statement class in VA Smalltalk. Why? People are often surprised that Smalltalk does not have one, so building one is a good way of showing how Smalltalk works to a new user, while implementing a concept that's familiar to them. To get started, define a new class:
The cases will be stored in a dictionary, and the default case will be held in the defaultCase variable. In this example, we'll default that to a simple Transcript write. Next, let's add the instance creation code:
Here we allow for the definition of a default case, and for the inbound cases to be either a dictionary or a collection of associations. We'll see how that gets handled in the instance code:
Note the conversion of string keys to symbols - that ensures that we have unique keys. For the values, we simply assume any object that responds to #value. It'll probably be a block, but that's not all that could be done there. Now let's look at the execution:
caseAt: keyName
"execute the corresponding value"
| key val |
key := keyName isString
ifTrue: [keyName asSymbol]
ifFalse: [keyName].
val := self cases at: key ifAbsent: self defaultCase.
^val value
Again, we convert the key if necessary, then do a lookup. If that fails, we simply use the default case. Finally, we send #value to the looked up case. That's it - we now have a case statement in Smalltalk.
Need more help? There's a screencast for other topics like this which you may want to watch. Questions? Try the "Chat with James" Google gadget over in the sidebar.
Today's Smalltalk 4 You looks at using HTTP in Pharo Smalltalk. If you have trouble viewing it here in the browser, you can also navigate directly to YouTube. To watch now, click on the image below:
If you have trouble viewing that directly, you can click here to download the video directly. If you need the video in a Windows Media format, then download that here.
Today's Smalltalk 4 You looks at raising exceptions in VA Smalltalk. If you have trouble viewing it here in the browser, you can also navigate directly to YouTube. To watch now, click on the image below:
If you have trouble viewing that directly, you can click here to download the video directly. If you need the video in a Windows Media format, then download that here.
You can also watch it on YouTube:
Today we'll take a look at raising exceptions (either your own or existing ones already defined) in VA Smalltalk. We'll use a somewhat artificial example to demonstrate:
This code raises the MessageNotUnderstood exception when it sees that we are trying to add a string to a number. The larger point is that this is how you raise an exception in VA (or most other Smalltalks) - see class Exception for the full range of API options.
Need more help? There's a screencast for other topics like this which you may want to watch. Questions? Try the "Chat with James" Google gadget over in the sidebar.
Today's Smalltalk 4 You looks at implementing a very simple HTTP server in VA Smalltalk. If you do this yourself, you would actually want to create some objects, not just use the code snippet below. If you have trouble viewing it here in the browser, you can also navigate directly to YouTube. To watch now, click on the image below:
If you have trouble viewing that directly, you can click here to download the video directly. If you need the video in a Windows Media format, then download that here.
You can also watch it on YouTube:
Today we'll take a look at setting up a simple HTTP server in VA Smalltalk. Bear in mind that for any "real" task you would want to create some classes of your own; this example will be enough to get you started. The code you'll want to use is below:
| server handler result |
handler := DirectedMessage
receiver:
[:request :response| |htmlStream htmlResponse|
htmlStream := WriteStream
on: (Locale current preferredStringClass new: 128).
htmlStream nextPutAll: '
This code does a couple of things. First, it uses DirectedMessage to set up a response handler - something to deal with each inbound request. In our case, it's a simple block that spits out some basic header type information as the body of the response. This is the part where you would want to customize; it's pretty easy to see how you could generalize this example for some ad hoc application status reporting
After that, we set up the actual server as an instance of SstBasicServer. Again, for an actual application, you'll want to create your own class for the server. In our case, we specify the port, some basic error handling (note the use of #isSstError), and start the server. As with HTTP client usage, we use #startUp - and eventually, when we want to shut it down, #shutDown.
Execute the code above - you should see something like this:
Now, open up a browser on your server (assuming you are running it now), and you should see something like this:
Finally, using the workspace attached to the inspector, send #shutDown to the server - you should see something like this:
Need more help? There's a screencast for other topics like this which you may want to watch. Questions? Try the "Chat with James" Google gadget over in the sidebar.
Today's Smalltalk 4 You looks at using exceptions (raising them) in VisualWorks Smalltalk. If you have trouble viewing it here in the browser, you can also navigate directly to YouTube. To watch now, click on the image below:
If you have trouble viewing that directly, you can click here to download the video directly. If you need the video in a Windows Media format, then download that here.
Today's Smalltalk 4 You looks at url encoding and decoding in VA Smalltalk. If you have trouble viewing it here in the browser, you can also navigate directly to YouTube. To watch now, click on the image below:
If you have trouble viewing that directly, you can click here to download the video directly. If you need the video in a Windows Media format, then download that here.
You can also watch it on YouTube:
Today we'll take a look at url encoding and decoding in VA Smalltalk. When making HTTP requests and posts, it's quite common to have to deal with encoded content. Fortunately, it's easy to do in VA. To Encode, we'll use an url:
And there's the result, back in its original form. That's all there is to it.
Need more help? There's a screencast for other topics like this which you may want to watch. Questions? Try the "Chat with James" Google gadget over in the sidebar.
Today's Smalltalk 4 You looks at client level HTTP again in VA Smalltalk - specifically, how to make such usage simpler. We also take a brief look at using proxy servers. If you have trouble viewing it here in the browser, you can also navigate directly to YouTube. To watch now, click on the image below:
If you have trouble viewing that directly, you can click here to download the video directly. If you need the video in a Windows Media format, then download that here.
You can also watch it on YouTube:
Today we'll go back to HTTP queries in VA Smalltalk. As it happens, there's a simpler way to do queries than getting the client, starting it up, and shutting it down. Instead of this:
"Set up a client for http, execute a request"
client := (SstHttpClient forTransportScheme: 'http') startUp.
response :=
[client get: 'http://www.jarober.com']
ensure: [client shutDown].
^response.
If you trace through the execution, you'll see that it does the same thing as the more complex looking code - but it's a whole lot simpler to use. Once you do that, you should see something like this:
We can't really demonstrate proxy server usage, as the network used here doesn't have that. However, it's pretty straightforward. Simply use the following:
and then execute requests normally - you'll then be using your proxy server.
Need more help? There's a screencast for other topics like this which you may want to watch. Questions? Try the "Chat with James" Google gadget over in the sidebar.