-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.scri
70 lines (57 loc) · 1.13 KB
/
test.scri
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
66
67
68
69
70
# Variable declaration and assignment
int foo = 21;
foo = foo * 2;
# Short form operators
int i = 10;
i += 2;
printLn(i);
i -= 2;
printLn(i);
i *= 4;
printLn(i);
i /= 2;
printLn(i);
# Working with strings
str s = "hello ";
s += "world";
printLn(s);
# # Declare a object
# obj exampleObj = {
# x: 30,
# y: null,
# z: false,
# bar: foo,
# foo: foo,
# };
# # Add a new property to an object
# exampleObj.y = 43;
# printLn(exampleObj.y);
# # Assign another value to an existing object property
# exampleObj.x = 42;
# # Get object properties
# int prop = exampleObj.x;
# printLn(prop);
# printLn(exampleObj.x);
# Native functions
printLn(foo, 13);
str userInput = input("Please enter some text:");
printLn("Given input: '" + userInput + "'");
printLn("Sleeping for five seconds...");
sleep(5);
# User defined functions
func add(int a, int b) void {
int result = a + b;
printLn(result);
}
add(1, 2);
func sub(int a, int b) void {
int result = 0;
result = a + b - 2 * b;
printLn(result);
}
sub(6, 4);
func addWithReturn(int a, int b) int {
int result = a + b;
return result;
}
printLn(addWithReturn(10, 11));