Basic loop on Ruby

For general discussion related FlowStone
Post Reply
borodadada
Posts: 47
Joined: Sun Jun 02, 2013 5:58 pm

Basic loop on Ruby

Post 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.
User avatar
Nubeat7
Posts: 1347
Joined: Sat Apr 14, 2012 9:59 am
Location: Vienna
Contact:

Re: Basic loop on Ruby

Post 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..
borodadada
Posts: 47
Joined: Sun Jun 02, 2013 5:58 pm

Re: Basic loop on Ruby

Post 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.
User avatar
Nubeat7
Posts: 1347
Joined: Sat Apr 14, 2012 9:59 am
Location: Vienna
Contact:

Re: Basic loop on Ruby

Post 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..
borodadada
Posts: 47
Joined: Sun Jun 02, 2013 5:58 pm

Re: Basic loop on Ruby

Post 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 ...
User avatar
MyCo
Posts: 718
Joined: Tue Jul 13, 2010 12:33 pm
Location: Germany
Contact:

Re: Basic loop on Ruby

Post by MyCo »

Here is a small example for timed events. That's the FS way to do "sleep"
Attachments
timed loop (MyCo).fsm
(441 Bytes) Downloaded 1180 times
borodadada
Posts: 47
Joined: Sun Jun 02, 2013 5:58 pm

Re: Basic loop on Ruby

Post by borodadada »

thank you it works! I would like to in the future, more similar to the Ruby language
Post Reply