Erlang Code Model
How the Erlang side works
See/download the code here
Erlbol does this:
- Receives a list of strings from the REBOL client
- Converts the elements of the list into appropriate datatypes
- Sends the converted input to an Erlang function.
- Receives output from the Erlang function and sends it back to the REBOL client
The demo code creates a parallel server. Multiple clients can connect to the server at the same time. The clients do not have to be identical.
The server waits for input from the REBOL client. Input will come as an Erlang list. The elements of the list are all strings. The server sends the list to erlbol/1.
The first element of the list matches in a case statement in erlbol/1. The case statement converts the other elements of the list into the appropriate datatypes. After conversion, the function is called. As programmer, you code the conversion from strings to the datatypes your Erlang function needs.
Fields are not identified by name. It is the programmer's job to verify that the input data in the same order as the case statement in Erlbol. I recommend that you send the fields in the same order as they appear in the Erlang function that will process the data.
The key advantage to using a list for input to Erlang is only one Erlbol function is required. If function X needs three parameters, it can break up the list as [A,B,C,D | _Tail]. If function Y needs one parameter it can break up the list as [A,B | _Tail]. (A is always the function name). This allows for a generic design on the REBOL side which greatly simplifies coding the GUI.