Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# cat-disruptor-6500
A Discord bot that reacts to certain messages with certain emojis. More importantly, it also lets you write code!
## Commands:
!START - start the interpreter
!STOP - stop the interpreter
LIST - list all code in memory
SAVE filename - save code into database
LOAD filename - load filename into memory
Code is specified by writing `line_num code`. For example, `10 print "hello world"`. This makes it easy to insert new code or overwrite lines.
### Example session
```
!START
10 for x in 0 to 10
20 print x
RUN
> expected NEXT after FOR statement. # oops - we forgot a line
30 next x
LIST
> 10 for x in 0 to 10
> 20 print x
> 30 next x
RUN
> 0
> 1
> 2
> 3
> 4
> 5
> 6
> 7
> 8
> 9
> 10
# actually, let's print them all on the same line
5 a = ""
20 a += x
LIST
> 5 a = ""
> 10 for x in 0 to 10
> 20 a += x
> 30 next x
RUN
012345678910 # oops - let's add spaces
20 a += " " + x
RUN
> 0 1 2 3 4 5 6 7 8 9 10 # awesome! let's save this program
SAVE count_to_ten
> Saved as count_to_ten
```
The interpreter can execute arbitrary code safely - it includes CPU and memory limits. For information on syntax, check out the xBASIC interpreter: https://git.scd31.com/stephen/xbasic
It even does graphics!
