License

MIT license

Copyright (c) 2008, Doug Edmunds

Attaching to a module

Making a clean connection

This topic shows how to cleanly connect Erlbol to your existing code module.

For this section,  I use a module written by Bjorn Gustavsson.  The name of his module is e3d_vec.  The original I worked from is at http://svn.devjavu.com/optigon/trunk/e3d/e3d_vec.erl.   A copy of the erl file is in Downloads

Run in a console

As you build out the erlbol/1 function, run it  in a console.  If you have coded it correctly, input to erlbol/1 (formatted as a list) will produce the same output as the underlying function (taking 0 or more parameters directly).  You don't need to build a REBOL GUI to test erlbol/1.  You don't need to be running erbol in a server either.  Also, you don't need to write erlbol/1 code for every function in your module.  Just write as much as you need for your GUI interface.

Which functions in my module can I use?

You can use any function that returns one value.  Run the function by itself in a console to see what the return value is.  Some functions include side effects as io:format statements; those will not be sent to the GUI.  (The return value of io:format is "ok". 

You may have written a function that returns a tuple.  You can pass that tuple to REBOL, then extract the parts you want on that side.  A better solution is to do all the processing on the Erlang side.  Write a short function that returns just the one value you are after.  For example, if your original function returns {ok, Value}, write a short function that calls your function, then extracts (and returns) Value.  Link Erlbol to that new function.

Take the next step

Click on the link labeled "Connect to e3d_vec" for the how-to info.  There is discussion of some input issues that you may encounter (such as dealing with lists as input, and dealing with functions that have the same name but different arities).

There are no Erlbol files for the e3c_vec.erl file.  You can easily write an Erlbol-Erlang file that supports some of the functions.  Remember, you don't need to write erlbol code for every function.   Pick one of the functions in this module, write Erlbol-Erlang code for it, then create a simple REBOL file that creates an input window for that function (one or more fields, and a do-it button).

Content © 2007 Erlbol |
Powered by Etomite CMS.