[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

LOGO-L> A Pattern Logo tool for K to 2/3



Hello Logophiles

Here is my Pattern Logo recently converted to run in (MSW)Logo.
I used a less user-friendly version of this program very successfully with
Yr 1 & 2 boys at Scotch College, here in Perth, West Australia for several.

This version has substantial error trapping and is designed to accept input
with or without spaces.

Instructions can be found in the "AAA" procedure which automatically
appears with the setup window when you load the program.

I am working on making an easy print feature which I'll send later.

Please enjoy and let me know of any bugs you find.
to A
; draw right arc
	rt 7.5
	repeat 6[fd (4 * :size * (sin 7.5)) rt 15 wait :speed]
	lt 7.5
end

to aaa
;;
;;  Pattern Logo: see the bottom of this message for brief instructions.
;;
;;  Developed for young children for keyboard skills, early Logo concepts,
;;  and as a mathematics pattern activity using repetitive codes
;;
;;  Copyright (C) 1998  by Paul Dench
;;  e-mail: paul.dench@bigpond.com
;;
;;  This program 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 2
;;  of the License, or (at your option) any later version.
;;
;;  This program 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 this program; if not, write to the Free Software
;;  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
;;
;;  INSTRUCTIONS
;;
;;  At the top lefthand corner of the screen you will see the startup menu
;;  which will set values for the current session.
;;
;;  You can set Step Size from 10 to 40 and the drawing Speed to slow, medium or fast.
;;  Beginning users for slow or medium can see their instructions develop slowly
;;  and see from the Action Report Window which code step and cycle is being drawn.
;;  
;;  The Turn Angle default is set to 30 degrees with additional choices of 45, 60,
;;  90, and 120 degrees. The 30 degree choice enables either a cartesian or a
;;  isometric structure with 'RRR' giving 90 degree turns and 'RR' 60 degree turns.
;;  It also allows more variation when the 30 degree angle turn is chosen.
;;
;;  The 'Enable Keys' button allows the teacher to choose a subset of keys for
;;  the current session or 'ALL' the keys.
;;
;;  F, B, R, L, U, D, E, H, C, and G perform familiar Logo commands such as
;;  FD, BK, RT, LT, PU, PD, PE etc.
;;
;;  A (right arc), J (left arc), K(ite), M(oon), O, P, Q, S, T, V, W, X, Y, and Z
;;  draw shapes readily associated with each letter,
;;
;;  N is used for a NEW start i.e the next child to use the teacher settings.
;;  I is the only letter currently unassigned. I'm open to suggestions for 'I'.
;;
;;  You will note a 'Current State' window at the top of the screen which
;;  reports the 'Pen' state and the selected 'Turn Angle'

end

to actionReportWinCreate
; reports current action

	if equalp "true :ActionReportWinUp? [stop]

	windowcreate "main "actionReportWin [Action] 10 10 120 80 []

	staticcreate "actionReportWin "how1St (se [Your pattern is:] :pattern) 5 5 110 10
	staticcreate "actionReportWin "how2St (se "repeating :repeats "times) 25 20 80 10
	staticcreate "actionReportWin "how3St~
			(se [Now doing step] :count "> :nextstep) 20 35 75 10
	staticcreate "actionReportWin "how4St~
			(se [in repeat] repcount) 35 50 70 10
	
	make "ActionReportWinUp? "true

end	

to B
; draw a unit backwards
	repeat 10[bk :size/10 wait :speed]
end

to C
; clear screen
	cs
end

to checkPattern
;strips out illegal characters
	
	make "repeats 1
	if numberp first :pattern~
			[make "repeats first :pattern make "pattern bf :pattern]
	localmake "count 1
	localmake "purged "
	until [:count>(count :pattern)]~
			[localmake "nextstep item :count :pattern~
			if memberp :nextstep :keyset~
				[make "purged word :purged :nextstep]~
					make "count :count + 1]
	make "pattern :purged

end

to compressPattern
;converts sentence to word
	
	localmake "count 1
	localmake "compress "
	until [:count>(count :pattern)]~
			[localmake "compress word :compress item :count :pattern~
					make "count :count + 1]
	make "pattern :compress

end

to D
; pendown
	pd ppt
	penstate "down
end

to E
; pen erase
	pe
	penstate "erase
end

to exitProc
; called by 'Esc' key

	;; close any open window
	if equalp "true :SetupWinUp? [windowdelete "setupWin]
	if equalp "true :SetKeysWinUp? [windowdelete "setKeysWin]
	if equalp "true :ActionReportWinUp? [windowdelete "actionReportWin~
							make "ActionReportWinUp? "false]
	if equalp "true :PenstateWinUp? [windowdelete "penstateWin~
							make "PenstateWinUp? "false] 
	cs
end

to F
; forward a unit
	repeat 10 [fd :size/10 wait :speed]
end

to G
; unit gap
	pu penstate "up
	F
	pd penstate "down
end

to getCode
; initiates patterninputs
	if :SetupWinUp? [windowdelete "setupWin make "SetupWinUp? "false]
	make "titleMessage [Pattern input]
	make "state [Enter your first pattern]
	inputPattern	
end

to H
; go 'Home'
	pu home pd
end

to inputPattern
; get pattern code	
	make "pattern questionbox :titleMessage :state
	if emptyp :pattern [inputPattern]
	compressPattern
	checkPattern
	repeat :repeats [unwrap :pattern]

	;setup next input
	make "titleMessage (se [That pattern was:] word :repeats :pattern)
	make "state (se [Enter your next pattern] ")
	inputPattern
end

to J
; left arc
	lt 7.5
	repeat 6[fd (4 * :size * (sin 7.5)) lt 15 wait :speed]
	rt 7.5
end

to K
; kite shape
	lt 30
	repeat 2 [ F F rt 60 F F rt 120]
	rt 30
end

to L
; turn left
	repeat :angle/5 [lt 5 wait :speed/2]
end

to M
; draw moon shape
	F F F F
	rt 90
	A A
	rt 90
end

to N
; a new start
	exitproc
	penstateWinCreate
	getCode
	
end

to O
; draw a circle
	rt 7.5
	repeat 24 [fd (4 * :size * (sin 7.5)) rt 15 wait :speed]
	lt 7.5
end

to P
; draw a petal shape
	lt 45
	repeat 2 [A rt 90]
	rt 45
end

to patterns
;
; Main Procedure. Start here!
;
	;;Close any open files
	if not emptyp allopen [foreach allopen [close ?]]

	cs
	;; Mark all windows as closed.
	make "SetupWinUp? "false
	make "SetKeysWinUp? "false
	make "ActionReportWinUp? "false
	make "PenstateWinUp? "false

	;;Setup user values
	penstateWinCreate
	setupWinCreate
	make "pattern []
	make "angle 30
	
end

to penstate :state
	staticupdate "stateSt (se [Pen is] :state)
end

to penstateWinCreate
; reports pen state

	if equalp "true :penstateWinUp? [stop]

	windowcreate "main "penstateWin [Current State] 200 0 55 35 []

	staticcreate "penstateWin "stateSt (se [Pen is] "down) 5 2 45 10
	staticcreate "penstateWin "turnAngleSt (se [Angle is] :angle) 5 12 45 10

	make "penstateWinUp? "true
end

to Q
; draw a quarter circle
	F F
	rt 90
	A
	rt 90
	F F
	rt 90
end

to R
; turn right
	repeat :angle/5 [rt 5 wait :speed/2]
end

to S
; draw a square
	repeat 4[fd :size*2 rt 90 wait :speed]
end

to setAngle
;; selects the default turn angle

	make "angle first listboxgetselect "angleList
	staticupdate "turnAngleSt (se [Angle is] :angle)
end

to setKeys
;; choose keys which will be recognised

	setKeysWinCreate
	make "keySet rl
	if equalp "ALL first :keyset [make "keyset :fullset]
	windowdelete "setKeysWin make "SetKeysWinUp? "false
end

to setKeysWinCreate
; choose keys to be enabled

	if equalp "true :SetKeysWinUp? [stop]

	windowcreate "main "setKeysWin [Enable Keys] 200 50 220 70 []

	staticcreate "setKeysWin "how1St [Type the keys you wish to make available from the set:] 5 5 200 10 
	staticcreate "setKeysWin "how2St ["A B C D E F G H J K L M N O P Q R S T U V W X Y Z" ] 5 15 200 10
	staticcreate "setKeysWin "how3St [Type a SPACE between each letter] 5 25 140 10
	staticcreate "setKeysWin "how4St [Enter ALL if you wish to make the full set available] 5 40 200 10

	make "SetKeysWinUp? "true
end

to setSize
	make "size 10 * scrollbarget "sizeSb
	staticupdate "sizeSt (se [Step Size] :size)  
end

to setSpeed
	make "speed 12 - (4 * scrollbarget "speedSb)
	ifelse equalp :speed 0 [localmake "turtleSpeed "Fast]~
		[ifelse equalp :speed 4[localmake "turtleSpeed "Medium]~
						[localmake "turtleSpeed "Slow]]
	staticupdate "speedSt (se :turtleSpeed "speed) 
