Ok sorry for all... I am giving up herre. On Thu, Aug 21, 2008 at 11:52 AM, Hugh Sasse <[EMAIL PROTECTED]> wrote:
> > > On Thu, 21 Aug 2008, Jean Lazarou wrote: > > That's what I thought, but then I must change the code I want to run (see >> highlighted code) >> > > This is a mailing list. The text appears as plain text for many > readers. There is therefore no highlight. Even if there were a > highlight, it doesn't tell us what change you have in mind. > > You should not be sending HTML to a mailing list, if you are > expecting me to see some highlight in the HTML. See these for > plenty of reasons why not: > http://www.american.edu/cas/econ/htmlmail.htm > http://www.expita.com/nomime.html > and elsewhere. > > >> Shoes.app :height => 260, :width => 250 do >> animate(1) do >> @time = Time.now >> clear do >> $app.draw_background >> stack do >> puts "Time = [EMAIL PROTECTED]" >> end >> end >> end >> def draw_background >> end >> end >> >> And would ideally like not change that code... >> > > You already have. You redefined Shoes.app so it calls the block > after not doing any setup, and so it does nothing with the result: > > > 13 class Shoes >> > 14 >> > 15 def self.app params >> > 16 yield >> > 17 end >> > 18 >> > >> > > That changes the meaning of Shoes.app. > > Am I right? >> > > I don't know what you are expecting to happen, and why what you are > getting doesn't make sense to you. Computer programming actually > relies heavily on the scientific method: "What did you expect, what > did you do to test that, what result did you get, and what did you > conclude from that?." That's 4 possible places for there to be a > problem. Your initial expectation may be wrong. You could do the > wrong experiment. You may incorrectly observe (and report) the > result. You may draw the wrong conclusion from it. This sort of > thing happens all the time. That is why science has a peer review > process. > > >> -Jean >> > > Hugh > > >> On Thu, Aug 21, 2008 at 6:48 AM, Ernest Prabhakar >> <[EMAIL PROTECTED]> wrote: >> Hi Jean, >> On Aug 20, 2008, at 4:59 PM, Jean Lazarou wrote: >> >> Hi Ernest, >> >> Where does the '$app' come from? >> >> >> That's just a global that you initialize from *inside* the >> 'Shoes.app' section of your code, so you can refer to it elsewhere. >> >> Look at some of the examples, like tankspank. >> >> -enp >> >> >> >> -Jean >> >> >> On Wed, Aug 20, 2008 at 11:26 PM, Ernest Prabhakar >> <[EMAIL PROTECTED]> wrote: >> Hi Jean, >> >> You may want to try the: >> >> $app = self >> $app.draw_background >> >> >> trick.... >> >> -enp >> >> >> >> On Aug 20, 2008, at 11:22 AM, Jean Lazarou wrote: >> >> Thank you all for answering, but if I go >> for simplicity nothing works... >> >> 34 Shoes.app :height => 260, :width => 250 >> do >> 35 animate(1) do >> 36 @time = Time.now >> 37 clear do >> 38 draw_background >> 39 stack do >> 40 puts "Time = [EMAIL PROTECTED]" >> 41 end >> 42 end >> 43 end >> 44 def draw_background >> 45 puts "draw_background" >> 46 end >> 47 end >> >> If I define a Shoes class as following and >> some methods (like animate): >> >> 13 class Shoes >> 14 >> 15 def self.app params >> 16 yield >> 17 end >> 18 >> 19 >> 20 end >> 21 >> 22 def animate fps, &block >> 23 yield >> 24 end >> 25 >> 26 def clear >> 27 yield >> 28 end >> 29 >> 30 def stack >> 31 yield >> 32 end >> >> I get >> >> test.rb:38: undefined local variable or >> method `draw_background' for >> #<Object:0x288fa34 @time=Wed Aug 20 >> 19:56:46 +0200 2008> (NameError) >> from test.rb:27:in `clear' >> >> I don't find any easy way to make the code >> run. Of course, if I comment the call to >> `draw_background' (line 38) I get the >> output => Time = Wed Aug 20 20:03:22 +0200 >> 2008 >> >> (I run the code with the C-Ruby runtime) >> >> Is there some Ruby technical I don't know? >> >> Jean >> >> >> >> >> >> >>
