9.6 REBOL

 

9.6.1 Introduction

REBOL is the Relative Expression-Based Object Language designed by Carl
Sassenrath, the software architect responsible for the Amiga OS -- one of the world's first personal computer multitasking operating systems.

REBOL is the next generation of distributed communications. REBOL code and data can span more than 40 platforms without modification using ten built-in Internet protocols. A script written and executed on a Windows platform can also be run on a UNIX platform with no changes. REBOL can exchange not only traditional files and text, but also graphical user interface content and domain specific dialects that communicate specific meaning between systems. Distributed communications includes information exchanged between computers, between people and computers, and between people. REBOL can be used for all of these.

REBOL is a messaging language that provides a broad range of practical solutions to the daily challenges of Internet computing. REBOL/Core is the foundation for al of REBOL’s technology. While designed to be simple and productive for novices, the language extends a new dimension of power to professionals. REBOL offers a new approach to the exchange and interpretation of network-based information over a wide variety of computing platforms.

REBOL scripts are as easy to write as HTML or shell scripts. A script can be a single line or an entire application.

(from REBOL/core User Guide, Copyright © 2000 REBOL Technologies)

 

 

The PowerNet plugin includes a useful interface to manage the REBOL scripts. Trough these scripts it's possible to control the VEGA function in order to automate the most common and repetitive operations.

 

9.6.2 How to create a simple REBOL script

This manual isn't a full exhaustive REBOL manual and for a complete description of this language, it's recommended the original documentation available in the REBOL Technologies Web site.
PowerNet offers a set of REBOL functions in order to simplify the access to the TCP/IP port and these are included in the Scripts\Common\Vega.r file.
As first step to create a REBOL script, you must add the script header:

REBOL [
  Title: "My first REBOL script"
  Date: 2-Feb-2000
  File: %test.r
  Author:  "My name"
  Version: 1.0.0
]

All keywords are optional. In the second step, you must include the file with the predefined functions to interface REBOL with VEGA/PowerNet:

do %Common\Vega.r

Please remember to specify the path of the Vega.r file in relation of the location where the script file is placed. In the present example, the file test.r must be placed in the Script directory.
At this point you must use the VegaOpen function to open the communication port with VEGA:

VegaOpen VegaDefHost VegaDefPort VegaDefUser VegaDefPass

VegaDefHost, VegaDefPort, VegaDefUser and VegaDefPass are special variables initialized by VEGA launching the script and containing the default values of the host IP, host port, user name and password (see below).
Now the port is open and you can send commands using the VegaCmd function:

VegaCmd {Open "..\Molecules\a3.msf"}

This command opens the a3.msf structure placed in the Molecules folder. The brackets ({ }) are string delimiters that allow the use of the " as a character and not as a delimiter. Open is a VEGA extended command (click here for more information).
If you want obtain a value of a VEGA environment variable, you must use the Get or PluginGet VEGA commands and the value is copied in the VegaRes REBOL variable:

VegaCmd "PluginGet TotAtm"
print VegaRes

The first line obtains the value of the TotAtm variable (it's the total number of atoms), and the second prints it in the REBOL console (not in the VEGA console). If you want print it in the VEGA console, you can use the VEGA Text command:

VegaCmd rejoin[{Text "Loaded atoms: } VegaRes {" 1}] 

The REBOL rejoin function join more strings together creating a whole string that's the argument of the VegaCmd function. For more information, consult the REBOL/Core user guide.
The script should end with VegaClose function call:

VegaClose

This function close the communication port and frees it for other applications. To run the script directly from VEGA, use the File -> Run script menu item as explained in the PowerNet script section.

 

9.6.3 The REBOL functions included in the Vega.r file

This section explains more in details the interface functions included in Scripts\Common\Vega.r file:

VegaClose
Close the communication port and free it.

Parameters:
None

Return values:
None.

Example:
VegaClose


VegaCmd   Command
Send a command to VEGA in synchronous mode.

Parameters:
Command   

Command to send to VEGA host.

Return values:
If an error occurs, this command returns the standard VEGA error code, otherwise it returns 0. The error code is also reported in VegaErrCode and the error description in the reported in VegaErrStr REBOL variable. 
If the sent command return a value, this is placed in the VegaRes REBOL variable.

Example:
VegaCmd   "mOpen"


VegaOpen   Host   Port   User   Password
Connect the REBOL interpreter to the VEGA TCP/IP port.

Parameters:
Host   

Host name or its IP. Use the VegaDefHost variable to obtain the default host.

Port

TCP/IP port number. Use the VegaDefPort variable to obtain the default port.

User

User name for the authentication. Use the VegaDefUser variable to obtain the default user name.

Password

Password for the authentication. Use the VegaDefPass variable to obtain the default password. If the password check is disabled in the PowerNet configuration window, the User and Password items can be null (""). Please remember that VegaDefHost, VegaDefPort, VegaDefUser and VegaDefPass are valid only for local connections.

Return values:
None. If it fails, the execution of the script is halted and an error message is showed.

Example:
VegaOpen   127.0.0.1 2000 "MyUserName" "MyPassword"


 

9.6.4 Notes