From e96778a7c73575d83e25aeabeedf5c9808c93740 Mon Sep 17 00:00:00 2001 From: niansa Date: Fri, 10 Apr 2020 16:23:58 +0200 Subject: [PATCH] Added more examples --- examples/gettest.pil | 27 +++++++++++++++++++++++++++ examples/guessinggame.pil | 31 +++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 examples/gettest.pil create mode 100644 examples/guessinggame.pil diff --git a/examples/gettest.pil b/examples/gettest.pil new file mode 100644 index 0000000..0726c38 --- /dev/null +++ b/examples/gettest.pil @@ -0,0 +1,27 @@ +#This file is part of pilang. +# +#pilang is free software: you can redistribute it and/or modify +#it under the terms of the GNU General Public License as published by +#the Free Software Foundation, either version 3 of the License, or +#(at your option) any later version. +# +#pilang is distributed in the hope that it will be useful, +#but WITHOUT ANY WARRANTY; without even the implied warranty of +#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +#GNU General Public License for more details. +# +#You should have received a copy of the GNU General Public License +#along with pilang. If not, see . + +catch True +set userin,$input "Type in something: " + +set charnum,0 +marker set,printloop + sleep 0.1 + printnnl $get "$~userin,$~charnum" + inc charnum + cmp bigger,$len $~userin,$~charnum,"marker goto,printloop" + +print +marker goto,start diff --git a/examples/guessinggame.pil b/examples/guessinggame.pil new file mode 100644 index 0000000..bb8fa9c --- /dev/null +++ b/examples/guessinggame.pil @@ -0,0 +1,31 @@ +#This file is part of pilang. +# +#pilang is free software: you can redistribute it and/or modify +#it under the terms of the GNU General Public License as published by +#the Free Software Foundation, either version 3 of the License, or +#(at your option) any later version. +# +#pilang is distributed in the hope that it will be useful, +#but WITHOUT ANY WARRANTY; without even the implied warranty of +#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +#GNU General Public License for more details. +# +#You should have received a copy of the GNU General Public License +#along with pilang. If not, see . + +catch true +set number,4 + +print "Guess the first number..." +marker set,mainloop + set guess,$input "Guess a number: " + cmp equal,$~guess,,"marker goto,mainloop" + cmp isnotnum,$~guess,0,"print That's not a number. Retry with a number!","marker goto,mainloop" + cmp bigger,$~guess,$~number,"print Retry with a lower number!","marker goto,mainloop" + cmp smaller,$~guess,$~number,"print Retry with a higher number!","marker goto,mainloop" + +print "You guessed it! It's ",$~number,! +print "Now guess another number..." + +set number,$add "asint,$~number,7" +marker goto,mainloop