Support

If you have a problem or need to report a bug please email : support@dsprobotics.com

There are 3 sections to this support area:

DOWNLOADS: access to product manuals, support files and drivers

HELP & INFORMATION: tutorials and example files for learning or finding pre-made modules for your projects

USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here

NEW REGISTRATIONS - please contact us if you wish to register on the forum

Users are reminded of the forum rules they sign up to which prohibits any activity that violates any laws including posting material covered by copyright

Last Switch(Ruby)

For general discussion related FlowStone

Last Switch(Ruby)

Postby billv » Mon Aug 05, 2013 7:47 am

Had lots of silly attempts at this over last few weeks...
have stripped it down to this....
Code: Select all
def event i,v
  if i==0 then
  output 0,@firstsignal
  end
  if i==1 then
  output 0,@secondsignal
  end
end

I want it to behave just like the standard "green" Last Switch.
Seems to work right...but it's a real important part...and I've stuffed it up a few times now...
so I want to make sure...before i stick a few hundred in my schematic..
Can anyone see a problem with this code....??
Is there a better way...?
billv
 
Posts: 1157
Joined: Tue Aug 31, 2010 3:34 pm
Location: Australia

Re: Last Switch(Ruby)

Postby MyCo » Mon Aug 05, 2013 8:03 am

Code: Select all
def event(i,v)
  output(v)
end
User avatar
MyCo
 
Posts: 718
Joined: Tue Jul 13, 2010 12:33 pm
Location: Germany

Re: Last Switch(Ruby)

Postby nix » Mon Aug 05, 2013 8:21 am

I think the inputs will sum MyCo?
Bill, I have done exactly the same thing,
I think it works fine.
Cheers
User avatar
nix
 
Posts: 817
Joined: Tue Jul 13, 2010 10:51 am

Re: Last Switch(Ruby)

Postby billv » Mon Aug 05, 2013 8:35 am

Great.....thanks guys.
billv
 
Posts: 1157
Joined: Tue Aug 31, 2010 3:34 pm
Location: Australia

Re: Last Switch(Ruby)

Postby MyCo » Mon Aug 05, 2013 5:16 pm

nix wrote:I think the inputs will sum MyCo?


No, why should they?
User avatar
MyCo
 
Posts: 718
Joined: Tue Jul 13, 2010 12:33 pm
Location: Germany

Re: Last Switch(Ruby)

Postby billv » Mon Aug 05, 2013 8:43 pm

Works great Myco....
I thought the inputs would needed to be declared individually....
I had no idea i could get away with that.. :D
Cheers
billv
 
Posts: 1157
Joined: Tue Aug 31, 2010 3:34 pm
Location: Australia

Re: Last Switch(Ruby)

Postby nix » Mon Aug 05, 2013 10:37 pm

oh ok sorry-
I don't know what i was thinking there
That's neat as MyCO, will use it too
User avatar
nix
 
Posts: 817
Joined: Tue Jul 13, 2010 10:51 am

Re: Last Switch(Ruby)

Postby RJHollins » Tue Aug 06, 2013 8:50 am

Ahhh ... for the 'slow' learner crowd ... apparently me :o

I tried a very simple input [ 0 or 1], along with inputs for the the 2 variables ... I could not get this to work consistently :shock:

This seems that this should be a simple choice and path through the code ... If 'this' ... this, if 'that' .... that.

How I'm screwing this up is ridiculous .... I'm embarrassed, but can someone shed light on this please :oops:

Thanks.
:roll:
RJHollins
 
Posts: 1571
Joined: Thu Mar 08, 2012 7:58 pm

Re: Last Switch(Ruby)

Postby nix » Tue Aug 06, 2013 12:16 pm

last.fsm
(524 Bytes) Downloaded 913 times


Here are 3 variations, 2 of Bill's and the MyCo one.
I think the problem u had was not naming the inputs.
np with asking- it's how I finally cottoned onto this program a little
User avatar
nix
 
Posts: 817
Joined: Tue Jul 13, 2010 10:51 am

Re: Last Switch(Ruby)

Postby RJHollins » Tue Aug 06, 2013 6:40 pm

Thanks Nix !!

It was the 'Trigger' :shock:

I had mine similar to your 2nd example ... BUT ... I also had a 3rd INPUT variable (i). :roll:

Obviously, still struggling to get a handle on the basics of RUBY. I'm hitting those posted RUBY sites to get familiar. My only programming 'experience' was using GFABasic on the ATARI ST back in the 80's. :lol:

When I looked at this "Last Switch', I saw an input [i], and 2 result variables. So on the left side of the RUBY box, I had 3 string inputs [labeled] ... i, firstsignal, secondsignal. I thought changing i from 0 to 1 would toggle the output through the IFTHENELSE routine.

Still don;t understand why this didn't work ... also [now] not sure what the 'DEF event i,v' is really doing. I thought this was telling RUBY to watch for 'i' and output to 'v'.

ahhh ... soooo much more to learn.
RJHollins
 
Posts: 1571
Joined: Thu Mar 08, 2012 7:58 pm

Next

Return to General

Who is online

Users browsing this forum: No registered users and 143 guests