User Guide

Ruby Component
This will show a message box whenever the trigger button is pressed. The input parameters to the MessageBox call are parent window,
message, title, type. Notice that the message and title are passed as strings. You don't need to do any packing. We use 'p' in the input types
because these strings are char* values, not constants.
Here's one final example. This shows how to retrieve a string value from a function call.
We're using a call to GetUserName to return us the name of the current user. For this we have to create a buffer for the function to put the
name into and also pass a variable to send the buffer size and receive the length of the string sent back.
To create a suitable buffer we just need a Ruby string of sufficient size. To set up the variable to send the buffer size we have to create a
32bit unsigned int. This we do using the pack method of the Ruby Array class. We put the number we want to initialise the int with in an array
([buf.length] ie. [260]). We call pack on the array passing 'L' meaning 32bit unsigned int. See the Ruby documentation for more on the Array
Pack method.
You can see that the buffer returns the name of the user, “Fred” in this case.
The size of the returned string is placed in 'len'. This is a 32bit unsigned int remember so to convert it to a Ruby Int we need to unpack it. The
result of calling unpack is an array with the string size as the first entry. We can see the size is 5, the four characters in 'Fred' and the string
null terminator.
Distribution
If you plan to distribute any exported exes that use an external DLL you must ensure that the DLL is distributed with it. You must also
distribute the ruby\libraries\win32 folder that is located in your FlowBotics Studio install folder. You need to have a folder called ruby in the
same folder as your exported file. Inside this folder should be a libraries folder and inside that you place the win32 folder and all its contents.
Without these your export will not function correctly.
161 of 212