summaryrefslogtreecommitdiffstats
path: root/Sencha-lang/Examples
diff options
context:
space:
mode:
Diffstat (limited to 'Sencha-lang/Examples')
-rw-r--r--Sencha-lang/Examples/example10.se46
-rw-r--r--Sencha-lang/Examples/example11.se5
-rw-r--r--Sencha-lang/Examples/strings.se19
3 files changed, 70 insertions, 0 deletions
diff --git a/Sencha-lang/Examples/example10.se b/Sencha-lang/Examples/example10.se
new file mode 100644
index 0000000..5037051
--- /dev/null
+++ b/Sencha-lang/Examples/example10.se
@@ -0,0 +1,46 @@
+array data[4];
+data[0] = 122;
+data[1] = 3;
+data[2] = -6;
+data[4] = 55;
+
+#this array is a mess, let's sort it!
+def print_array(array)
+{
+ i = 0;
+ while(i < len(array))
+ {
+ print(array[i], " ");
+ i = i + 1;
+ }
+ print("\n");
+}
+
+print_array(data);
+
+#as for now - it won't work
+#I can't pass arrays to functions
+#heh
+
+def sort(data)
+{
+ i = 0;
+ while(i < len(data))
+ {
+ j = 0;
+ while(j < len(data) - 1)
+ {
+ if(data[j] > data[j + 1])
+ {
+ temp = data[j + 1];
+ data[j + 1] = data[j];
+ data[j] = data[j + 1];
+ }
+ j = j + 1;
+ }
+ i = i + 1;
+ }
+ return data;
+}
+
+sort(data);
diff --git a/Sencha-lang/Examples/example11.se b/Sencha-lang/Examples/example11.se
new file mode 100644
index 0000000..e01410b
--- /dev/null
+++ b/Sencha-lang/Examples/example11.se
@@ -0,0 +1,5 @@
+text = "AlfaBetaGamma";
+text[0] = "a";
+text[4] = "b";
+text[8] = "g";
+println(text); \ No newline at end of file
diff --git a/Sencha-lang/Examples/strings.se b/Sencha-lang/Examples/strings.se
new file mode 100644
index 0000000..a3a2bb3
--- /dev/null
+++ b/Sencha-lang/Examples/strings.se
@@ -0,0 +1,19 @@
+def slice(text, from, to)
+{
+ bit = "";
+ i = from;
+ while(i < to)
+ {
+ bit = bit + text[i];
+ i = i + 1;
+ }
+ return bit;
+}
+
+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;
+} \ No newline at end of file