Professional Documents
Culture Documents
Turtle Inc.
March 4, 2016
Authored by: Turtle
Simply use a text editor and type your code in. Then open the Pencil compiler or interpreter
and enter the pathname and click compile. A .penc file will be generated in compiled version
while in interpreted version it simply executes the code except that it does more complex error
checking. Afterwards, you can package the .penc file into an exe if you wish with Pencil
packager. You can download and install libraries from the Pencil repository using Pencil package
manager. Updater and IDE are still in development.
Important: Packager, package manager and interpreter are only starting in Alpha 0.8.
Changelog
Pencil 0.8 Alpha: Implemented main syntax. Solved pre-Alpha bugs.
Licences
Pencil cannot be resold or redistributed without permission. All programs made with Pencil are
under the GPLv2 License and cannot be sold. Pencil is made only using free software.
Copyright 2016 Turtle Inc.
Commands
Base Commands 55 Commands
These are commands that do not require any library. Variables are defined like this:
ABC:=abc; //Variable name followed by := then the value + ; behind.
Number
Command
Definition
Input/Output
Example
finally
Finally
statement
behind except.
Except
statement
behind try.
Commands
to
run finally after
except.
Commands
to
run once try
encounters an
error.
Import or include Library name.
library. If library
in
Pencil
distribution, use
library. Else you
must
specify
library path.
Repeat
Number of times
statement
to repeat. What
certain number to repeat.
of times.
2.
except
3.
import
4.
repeat
5.
elseif
6.
forval
7.
turtle
Turtle library
8.
while
While loop.
9.
10.
11.
break
false
array
None
Statement
sastify.
Escape from loop None
Set to false.
None
Array library
None
to
try[]
except[]
finally:
try[]
except[]
import:turtle;
repeat[(4)]
<turtle.po
inter.("turtle")>
<turtle.st
amp.()>
<turtle.fo
rward.(100)>
;
if:
elseif:
elseif:
else:
repeat[(4)]
<turtle.po
inter.("turtle")>
<turtle.st
amp.()>
<turtle.fo
rward.(forval)>
;
<turtle.forward.(
90);>
while[1===1]
<break>
array.append(AR
1.
12.
13.
file
else
File library
Else statement
None
None
14.
func
Function
definition.
Parameters.
15.
16.
17.
18.
19.
true
and
=!=
===
=>=
20.
=<=
21.
22.
not
try
Set to true.
None
This and that.
None.
Not equals
None
Equals
None
More than or None
equals
Less than or None
equals
Not this.
None.
Test if works.
Code to test.
23.
24.
25.
26.
27.
28.
29.
30.
for
+=
-=
*=
/=
++
-/*
31.
*/
32.
if
33.
34.
35.
36.
or
>>
<<
//
37.
38.
(
)
For loop.
+= operator
-= operator
*= operator
/= operator
Increment
Decrement
Opening
multiline
comment
Closing multiline
comment
If else statement
RAY, a)
file.open(FILE)
if[]
else[]
func[text()]
<turtle.te
xt.("click")>
;
while[true]
if[1>2 and 2>3]
1=!=2
1===1
1=>=1
1=<=1
Code to repeat
None
None
None
None
None
None
None
not a
try[]
except[]
N/A
VAR+=90;
VAR-=90;
VAR*=90;
VAR+/=90;
VAR++
VAR-/*excluded*/
None
/*excluded*/
+
*
/
^
Plus operator
Minus operator
Times operator
Divide operator
Exponent
operator
Used in multiline
statements
to
separate code.
44.
45.
Used in multiline
statements
to
separate code.
46.
47.
48.
<
49.
>
50.
51.
52.
53.
<tab>
54.
<space>
55.
<newline>
List or string
indexing or list
comprehension.
List or string
indexing or list
comprehension.
Opening of any
single
line
statement.
Closing of any
single
line
statement.
Used to separate
parameters.
Ends
the
statement.
Separates import
from library.
Tab character.
Ignored.
Space character.
Ignored.
New line.
Ignored.
None
None
None
None
None
None.
None.
None.
1+1
1-1
1*1
1/1
3^7
func[text()]
<turtle.te
xt.("click")>
;
func[text()]
<turtle.te
xt.("click")>
;
List={a,b,1};
<List{2}>;
//
returns 1
List={a,b,1};
<List{2}>;
//
returns 1
<turtle.forward.(
100)>;
None.
<turtle.forward.(
100)>;
None.
None.
turtle.keypress.(t
urtle.exit., "x")
ABC:=abc;
None.
import:file;
None.
N/A
None.
N/A
None.
N/A
39.
40.
41
42.
43.
Number
Function/Method Definition
Input/Output
Example
1.
clear
None
turtle.clear.()
2.
circle
3.
stamp
4.
zeropos
5.
location
6.
forward
7.
backward
8.
right
9.
left
10.
11.
stop
start
12.
thickness
13.
color
14.
fill
turtle.stamp.()
None
turtle.zeropos.()
None
turtle.location.()
Steps to move
the pen forward
in numbers
Move the pen Steps to move
backward
the
pen
backward
in
numbers
Turn the pen Degrees to turn
right by degrees the
pen
in
numbers
Turn the pen left Degrees to turn
by degrees
the
pen
in
numbers
Stop drawing
None
Continue
None
drawing
Set the thickness The thickness of
of the pen
the
pen
in
numbers
Set the color of The color of the
the pen
pen
in
hexadecimal
with a # in front
Set the fill of the The color of the
turtle.forward.(1
00)
turtle.backward.(
10)
turtle.right.(90)
turtle.left.(180)
turtle.stop.()
turtle.start.()
turtle.thickness.(
9)
turtle.color.(#A
BCDEF)
turtle.fill.(#ABC
15.
pointer
16.
text
17.
goto
18.
setx
19.
sety
20.
getx
21.
gety
22.
setrot
23.
speed
24.
25.
26.
show
hide
tracer
27.
stpoly
28.
endpoly
29.
keypress
fill
in
hexadecimal
with a # in front
Set the shape of The shape of the
the pointer
pointer which is
classic,
arrow,
turtle,
square,
triangle, blank
Show text
The text to show
DEF)
turtle.pointer.(t
urtle)
turtle.text.(turtl
e)
Move
the X
coordinate turtle.goto.(10,1
pointer to a followed by Y 00)
specified
coordinate
location
separated
by
commas
Set the x position The X coordinate turtle.setx.(0)
of the pointer
Set the y position The Y coordinate turtle.sety.(10)
of the pointer
Get
the
x None
turtle.getx.
position of the
pointer
Get
the
y None
turtle.gety.()
position of the
pointer
Set the rotation The rotation of turtle.setrot.(90)
of the pointer
the pointer in
degrees
Set the moving 1 to 10 speed turtle.speed.(10)
speed of the values, 10 is the
pointer
fastest
Show the pointer None
turtle.show.()
Hide the pointer None
turtle.hide.()
Trigger
None
turtle.show.()
animation
Start recording None
turtle.stpoly.()
moves
Ends recording None
turtle.endpoly.()
moves
What to do Commands to do turtle.keypress.(t
when specified followed by key. urtle.exit., "x")
key is pressed.
(Implemented
shape
30.
click
31.
release
32.
bgimage
33.
bgcol
34.
35.
36.
screen
reset
undo
37.
wait
38.
39.
exit
dot
40.
mainloop
Commands
do.
to <turtle.click.(turt
le.goto.)>;
Commands
do.
to <turtle.release.(t
urtle.goto.)>;
Image path.
turtle.bgimage.(
C:\i.png)
Hexadecimal
color.
turtle.bgcol.(#A
BCDEF)
None.
None.
None.
turtle.screen.()
turtle.reset.()
turtle.undo.()
turtle.exit.()
turtle.dot.(10)
None.
turtle.mainloop.(
)
Function/Method Definition
1.
write
Input/Output
Example
2.
close
opened file.
Close a file.
to write.
File to close.
3.
open
Open a file.
4.
read
e, "abc")>;
<file.close.(myfil
e)>;
File to open.
myfile:=file.open
.("a", "w");
Opened file to <file.read.(myfile
read.
)>;
Number
Function/Method Definition
Input/Output
Example
1.
reverse
Array
<array.reverse.(
ARRAY)>;
2.
append
Array, element
3.
extend
4.
insert
5.
remove
<array.append.(A
RRAY, 4)>;
<array.extend.(A
RRAY, 4)>;
<array.insert.(AR
RAY, 4)>;
<array.remove.(
ARRAY, 4)>;
6.
index
7.
times
8.
sort
9.
pop
Reverse
the
elements in an
array.
Append a new
element.
Extend array to a
new element.
Insert a new
element
Remove
the
specified
element.
Get the index of
the element.
Get how many
times
the
element appears
in array.
Sort an array.
Pop the
element.
Array, element
Array, element
Array, element
Array, element
Array, element
Array
last Array
<array.index.(AR
RAY, 4)>;
<array.times.(AR
RAY, 4)>;
<array.sort.(ARR
AY)>;
<array.pop.(ARR
AY)>;
These are commands that require the math library. The math library supplies math functions.
Not yet implemented. Starts in Alpha.
TkInter Commands
These are commands that require the TkInter library. The TkInter library is a GUI library that
enables you to draw GUI elements. Not yet implemented. Starts in Alpha.
Gamelib Commands
These are commands that require the gamelib library. The gamelib library supplies functions to
easily make games. Not yet implemented. Starts in Alpha.
Syntax
Importation of libraries and definition of variables do not need to be enclosed in <>. Other
single line statements must be enclosed in <>. Long statements such as if else, repeat and func
statements must not be enclosed in <>. A librarys name followed by a dot must be in front of
its functions name, for example turtle.location.() and turtle.click.(turtle.goto). Function inputs
are in brackets behind the function and are separated by commas. All first level statements
must be separated by a ;. Variables and functions defined can be used throughout the
program but are encouraged to start with a capital letter or might cause serious problems.
Q&A + Problems
If you spot any errors or have any queries, do go to our Help desk @ ___ on our website to post
your question. Not yet implemented. Starts in Alpha.