User Guide
Ruby Component
Debugging
FlowBotics Studio is designed to make programming easier. However, it can never be foolproof and so at some point you are bound to find
yourself facing bugs which have you scratching your head.
This aim of this section is to provide you with information, hints and tips that will hopefully make the debugging process much less of a
headache.
Error Reporting
The first thing you need to know when you have an error is where it is. As we discussed way back near the start of this whole chapter, the
Ruby component evaluates your code while you are typing. If an error occurs it is displayed immediately in the output pane.
Hopefully this will help you eliminate most problems immediately when they occur.
There are some situations where errors are not reported straight away. Errors inside any methods you define will only show up when the
method is called. There are some exceptions to this but most of the time the error will only show itself on executing the method.
When this happens you will still get an error message. However, unlike when you're typing you may have moved to another part of your
schematic and not be able to see the component when the error appears.
To help with this, FlowBotics Studio highlights any module that contains a Ruby component that has an error.
This highlighting propagates right up to the top level so no matter where you are in your schematic, you should see errors show up on the
navigator and you can drill down through them to find the cause.
The watch Method
If you're debugging your code it's often very useful to be able to look at the values of variables as your code runs. You'll recall from earlier in
the chapter that the value of the last evaluated expression is shown in the output pane. This is great but what if you want to see a value that
is calculated earlier or inside a method?
To help with this we have the watch method. This method takes two inputs. The first is a label to identify the watched data in the output
pane. The second input parameter is the value you want to watch. The label can be a string or an integer value.
115 of 212