Page 1 of 1
Basic loop on Ruby
Posted: Thu Jun 20, 2013 11:21 am
by borodadada
Hello, my simle code on ruby not work in flowstone, but work on Ruby language.
a = 1
b = 2
c = 3
loop do
puts a
sleep 1
puts b
sleep 1
puts c
sleep 1
end
original
flowstone
a = 1
b = 2
c = 3
loop do
output a
sleep 1
output b
sleep 1
puts c
output c
end
All die... FL crash....
trying to write a simple sequence generator
Method Sleep kill ruby.
Re: Basic loop on Ruby
Posted: Thu Jun 20, 2013 11:55 am
by Nubeat7
afaik sleep dont work here in fs, but you can try to use time.. to delay the the output..
or you use an array with you values an read the index with a timed counter..
Re: Basic loop on Ruby
Posted: Thu Jun 20, 2013 12:20 pm
by borodadada
time - FlowStone? or standart ruby class?
I have a task to build an infinite loop that would print the value of variable intervals.
Re: Basic loop on Ruby
Posted: Thu Jun 20, 2013 1:48 pm
by Nubeat7
so a,b & c are changing constantly and you want to read them every second ? maybe you could post a schematic to see what you want exactly
if you use the event method you can use time, just watch the userguide, and there is also a ruby ticker in the toolbox where you can choose variable ticking time..
Re: Basic loop on Ruby
Posted: Thu Jun 20, 2013 2:05 pm
by borodadada
if start ruby language
a = 1
b = 2
c = 3
loop do
puts a
sleep 1
puts b
sleep 1
puts c
sleep 1
end
resultat
1
2
3
1
2
3
..... + pause, infinite
I need exactly the same effect
I have a module that I need to constantly send information cycle, the size may be different, which will show itself, and I can not understand how can implement.
ticker module, but it sends a true or false.
bad in that Ruby can not write cycles ...
Re: Basic loop on Ruby
Posted: Thu Jun 20, 2013 3:35 pm
by MyCo
Here is a small example for timed events. That's the FS way to do "sleep"
Re: Basic loop on Ruby
Posted: Thu Jun 20, 2013 4:03 pm
by borodadada
thank you it works! I would like to in the future, more similar to the Ruby language