Here's the documentation of Bundle Again.
Bundle Again syntax resembles shell commands, with the command type written first.
Bundle Again is very strict in terms of spacing. Commands should be seperated with arguments strictly by a space.
For example, this is correct:
write Hello, world!but this is not:
write Hello, world! // This will print " Hello, world!" instead!
Commands that uses multiple arguments like def
, add
, or if
should not have a space on the delimiter.
For example, this is correct:
add 1,2but this is not:
add 1, 2
Curly brackets allows variables to be put on arguments.
For example, this calculates 1 + variable "a":
add 1,{a}
start
and end
On Bundle v1, the keyword start
and end
are required for the code to run.
However, in Bundle Again, they are not required; however you have to use them in pairs and in their correct locations if you want to use them.
For example, this is correct:
start write Hello, world! endBut these are not:
start write Hello, world!
write Hello, world! end
start end write Hello, world!... you get the idea.
The res
variable contains the result of the last calculation. It is, in a way, a way the Bundle Again interpreter returns values.
For example, this sets the res
variable to 3:
add 1,2Note that there's nothing special on this variable. You can even set it to a custom value if you want to:
def res=1
Looping in Bundle can be achieved by the loop
command:
loop write Hello, world!Note that running
loop
doesn't actually restart the code (putting the instruction pointer back at the first line), but instead the code is flagged as looped.
write a write b loop write c write d // this prints a, b, c and d over and over againTo stop looping, use
stoploop
.
Arrays allow you to store multiple values in a single variable.
To create an array, you can use the arr
command.
You can also use the getarr
command to get the value of this
Note that getarr
counts from 0 (since that's how computers count).
For example:
arr array=1,2,3 getarr a=2 write {res}You can also concatenate arrays using
concat
. It returns the concatenated array to the res
variable.
arr array1=1,2,3 arr array2=4,5,6 concat array1,array2 getarr res,4 write {res}
Added in Bundle Again 1.2.
The deque allows you to easily store multiple values in a single place.
While it can be implemented using arrays, using deques are much more simpler.
To use the deque, you can use the commands push
, pop
, unshift
, and shift
:
push 1 push 2,3 // Current deque is [1, 2, 3] pop writeln Popped: {res} // Should write "Popped: 3" unshift 4 // Current deque is [4, 1, 2] shift shift writeln Shifted: {res} // Should write "Shifted: 1"
Bundle Again supports these commands:
def [var]={val}
: set a value to a variable
copy [orig],[copy]
: copy value of variable [orig]
to [copy]
arr [var]={v1},{v2},...
: set a comma-seperated array to a variable
getarr [var],{i}
: get a value of array at specified index and set the value to res
concat [v1],[v2],...
: concatenates the given variables and set the result to res
length [var]
: get the length of variable and set the value to res
write {text}
: outputs the text to the terminal
writeln {text}
: outputs the text to the terminal with a line break
break
: output a line break to the terminal
ask [text]
: prompt for input from user
add {a},{b},...
: adds the given values and set the result to res
sub {a},{b},...
: subtracts the given values and set the result to res
mul {a},{b},...
: multiplies the given values and set the result to res
div {a},{b},...
: divides the given values and set the result to res
+ [var]
: increments the given variable
- [var]
: decrements the given variable
if {val}={val}
: compares two values together, if it's false then skip the next line (supported operations are =
, !=
, >
, and <
)
second
: get the current second and set the value to res
minute
: get the current minute and set the value to res
hour
: get the current hour and set the value to res
day
: get the current day and set the value to res
month
: get the current month and set the value to res
year
: get the current year and set the value to res
random {low},{high}
: sets res
to a random number on interval [low, high]
wait {time}
: wait for the specified amount of time in seconds
clear
: clears the console
push {a},{b},...
: push the given values to the deque
pop
: pop the value at deque and set the value to res
unshift {a},{b},...
: enqueue the given values to the deque
shift
: dequeue the value at deque and set the value to res
[...]
means a sequence of characters, while {...}
means a sequence of characters that can use curly brackets.