console

rcb. console

new console()

Console interface functions
Source:

Methods

(static) append(message, idopt)

Adds to the last printed line (does not create a new line).
Parameters:
Name Type Attributes Description
message string The string to print on the console. Can have html markup.
id integer <optional>
If specified, will append to this line instead.
Source:
Example
rcb.console.print('Doing...');
rcb.console.append('<strong>done</strong>');

(static) clear()

Clears the script console. Needed for performance reasons if console log has too much text.
Source:
Example
rcb.console.clear();

(static) error(message)

Prints an error on the user console. The script will be stopped.
Parameters:
Name Type Description
message string The string to print on the console. Can have html markup.
Source:
Example
rcb.console.print("A basic message");
rcb.console.warning("About to throw error");
rcb.console.error("Bazinga!");

(static) overwrite(message, idopt)

Reprints over the last line of the user console. Useful to display progress updates.
Parameters:
Name Type Attributes Description
message string The string to print on the console. Can have html markup.
id integer <optional>
If specified, will overwrite this line instead.
Source:

(static) print(message) → {integer}

Prints a new line to the user console.
Parameters:
Name Type Description
message string The string to print on the console. Can have html markup.
Source:
Returns:
A unique id, to reference this printed line later.
Type
integer
Examples
rcb.console.print('Normal text');
rcb.console.print('<strong>Bold font</strong>');
rcb.console.print('<span style=\"color: green\">Green text</span>');
//Simple examples
rcb.console.print("I will always be there!");
rcb.console.print("I will be gone");
rcb.console.remove();
rcb.console.append(" Still here!");
rcb.console.print("I will be overwritten");
rcb.console.overwrite("Fruits:");

//Working with ids
var id1 = rcb.console.print("I WILL BE REMOVED");
var id2 = rcb.console.print("2");
var id3 = rcb.console.print("I WILL BE OVERWRITTEN");
rcb.console.print("3");
rcb.console.append(" apples");
rcb.console.append(" oranges", id2);
rcb.console.remove(id1);
rcb.console.overwrite("Doesn't compare with:", id3);
rcb.endScript();
//Animation example
rcb.console.setVerbose(false);
var lineQty = 12;
var colQty = 25;
var lines = [];

//Create the lines
for(var i=0; i<lineQty; i++) lines[i] = rcb.console.print("");

//Starting coordinates
var line = 0;
var col = 0;
var dirL = true;
var dirC = true;
//Travel loop until user stops script
move();
function move(){
    //Update coordinates
    if(dirL){
      line++;
      if (line === lineQty-1) dirL = false;
    }else{
      line--;
      if (line === 0) dirL = true; 
    }
    if(dirC){
      col++;
      if (col === colQty-1) dirC = false;
    }else{
      col--;
      if (col === 0) dirC = true; 
    }
    
    //Draw
    for(var i=0; i<lineQty; i++){
        if(i===line){
            var text = "";
            for(var j=0; j<col-1; j++) text+="&nbsp;&nbsp;&nbsp;";
            text+="O";
            rcb.console.overwrite(text,lines[i]);
       }else
            rcb.console.overwrite("",lines[i]);
    }
    
    //iterate
    rcb.wait(move,0.05); 
}

(static) remove(idopt)

Removes the last line of the user console.
Parameters:
Name Type Attributes Description
id integer <optional>
If specified, will remove this line instead.
Source:

(static) setVerbose(value)

Sets the verbose mode for the rcb API. If activated (default), some API functions will print some text (in grey color). It may be useful to deactivate verbose mode in loops to avoid excessive text in the console.
Parameters:
Name Type Description
value boolean If true, verbose mode is activated.
Source:
Example
//Example showing the effect of changing verbose mode
rcb.console.print("Verbose activated...");
rcb.setDebugMode(true);
rcb.setDebugMode(false);
rcb.console.setVerbose(false);
rcb.console.print("Verbose deactivated...");
rcb.setDebugMode(true);
rcb.setDebugMode(false);
rcb.endScript();

(static) warning(message) → {integer}

Prints a message in orange. Does not interrupt script.
Parameters:
Name Type Description
message string The string to print on the console. Can have html markup.
Source:
Returns:
A unique id, to reference this printed line later.
Type
integer
Example
rcb.console.warning('<strong>Warning:</strong> winter is coming!');