end

to setupWinCreate
; setup user values

	if equalp "true :SetupWinUp? [stop]

	windowcreate "main "setupWin [Choose Setup Values] 5 0 85 185 []

	groupboxcreate "setupWin "valuesGb 5 5 70 142
	staticcreate "setupWin "values [Setup] 30 5 20 10 

	staticcreate "setupWin "sizeSt [Step Size 20] 10 15 50 10
	scrollbarcreate "setupWin "sizeSb 10 25 60 10 [setSize]
	scrollbarset "sizeSb 1 4 2

	;Turn Angle selection
	listboxcreate "setupWin "angleList 10 45 20 50
	listboxaddstring "angleList [30]
	listboxaddstring "angleList [45]
	listboxaddstring "angleList [60]
	listboxaddstring "angleList [90]
	listboxaddstring "angleList [120]
	staticcreate "setupWin "angle1St [Select angle] 33 50 40 10
	staticcreate "setupWin "angle2St [THEN] 41 60 20 10
	buttoncreate "setupWin "setTurnAngle [Set it] 38 70 25 15 [setAngle]

	staticcreate "setupWin "speedSt [Slow speed] 10 100 50 10
	scrollbarcreate "setupWin "speedSb 10 110 60 10 [setSpeed]
	scrollbarset "speedSb 1 3 2

	buttoncreate "setupWin [setKeysToUse] [Enable Keys] 15 130 50 10 [setKeys]

	buttoncreate "setupWin [finishSetup] [Finish setup] 15 155 50 10 [getCode]

	make "SetupWinUp? "true

