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

Questions on Sum2000 P2 Milestone

Ask questions here...

Now open for business!

Be sure to form a team for this one (Summer 2000 Team Forming Page), and do read the section in Chapter 4 on ChangeSets and Projects. They're INDISPENSABLE for team projects in Squeak! Mark Guzdial


I am trying to add rows of buttons to an AlignmentMorph. It keeps showing all my rows into one combined row. Is there anyway to have my rows appear one under each other in the AlignmentMorph?

8June: Place a different AlignmentMorph for each row. AlignmentMorphs inside of AlignmentMorphs is how much of layout occurs in Morphic. Mark Guzdial



I downloaded the examples from lecture from the web site provided in the Squeak book, page 147. After I file it in, when I try running the code in the WorkSpace, it doesn't work. Some of the commands, like setTime:, are not recognized. Is there something I am missing in getting it to run?

8June: No, it should work. What did you load in? Clock.st includes all the basic clock stuff, but to do the UI stuff, you must load each of 1, 2, and 3 in order. Mark Guzdial


This is not a P2 question...
I make some changes to a method in the browser and I say 'accept it' the immediate message I get is a window which says 'file write failed' and it would not let me save anything. I can't figure out what to do. I can open up a browser , workspace or anything but if I do 'accept' or 'do it' it gives me that window and does nothing. Can someone please tell me how to get rid of that window.

Thanks
Sounds like you were working in the cluster and you left your changes file across Samba. Squeak lost the connection, and now you're hosed. Restart and see Squeak FAQ. Mark Guzdial

