RUBY Counter - this was suppose to be easy :|
Posted: Thu Dec 28, 2017 1:27 am
Yeah ... I thought it'd be easy ... for a little project idea I wanted to do.
I'm trying to make a COUNTER. Was thinking RUBY based.
What I have:
OK ... so it increments 1/sec. [good].
Whenever I start the app, I can only get it to start at ZERO.
That's good, as I do need a way to manually RESET it to ZERO. But I also need it to run from the LAST VALUE,
so that when I re-run the app, it will start at the last elapsed time.
I pulled out ALL of my experimentation from this code [it wasn't pretty ... and it didn't work].
If anyone can guide me, the objective is:
1. A trigger or Boolean to start/stop the counter.
2. internally save the last counter value [do I need to right to a file ??? hope not ... but]
3. start app to count from this 'last saved' value.
4. option to RESET counter to ZERO.
ok ... I'm sure the RUBY GURUS are chuckling about this ... I've been going through a bunch of RUBY sites for
researching this. How I got to the included code. But everything I've tried since as been a mess of errors, not
working, or always starting at zero.
anyway ... appreciate anyone reading through this. Could really use the help.
Thanks GANG.
I'm trying to make a COUNTER. Was thinking RUBY based.
What I have:
Code: Select all
def init
input 100,nil
end
def event i,v,t
output 0, t
input 100,nil, t+1
end
OK ... so it increments 1/sec. [good].
Whenever I start the app, I can only get it to start at ZERO.
That's good, as I do need a way to manually RESET it to ZERO. But I also need it to run from the LAST VALUE,
so that when I re-run the app, it will start at the last elapsed time.
I pulled out ALL of my experimentation from this code [it wasn't pretty ... and it didn't work].
If anyone can guide me, the objective is:
1. A trigger or Boolean to start/stop the counter.
2. internally save the last counter value [do I need to right to a file ??? hope not ... but]
3. start app to count from this 'last saved' value.
4. option to RESET counter to ZERO.
ok ... I'm sure the RUBY GURUS are chuckling about this ... I've been going through a bunch of RUBY sites for
researching this. How I got to the included code. But everything I've tried since as been a mess of errors, not
working, or always starting at zero.
anyway ... appreciate anyone reading through this. Could really use the help.
Thanks GANG.