end

to T
; draw a triangle
	repeat 3[fd :size*2 rt 120 wait :speed]
end

to takeAction
	if :speed > 0 [actionReportWinCreate]
	run :nextstep
	if :ActionReportWinUp? [windowdelete "actionReportWin~
						make "ActionReportWinUp? "false]
end

to U
; pen up
	pu
	penstate "up
end

to unwrap :inputs
; reads the pattern letter by letter and acts on it

	if emptyp :inputs [stop]
	localmake "count 1
	until [:count>(count :pattern)][localmake "nextstep item :count :pattern~
							takeAction make "count :count + 1]
	ifelse (or (:repeats > 1) ((count :pattern) = 1))~
					[stop][ifelse yesnobox[Question]~
						(se "draw "\" :pattern "\" "AGAIN?)~
								[unwrap :inputs][stop]]	
end

to V
; draw a V shape
	lt 30
	F B
	rt 60
	F B
	lt 30
end

to W
; draw a wave shape
	A A J J
end

to X
; draw a star shape
	rt 22.5
	repeat 8[F B rt 45]
	lt 22.5
end

to Y
; draw a Y shape
	F
	V
end

to Z
; draw a zigzag shape
	F
	rt 120
	F
	lt 120
	F
end

Make "actionreportwinup? "false
Make "angle 30
Make "fullset [A B C D E F G H J K L M N O P Q R S T U V W X Y Z]
Make "keyset [A B C D E F G H J K L M N O P Q R S T U V W X Y Z]
Make "pattern []
Make "penstatewinup? "false
Make "repeats 1
Make "setkeyswinup? "false
Make "setupwinup? "true
Make "size 20
Make "speed 4
Make "startup [patterns ed "aaa]
Make "state [Enter your next pattern]
Make "titlemessage [That pattern was:]

Paul Dench


Global SchoolNet Foundation - Linking Kids Around the World!
Copyright GSN - All Rights Reserved - Comments & Questions
Visit GSN's Global Schoolhouse for more exciting learning resources!
Search our Site - Home