This is a P1 question
(I put it here because I don't know if P1 questions will still be monitored).
Just going back and trying to get what I didn't get done on P1 done. Question about the dictionary for the GreekSymbol. I have this working. The method to create the dictionary is a class method inside GreekSymbol. It is called by the MathEquation from: method. To me this seems inefficient, i.e. every time Math Equation from: gets called, the dictionary is re-created. I know Mark said in class don't be concerned about # of messages, but just in general, I feel my design is not entirely correct on this one.
Thanks!
There are a couple ways to do this.
  1. You could have a class "initialize" method that gets called only once and sets a class variable containing the dictionary. This isn't uncommon.
  2. A second way is using something called lazy initialization. Inside from: check if the dictionary (again, in a class variable, since it can be shared) is initialized, and if not, initialize it.
Mark Guzdial
p.s. We'll be describing how to do interfaces in Morphic this week in lecture, for those struggling with it this weekend.


Should our user interface have a "save" button which allows the user to save the ImageMorph that is created to a folder. The instructions say that our program must generate an ImageMorph of the equation, but doesn't say what we should do with it once we're done. But maybe that's for the next Milestone. Thanks!
You don't really need one. There are various tools in Squeak for generating GIF, EPS, etc. from ImageMorphs. Mark Guzdial

Is there any good way of resizing a SystemWindow? I've gone through all of SystemWindow's methods, and looked at its superclasses. I still can't see how to resize it. The only way I've been able to do it, is to do the following:

example _ SystemWindow new.
example openInWorld.
example width: 400.
example position: 20@50.

I know this is a hackish way of doing it, but that's all I could make work. The problem with doing it this way is that the window will first pop up where the system tells it to, and then a millisecond later it will move to where I specified. Is this okay?


I'm having a problem with a wait statement. We're waiting with something to the effect of:

[object hasValue]
whileFalse:
[(Delay forMilliseconds: 500) wait].

This code seems to wait fine, except for the problem that it won't allow us to do anything... the mouseclicks that we do don't register, the screen doesn't update at all, and any of our buttonMorphs are uneffective. The minute that we hit Alt-. to interrupt, all of the button clicks register, and the buttonMorphs do what they were supposed to do. We have tried all different amounts of time for the wait, from 2 seconds to 1/30 seconds. Anybody have any ideas?????

Thanks. Rich Glazerman

Your code is stopping squeak from going on to anything else, including accepting mouseclicks which could change the value of the object and allow you to escape your delay loop. You might have to run your code as a thread, e.g. [your code] fork. Ashley Taylor

Ashley's right: A wait LITERALLY waits. The process is hung. Mark Guzdial

Im trying to turn in Lab2 but I get a message not understood:binary
error on the line that reads filestream binary.

Nevermind about the not understood:binary question. My file was a converted Word file. I had to past it into a txt file.

We figured out how to get SystemWindows to open at the right size. Morphs get sent the message initialExtent to figure out their opening size. SystemWindows define initialExtent as model initialExtent. So we defined a class, SomeWindowModel which had the method initialExtent returning the value we wanted. Now,
s := SystemWindow new.
s model: (SomeWindowModel new).
s openInWorld.
worked just fine.
Mark Guzdial


Is it possible to create a class that subclasses String, and also has instance variables? Every time I try, I get an "Error: A non-pointer class cannot have instance varaibles" error. Thomas Annandale

It's a SERIOUSLY bad idea. Think about it – as soon as you redefine String, EVERY STRING IN THE ENTIRE SYSTEM IS NOW "DEFUNCT" – OF THE WRONG FORM!. As the error indicates, String is a kind of class that CANNOT take instance variables. (Array is another.) What is it that you're trying to do, Thomas? Mark Guzdial

I wasn't trying to redefine String, merely subclass it. String subclass: #MyString, to add extra functionality to string (ie, the ability to hold a font and a size) without tampering with the String class. I don't see why this should be illegal. I guess I'll find other ways to do it, though subclassing String seems to me to be the cleanest. Thomas Annandale

Why not just create a class that has an instance variable that IS a string, as well as a font and a size... you can then use those in combination to get what you want... no need to subclass string... just a suggestion... Rich Glazerman

That's what I'm going to do (and what I did for the first milestone) if it's impossible to subclass String. Subclassing String just seems to me to be the nicer solution. Thomas Annandale

Ah, I see your issue. You can subclass String, but if you do, you can't add instance variables to it. There is actually more than one kind of class in Smalltalk. One kind (rarely used) doesn't have instance variables per se – instead, it has a chunk of memory that it indexes. String and Array are both of that kind. You can subclass String to add functionality, but you can't mix index and instace variables. Mark Guzdial



Back to my question on wait again... where the code was as follows:

[object hasValue] whileTrue:
[wait.]

I've tried the fork option, where we create an instance of our UI class in a block, and fork that instance... which would seem to me to create a new process in which this UI is running, so that any button press or anything would still be able to occur in this process. My original process, then, needs to wait for the second process to set a value. At the current moment, I've attempted both the straight delay wait as the second process, as well as using a Semaphore wait and signal, where the second process runs the new UI, and sends a signal when it has set the value, and the first waits for that signal. This also seems to hang, as it appears that even the semaphore wait LITERALLY waits, and hangs both processes. Is my thinking wrong here? Shouldn't I be able to fork of a process, and have another process wait for that to send it a signal without having things hang??? HELP!!! PLEASE!!!

Rich Glazerman

Just wanted to insert a bit of information here about Squeak's threading (at least from what I understood when playing with it). If two threads of the same priority are run then whichever one gets the thread of execution will continue running until it explicitly yields to let another thread of the same priority run. So make sure that the thread which is running isn't the one that is waiting. There is a yield method that you can call to allow your thread to yield. Don't know if this relates to your problem (since it is hard to tell without looking at code), but just thought I would throw up this bit of info. Eric Anderson

First off, Rick, there is NO REQUIREMENT TO USE PROCESSES IN THIS PROJECT! Seriously! NONE! You can do this all just fine without forking. Second, the only way to get safe inter-process communication is via Semaphores. You don't have to use waits at all! Simply signal the semaphore. If the other process is waiting for the semaphore, it will proceed when the semaphore gets signalled. Mark Guzdial


Our group has been having problems with Squeak crashing(unrecoverably
by Alt-<.>). We've tried several times to figure out how to use the
.changes file for recovering, but we can't get it to work. We've tried:
open > simple change sorter > new changes

but several classes are missing, what are we doing wrong?

The simple change sorter doesn't let you look at an EXTERNAL changes file – it only lets you look at your CURRENT changes file. You can select an old Changes file from the File List, then browse code or browse changes.

But suggestion: SAVE YOUR IMAGE BEFORE YOU EXECUTE, OR, FILEOUT YOUR CHANGE SET! Mark Guzdial

I have a question about Morphs/MorphImages. I know you can change the size of them using the newForm message and passing a form of a new size, but if you do it when there are other MorphImages embedded in the MorphImage you are trying to resize, it doesn't seem to resize. My question is: is there a way to resize a Morph or MorphImage while at the same time resizing all its submorphs too? I've been adding submorphs using the addMorphFront:fromWorldPosition: message if that helps... Thanks.
Why not just addMorph:? addMorphFront:fromWorldPosition: may be placing additional constraints on the morph that gets in your way. I've never had any problem resizing a morph and all its internal morphs. Mark Guzdial


A couple of things that got asked in class this morning that I wanted to be sure to mention:

Mark Guzdial


I am still unsure about what exactly has to be done for P2. I assume we're creating an interface with various buttons that represent the functions wrote for P1, like MathFraction, MathOPeration etc. THe user would click on a button, and then more menus would be popped up, allowing the object to be assembled part by part. THen a final enter or finish button would be clicked, and the equation would be displayed in a form as in P1. IS this correct?

It can be whatever you want to look like. The UI design is up to yall. What we want is a graphical interface in which we can create equations with. It it up to yall to figure out how it should look and feel. Eric Anderson



For some reason my cursor in Squeak is now invisible even when I open with all the copies I made of the original good image file. Any ideas? It's hard to do anything when you can't see what your pointing at.


Lets say I have a rectangle morph and a...smaller rectangle morph I suppose. I try to add one to the other using addMorph. My intention is to be able to display the larger one with the smaller one in it, and I can move the smaller one around WITHIN the larger one, but it cannot leave it. I saw Mark do this in class with a rectangle morph and a curve morph. Anyway, when I use addMorph and openInWorld the larger morph, the smaller one is fused to the larger one. I cannot grab it to move it around the inside of the larger one. Is there an easy way to do this without constantly testing the bounds of the larger one so that I make sure the smaller one doesn't leave it?


Seth, no, you have to test bounds.
For P2, you are building a UI that allows you to build the things that were buildable in P1.
To restore your cursor, it's something like "Cursor normal show" – take a look at the source. - Mark Guzdial



I'm having trouble getting the EmphasizeMenu class to work.
It's not running the method that I specify with the action: call
when I click on the appropriate menu entry. I even tried
putting in a bogus method name and when I clicked on the
appropriate menu entry, no error message was generated.
Any idea?

– Rakesh

It doesn't run any method! It simply returns the symbol (read that section over carefully...). This allows you to do something like model perform: (menu startUp). Mark Guzdial




Does UML distinguish between an instance of a class "talking to" a Class Object or another instance of a class? I know the "talks to" relationship is shown with a dotted line, but should there be anything different with that line if it will be talking to the Class Object of that class instead of an instance? Is it ok to add an arrow on the dotted line to show which direction the "talking" is being done?
Nope – it's one of the downsides of the UML class diagram that you can only talk to classes of objects (or the class itself). You can't really describe talking to specific objects (like the class itself). Your UML lecture on Thursday will describe other UML diagrams that let you describe these other things. Mark Guzdial



In our UI the user clicks on, say, the fractions button- this then (in theory) pops up 1 window asking for the numerator at which time the user clicks 'accept', the numerator is returned to our model and then a similiar window pops up for the denominator. The problem I've been running into is that I can't figure out how to get the model to wait on the user clicking on "accept" for the numerator before popping up the denominator window.
Any advice would be appreciated,

Why is your model waiting for your controller to do something? You don't want your model to be dependent on how your controller acts. Eric Anderson



Is it possiable to have a PluggableButtonMorph action: pass in a
symbol that takes in a parameter?

In other words why does the following not work?

test
test:= 2.

component := PluggableButtonMorph new
model: clock;
action: #(addHour: test);
label: 'Hours +';

If gives the error:
MessageNotUnderstood: (addHour: test )

Clock(Object)>>doesNotUnderstand:

Is it possiable to "call" methods in a model that take in "parameters" from an action:


I have found a disk full of somene's work for Milestone 2 in the State's cluster. It is a blue disk withno label. Potential owners can contact me at shweppy@cc.


How do you print a single apostrophe?
Use a two single apostrophe's in a string. For example to print a single apostrophe to the Transcript type -
Transcript show: ''''.
Eric Anderson



Eric..I tried that but it doesnt seem to work. It will print properly on the Transcript when I type
 Transcript show: ''''.
, but when I save that value in a string it will store it as ''. Any ideas anyone?

I have a method that creates a Window with various buttons. These buttons can call more instances of the window to "nest" math objects within each other. The problem is is that I want the method that creates the window to be able to also wait for the user to finish completing that part of the equation, and then return the form instantly. This is similar to a FillInTheBlankMorph, whose 'Accept' button actually returns the string contained in the textfield, allowing the calling method to essentially use just 1 line of code to get the user's request. I basically want to emulate this sort of behavior.
I've made an instance variable in my Window class that would hold the form to be returned, and I've implemented the methods that would write to that form. But I want the method (which created the Window) to basically return the form once it finds out that the form has been created. I've read the above posts on Semaphores because they seem very pertinent to what I'm trying to do, but I can't figure out how to implement them in Squeak. I would theoretically just "halt" the Window initlialize method after the window had been popped up. The method would be halted until the user assembled that part of the eqaution, and when the form had been created, the initialize method would take over execution and return that form.
Any ideas on how i could do this?



A question on the UML design:
I've been using BOOST to do my UML diagram, but it doesn't exactly follow standard UML conventions. Will I be penalized for this, and thus should I use another UML tool? Or will a BOOST-created UML diagram be accepted as it is?

Geoff McElroy




I am trying to work out a solution involving Semaphores, but I have run into an obstacle. Let's say I have a Semaphore called testSemaphore. basically, the situation is that whenever one of my SimpleButtons is pressed, a testSemaphore signal is called.

Another method is constantly running - the first line in the method, however, is a testSemaphore wait. In other words, I want to suspend this process indefinently until one of my SimpleButtons has been pressed, at which time I want to continue executing the method. However, this wait call to the Semaphore is halting the entire system. The way I understood Semaphores to work is that they differed from the Delay class in that they did not have to suspend the whole system, only suspend the process that was relying on a signal from the Semaphore. Was I wrong in assuming this? Does a Semaphore wait call halt the system from user input, mouse clicks, etc., or am I leaving something out? Thanks.







Link to this Page