You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
kvirc/doc/scriptexamples/newkvstest.kvs

102 lines
1.3 KiB

# 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;
}