summaryrefslogtreecommitdiffstats
path: root/doc/scriptexamples/newkvstest.kvs
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-02-24 02:13:59 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-02-24 02:13:59 +0000
commita6d58bb6052ac8cb01805a48c4ad2f129126116f (patch)
treedd867a099fcbb263a8009a9fb22695b87855dad6 /doc/scriptexamples/newkvstest.kvs
downloadkvirc-a6d58bb6052ac8cb01805a48c4ad2f129126116f.tar.gz
kvirc-a6d58bb6052ac8cb01805a48c4ad2f129126116f.zip
Added KDE3 version of kvirc
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/kvirc@1095341 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'doc/scriptexamples/newkvstest.kvs')
-rw-r--r--doc/scriptexamples/newkvstest.kvs101
1 files changed, 101 insertions, 0 deletions
diff --git a/doc/scriptexamples/newkvstest.kvs b/doc/scriptexamples/newkvstest.kvs
new file mode 100644
index 00000000..0fe06a25
--- /dev/null
+++ b/doc/scriptexamples/newkvstest.kvs
@@ -0,0 +1,101 @@
+# This file contains test code for the new KVS parser
+# It does nothing useful
+
+
+echo "Foreach test 1"
+
+%arry[0] = "test0"
+%arry[2] = "test2"
+
+%i = 0
+
+foreach(%x,%arry)
+{
+ echo "Array item %i: (%x)"
+ %i++
+}
+
+echo "Foreach test 2"
+
+%ahash{"keyA"} = "dataA"
+%ahash{"keyB"} = "dataB"
+
+%i = 0
+
+foreach(%x,%ahash)
+{
+ echo "Hash item %i: (%x)"
+ %i++
+}
+
+echo "Foreach test 3"
+
+%i = 0
+
+foreach(%x,$keys(%ahash))
+{
+ echo "Hash entry %i: key->(%x), item->(%ahash{%x})"
+ %i++
+}
+
+echo "Foreach test 4"
+
+%i = 0
+
+foreach(%x,%arry,$keys(%ahash))
+{
+ echo "Item %i: %x"
+ %i++
+}
+
+
+%tmp = 1
+switch(%tmp)
+{
+ case(1):
+ echo \%tmp was 1!
+ break;
+ case(2)
+ echo \%tmp was 2!
+ break;
+ default:
+ echo \%tmp was not 1 nor 2: it was %tmp!
+ break;
+}
+
+%tmp = 1
+switch(%tmp)
+{
+ case(1):
+ echo \%tmp was 1!
+ case(2)
+ echo \%tmp was 2!
+ break;
+ default:
+ echo \%tmp was either 1 or something different from 2 (%tmp)
+ break;
+}
+
+%tmp = "This is a test"
+%tmp2 = "This is not a test"
+switch(%tmp)
+{
+ case(%tmp2)
+ echo \%tmp == \%tmp2
+ break;
+ case(%tmp)
+ {
+ # do not break here
+ echo "Yeah.. it's stupid.. \%tmp == \%tmp :D"
+ }
+ match("*TEST"):
+ echo "Matched *TEST"
+ regexp("[a-zA-Z ]*test"):
+ echo "Matched [a-zA-Z ]*text"
+ regexp("[a-zA-Z ]*not[a-zA-Z ]*"):
+ echo "Matched [a-zA-Z ]*not[a-zA-Z ]*"
+ default:
+ echo This is executed anyway (unless some break was called)
+ break;
+}
+