diff options
Diffstat (limited to 'Sencha-lang/Examples')
-rw-r--r-- | Sencha-lang/Examples/example7.se | 14 | ||||
-rw-r--r-- | Sencha-lang/Examples/example8.se | 60 | ||||
-rw-r--r-- | Sencha-lang/Examples/example9.se | 9 |
3 files changed, 83 insertions, 0 deletions
diff --git a/Sencha-lang/Examples/example7.se b/Sencha-lang/Examples/example7.se new file mode 100644 index 0000000..f3a46f3 --- /dev/null +++ b/Sencha-lang/Examples/example7.se @@ -0,0 +1,14 @@ +println("I start program by assigning 0 to x"); +x = 0; +println("Then I declare a table, which is not obligatory"); +array t[100]; +println("After that I fill the table like that:"); +while (x < 100) +{ + print("Index: ", x); + t[x] = 3*x; + println(", value: ", t[x]); + x = x + 1; +} + +println("Pretty simple isn't it?");
\ No newline at end of file diff --git a/Sencha-lang/Examples/example8.se b/Sencha-lang/Examples/example8.se new file mode 100644 index 0000000..9274d14 --- /dev/null +++ b/Sencha-lang/Examples/example8.se @@ -0,0 +1,60 @@ +println("Some string manipulation"); + +text = "When I was young, everything was simpler."; + +println("Our text looks like that:"); +println(text); + +x = 0; +while(x < 4) +{ + print(text[x]); + x = x +1; +} + +print("\n"); + +println("We can replace some content of the text, for example \" whatever \" "); + +println("But first, let's try some simple replacement!"); + +text[5] = "M"; +text[3] = "K"; + +println("Now text is: ", text); + +println("Let's define some useful functions for us:"); + +def slice(text, from, to) +{ + bit = ""; + i = from; + while(i < to) + { + bit = bit + text[i]; + i = i + 1; + } + return bit; +} + +println("We defined slice, let\'s try it now!"); + +println(slice(text, 0, 8)); + +println("And some more: ", slice(text, 9, 14)); + +println("Sweet!"); +println("What about replace function?"); + +def replace(text, replacement, start_position, end_position) +{ + prefix = slice(text, 0, start_position); + suffix = slice(text, end_position, len(text)); + result = prefix + replacement + suffix; + return result; +} + +println("It looks pretty simple. Lets replace some text!"); + +println("Original: ", text); +println("After replacement: ", replace(text, "nice", 11, 16));
\ No newline at end of file diff --git a/Sencha-lang/Examples/example9.se b/Sencha-lang/Examples/example9.se new file mode 100644 index 0000000..396871e --- /dev/null +++ b/Sencha-lang/Examples/example9.se @@ -0,0 +1,9 @@ +#some comment +println("x = "); +x = 99; +println(x); +#another comment +println(" - Shouldn't comments be useful?"); #why? + +#If not, what's the point in writing them? +println(" - Aren't they?");
\ No newline at end of file |