Are you done setting up the Xill IDE? Did you start your first project? Then following this tutorial here is probably the best way to proceed.

Let's start by taking a look at a very simple robot. Copy (doubleclick to select) and paste the code in the IDE for more accurate highlighting. Step through the robot like described in the debugging article.

First example 

use System;
function greet(name) {
    System.print("Hello " :: name);
}
var myname = "Xillio";
greet(myname);

 We'll walk you through this code, line by line. 

Line 1: Use System;

As a developer you have a full arsenal of so called 'constructs' at your disposal which you can use to add functionality to your robot. These constructs are actions that take parameters. An example could be File.saveTo that saves text to a file. Constructs are grouped in packages. On this first line you tell your robot that you will use the System package, which gives you access to all constructs in it.

Line 3 - 5: function greet(name) { ...

Xill allows you to define functions. These functions can be used to make your code more readable, maintainable and shorter by eliminating duplicate code. This particular function will print a greeting to the console if you give it a name.

Line 4: System.print(...);

This is where we invoke the System.print construct with a message.

Line 4: "Hello " :: name

On this line you can see how we use the :: operator to concatenate two string values together.

Line 6: var myname = "Xillio";

Here we declare a variable called 'myname' and assign the value "Xillio" to it. Of course you could put your own name there instead.

Line 8: greet(myname);

And finally we call the greet function with the value that is assigned to myname.

If you run this code, you'll see the info message "Hello Xillio" in the console.

A more complex example

Here's a bigger robot that is still linear and simple, but demonstrates some other essential parts of the Xill language. Step through this code and read along with the comments:

/*
Author:     Xillio
Modified:   7-9-2015
Description:
        The Xill scripting language has a javascript like syntax.
        It is an imperative language without user-defined classes and inheritance.
*/
// To start off this robot we will have to declare all the plugins we use
use System;
use String;
  
// Literal strings must always be enclosed in either double or single quotes
// Each command is closed with a semicolon ;
var message1 = "Hello";
var message2 = "Xillio";
  
// Plugin functions are called with zero or more comma-separated arguments: System.print("Hello");
// Strings can be concatenated using the :: operator
System.print(message1 :: " " :: message2);
  
// Operators can be used to perform simple actions like concatenating, multiplying;
var b = 5;
var a = b + 1;
System.print(a);
  
// Curly braces are used to enclose code blocks that are executed when specific conditions
// are met, such as in if, foreach, while and routine.
if(true) {
    System.print("Hello!");
} else {
    System.print("Goodbye!");
}
  
// Lists and Objects can be defined using json notation
var emptyList = [];
var emptyObject = {};
var simpleList = ["a", "b", "c"];
var simpleObject = {
    "first": "a",
    "second": "b",
    "this is a complex key": "c"
};
  
// Accessing list elements
System.print(simpleList[0]);
System.print(simpleObject.first);
System.print(simpleObject["this is a complex key"]);
// Handling lists with foreach
foreach(key,value in simpleObject) {
    System.print(key :: "\t" :: value);
}
// When robots grow and get more complex you will want to create your own routines for
// repeating tasks and to keep your code maintainable. Consider the following.
function removeDiacritics(str) {
    // Use the built in replace function with regular expressions
    str = String.replace(str, "[éèêë]", "e");
    str = String.replace(str, "[óòôö]", "o");
    str = String.replace(str, "[áàâä]", "a");
    str = String.replace(str, "[úùûü]", "u");
    str = String.replace(str, "[íìîï]", "i");
    str = String.replace(str, "[ýÿ]", "y");
    return(str);
}
System.print(removeDiacritics("Why livë lìfe tö the mâx when you can livê it to the méân."),"warn");
// Happy coding, from the team at Xillio