Well just tried this code now and got the error below it.
def hello
%23@...)
puts 'hello'
end
def init
@topwin.resize(958,670)
aTimer = @topwin.addTimeout(1000, method(:hello))
....
end
>rubyw mymainwin3.rbw
mymainwin3.rbw:39:in `init': undefined method `addTimeout' for #<FX::MainWindow:0x40636ec> (NoMethodError)
from ./multitabwin3.rb:6:in `initialize'
from mymainwin3.rbw:13:in `initialize'
from mymainwin3.rbw:106:in `new'
from mymainwin3.rbw:106
>Exit code: 1
because of this error think i had tried other variations as per my original email to you.
have also tried aTimer = addTimeout.new and also added in a require 'timeout' statement into the program just in case i had to add in the file without realising it from documentation.
Now i've tried something a bit left field.
this is my thinking be it right or wrong...
because the error shown implies there is NO object created i added this in the unit test code...
#unit test
if __FILE__==$0
require 'libGUIb16'
app=FX::App.new
w=Fxwindow_code.new app
w.topwin.show(Fox::PLACEMENT_SCREEN)
@aTimer = app.addTimeout.new<<<< in case i needed to create the object 1st.
app.create
app.run
end
now i have this code
giving me the error below...
def init
@topwin.resize(958,670)
@aTimer {1000 :hello}
>rubyw mymainwin3.rbw
mymainwin3.rbw:39: syntax error, unexpected '{', expecting kEND
@aTimer {1000 :hello}
^
>Exit code: 1
have tried replacing the {} with DO and END but got an error $end expected.
tried brackets but got unexpected () encountered.
could you send me a work piece of code?
like a listbox , toggle button
push button and timer is started, after timeout text apended to the listbox, push button again and timeout is removed?
that way i can see what errors i get (esp if you wroked sample fails).
rgds,
Dave.
To: dave L <dglnz@...>Sent: Thu, 5 November, 2009 11:05:39 PM
Subject: Re: Timer function usage
you need to give it a method:
aTimer = @topwin.addTimeout(1000, method(:hello))
hth,
-- henon
On Thu, Nov 5, 2009 at 9:42 AM, dave L
<dglnz@...> wrote:
Hi Meinrad,
I have been battling with trying to get the timer event to work - wanting to have an event/methd run every X minutes.
from my reading of things this should work but it fails with no methoderror.
aTimer = @topwin.addTimeout(1000, (:hello))
Hello is a define method further up in code - currently it puts hello to a listbox every second as proof of it working.
also tried this.
aTimer = Timer.new
aTimer = @topwin.addTimeout(1000, (:hello))
my ultimate aim is to have it reset after countdown so it's a continous timer to fire an event that will request a read from a database (thinking in memory SQLlite at present) and refresh the listbox.
Oh i did get over my other issues (more of a work around but still) - that's all working now <sheepish grin>
dave.
Email slow, clunky, unreliable?
Switch to Yahoo!Xtra Mail, New Zealand's new email address.