- Download
- Arithmetic Expressions
- Logical Operators
- Variables
- Strings
- Lists
- If-Statement
- For and While-Statement
- Functions
- Build in Functions
- Multi-Line-Statements
- Return, Break, Continue-Statement
- Run-Statement
- Comments
- You can download SparkScript on GitHub.
- The sourcecode is free and you can modify it how you want.
- You can use Arithmetic expressions mostly like in other languages. But of course I will list them here.
- The sign for Plus is a normal + so you can add numbers like this a + b
- Minus Works exactly like Plus so you can subtract numbers like this a - b
- You can multiply numbers like this a * b
- You can divide numbers like this a / b
- You can raise a number by a power like this a ^ b
- You can also calculate with parentesis like a * (b + c)
- First of it is to say that the number 1 represents True and the number 0 represents False.
- You can test if a number is equal another by writing a == b. If it is True, you will get 1 and if it is False you will get 0
- You can test if a number is not equal another by writing a != b. If it is True, you will get 1 and if it is False you will get 0
- You can test if a number is bigger or smaller than another by writing a < b or b > a. If it is True, you will get 1 and if it is False you will get 0
- You can define a variable relatively simple like this.
VAR a = b
- Strings are basically the same as in most other languages. You are marking a String like in most other languages with quotation marks like this.
"text"
- You can also initialize a new line with a \n like this
"text \n text"
- You can create Lists with square brackets like this. The elements a separated with commas.
[elements]
- You can add an other element to the List like this.
[elements] + element
- You can also combine two lists like this.
[elements] * [elements]
- You can remove an element like this
[elements] - elements_number(starts with 0)
- To get an element out of a List you can use / like this
[elements] / elements_number(starts with 0)
- An IF statement is structured like this.
IF condition THEN expression
- You can also use the ELIF-Statement like this to get another condition and expression.
IF condition THEN expression ELIF condition THEN expression
- You can also use the ELSE-Statement like this to get only another expression.
IF condition THEN expression ELSE expression
- A For-Statement is structured like this.
FOR variable_name = start_value TO end_value THEN expression
- You can also implement a step into the For-Statement like this.
FOR variable_name = start_value TO end_value STEP step_value THEN expression
- A While-Statement is simpler. It is structured like this
WHILE condition THEN expression
- A simple Function is structured like this.
FUN function_name (arguments) -> combination_of_the_arguments
- You can call the Function then like this.
function_name (arguments)
- You can give a Function an other name like this
VAR other_function_name = functions_name
- and then call the Function with the other name
other_function_name (arguments)
- You can also create anonymous Functions without names like this
FUN (arguments) -> combination_of_the_arguments
- and assign these Functions some Variable like before
function_name = FUN (arguments) -> combination_of_the_arguments
- and also call these like this.
function_name (arguments)
- The Function PRINT prints out a given String or Integer in the Console like this.
PRINT("text")
or this PRINT(integer)
- The Function
PRINT_RET
will return the printed value.
- The Function
INPUT
takes String inputs and the Function INPUT_INT
takes Integer inputs
- The Function
CLEAR
clears the console.
- The Functions
IS_NUMBER, IS_STRING, IS_LIST, IS_FUNCTION
are checking if some data is an Integer, a String, a List or a Function.
- The Function
APPEND
adds an element to a List, POP
will remove an element from a List and Extend will combine two Lists together.
- You can return the length of a List with the Function
LIST
.
- If you have a Multi-Line-Statement like this.
FUN name()
expression1
expression2
expression3
- Then you have to end it like this
FUN name()
expression1
expression2
expression3
END
- with the word END
- The Return-Statement can be used like this to return a value of a Function.
FUN function_name(arguments)
return combination_of_the_arguments
END
- You can use the Break-Statement inside a For-Loop like this to break out of the Loop with some condition.
FOR variable_name = start_value TO end_value THEN
IF condition THEN
BREAK
END
END
- You can use the Continue-Statement like this to Continue-Statement so if there is some other condition you can continue.
FOR variable_name = start_value TO end_value THEN
IF condition THEN
BREAK
IF other_condition THEN
CONTINUE
END
END
- You can use the Run-Statement like this to run a program which is written in SparkScript.
RUN("path_to_program")
- You can comment in your Script with putting a # before the comment.