please dont rip this site

HOW TO PROGRAM IN CYLOGO


CyLogo.app (load CyLogo.app to your CyBiko with the CyBiko Console)

CyLogo Main Page
CyLogo Examples

Variables

CyLogo Screen is a field for entering CyLogo operators. Result of the program is a picture. It may be a line or a curve, open or closed, or an image. Usually you draw with a pen or a pencil. In CyLogo the drawing tool is a turtle. It draws a line with its tail.

There is a virtual rectangular coordinate system in the screen: axis X is a horizontal one with a positive direction to the right; axis Y is vertical with a positive direction up. The turtle can turn around its tail for any angle to the left (anti-clockwise) or to the right (clockwise). The positive direction for angle is to the left (anti-clockwise). So at any time the location of the turtle (more precisely, of its tail) is defined as a set of three variables: X, Y and ANGLE. X=1 means X=1 pixel. Y=1 means Y=1 pixel. ANGLE=1 means ANGLE =1 degree.

In the initial position the turtle is in the center of the screen and turns to the right. Its coordinates are X=0, Y=0, ANGLE=0.

The screen has size 160x85 pixels. The turtle is on the screen if its current coordinates satisfy the conditions -80<X<79, -42<Y<42. Otherwise, the turtle is beyond the bounds of the screen. It is not an error. It just means that you cannot see it on the screen.

Besides variables X, Y and ANGLE you can also use the variable KEY. This variable takes on just determined values. You will find the list of possible values below:

Action = pressing the key Value of the variable KEY

Left Arrow

264

Up Arrow

265

Right Arrow

266

Down Arrow

267

Ins

268

Del

269

Tab

270

Select

271

Enter

272

Backspace

273

Shift

275

Fn

276

Space

32

0

48

1

49

2

50

3

51

4

52

5

53

6

54

7

55

8

56

9

57

Quote

39

,

44

-

45

.

46

/

47

;

59

\

92

=

61

(

91

)

93

Back quote

96

A

97

B

98

C

99

D

100

E

101

F

102

G

103

H

104

I

105

J

106

K

107

L

108

M

109

N

110

O

111

P

112

Q

113

R

114

S

115

T

116

U

117

V

118

W

119

X

120

Y

121

Z

122


You can also create your own variable. It may consist of letters, figures and a sign “_”, begin with a letter and not exceed 19 symbols. The total quantity of such variables cannot be more than 30.

Operators

To create a program in CyLogo you may use the following operators:

Penup: - the turtle ups its tail. It means that all the next turtle movements will not be shown at the screen, but the turtle itself will be in its current position.

Pendown; - the turtle lowers its tail and all its next movements will be shown with a black color at the screen. (This operator abolishes the operator Penup;.)

Pendown N; - the turtle lowers its tail and all its next movements will be shown with one of the next four colors: N=0 – white, N=1 – light gray, N=2 – dark gray, N=3 – black.

Hide; - The turtle hides. Drawing goes on without turtle.

Show; - The turtle shows again.

Note: As defaults the operators Pendown; and Show are set;

Left; - the turtle turns for 90 degrees to the left (anti-clockwise).

Left N; - the turtle turns for N degrees. If N is a positive value then it rotates to the left (anti-clockwise), if N is a negative one then it does to the right (clockwise). For example, Left 63; means that the turtle will turn for 63 degrees to the left.

Right; - the turtle turns for 90 degrees to the right (clockwise).

Right N; - the turtle turns for N degrees. If N is a positive value then it rotates to the right (clockwise), if N is a negative one then it does to the left (anti-clockwise). For example, Right -10; means that the turtle will turn for 10 degrees to the left.

Forward; - the turtle moves forward and draws a straight line with length 10 pixels.

Forward N; - the turtle moves and draws a straight line with length N pixels. It moves forward if N is a positive value and back if it is a negative one.

Back; the turtle moves back and draws a straight line with length 10 pixels.

Back N; - the turtle moves and draws a straight line with length N pixels. It moves back if N is a positive value and forward if it is a negative one.

Moveto X,Y; - the turtle move to the position X,Y not changing current ANGLE.

If <expression> <operator>;

or

If <expression> { <operator1>;

<operator2>;

} - is a conditional operator. This means if the expression is met then the program will execute these operators. Otherwise it will move to the next operator.

While <expression> { <operator1>;

<operator2>;

} - is a conditional operator. It means while the expression is met, then the program of these operators will be executed. Otherwise it will move to the next operator.

Beep N; - It makes a N-sound. There are seven different sounds.

Beep without N is equal to Beep 1. Beep 0 makes no sound.

Wait N; - It is a pause before the next operator executing for N tenths of a second.

Wait without N is equal to Wait 10.

Clear N; - fills a screen with one of the next four colors: N=0 – white, N=1 – light gray, N=2 – dark gray, N=3 – black. Clear without N is equal to Clear 0.

Important: You should keep in mind the following rules while entering the CyLogo operators:

  1. You may type operators and variables in small or capital letters - it doesn't matter.
  2. All operators need the mark ";" at the end. Any notes or symbols after mark ";" are understood as comments and therefore will not be executed. So comments may be written at the new line and begin with ";".
  3. Each operator is typed in a new line.
  4. You may use the following operations in expressions: or, and, >, >=, <, <=, =, <>, +, -, *, /, (, ),
  5. You may use the following functions in the programs: sin, cos, tg, sgrt. F.e., I=sin (x+5); Arguments of the functions should be enclosed in brackets.
  6. In each operator you should separate the text part from the parameter by any space.
  7. The value of variable must be greater than -–20000.000 and less than 20000.000. The value of the variable ANGLE must be greater than 0 and less than 360 not including it.
  8. The value of expression must be greater than –32767.000 and less than 32767.000.
  9. The spacer of fractional part in a number is a point.
  10. The maximum number of nested brackets is 6.
  11. The maximum number of nested cycles is 30.

CyLogo Main Page
CyLogo Examples


file: /Techref/cybiko/cylogo.htm, 17KB, , updated: 2008/6/13 17:16, local time: 2024/12/27 01:50,
TOP NEW HELP FIND: 
3.17.181.181:LOG IN

 ©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE!

<A HREF="http://massmind.org/Techref/cybiko/cylogo.htm"> Programming in CyLogo</A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type a nice message (short messages are blocked as spam) in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.


Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?

 

Welcome to massmind.org!

 

Welcome to massmind.org!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .