header

 

More links

AutoHotkey | Android | Arduino | COMM140Fractals | Grammar Checkers | Knots | A Million Dots Activity |  Processing | Processing for Scratch Users | Redbubble | Tutorials | Weather | World Time Meeting Planner | Favicon Generator.

Home > MicroWorlds Logo Links & Examples > Elements of Programming MicroWorlds LOGO

Elements of Programming MicroWorlds LOGO

MicroWorlds LOGO

Logo programming language
From Wikipedia, the free encyclopedia.
http://en.wikipedia.org/wiki/Logo_programming_language


How to Think Like a Computer Scientist
http://ibiblio.org/obp/thinkCS/

Increment a counter Microworlds LOGO
October 29, 2004

increment2.mw2 20 KB
increment2.zip 11KB
increment2.exe 72KB

increment2 source code

Get MicroWorlds Web Player Plugin version
GNU License.txt

Published under the GNU GPL

Using a counter

make "counter 0              ; create the counter
                             ; & set its default value


make "counter :counter + 1   ; increment by 1

MicroWorlds Counter
September 4, 2004

counter.mw2 13 KB
counter.zip 2 KB
counter.exe 64 KB

Get MicroWorlds Web Player Plugin version
GNU License.txt

Published under the GNU GPL

Using a counter
to go
   make "x 0                
        ; define x
   make "stop_at (random 19) + 1    
; > 0 < 21
   cc
   show (word [The counter will stop at] char 32 :stop_at)

   ct                               ; clear text box
   repeat 50 [
      make "x :x + 1                ; increment x by 1
      print :x
      if :x = :stop_at [stop]
      wait 0.5
   ]
end

MicroWorlds Uning Sliders
November 3, 2003

sliders.zip 3KB Ziped with Winzip  from www.winzip.com use winzip to unzip

 

Playing with sliders

Demonstrates how to set sliders and how to use the value of sliders within a procedure. Also provides an example of turning on & off a button from with a procedure.


set "button3 "on? "false  ; turn off the button

This also creates a simple etch-a-sketch program using sliders to move the turtle around.

to move_turtle
   ;an etch-a-sketch program!
   setpensize pen_size
   setc colour
   sety y_pos
   setx x_pos
   pd
end

All that is required for the above etch-a-sketch to work are 4 sliders named:

pen_size       ; minimum value 1 maximum value 100
colour         ; minimum value 0 maximum value 9999
y_pos          ; mimimum value -200 maximum value 200
x_pos          ; mimimum value -300 maximum value 300

and a button with the instruction move_turtle set to Many Times

 

to test
   repeat 20 [
    show word "t random 8
    ]
end

test

t7
t0
t7
t3
t6
t5
t2
t7
t3
t0

MicroWorlds Check Boxes
November 8, 2003

check_boxes.zip 5KB Ziped with Winzip  from www.winzip.com
use winzip to unzip

Implementing Check Boxes in MicroWorlds

MicroWorlds Check Boxes

I must not ridicule the detention system
February 16, 2005

detention.mw2 19 KB
detention.zip 10 KB
detention.exe 72 KB

Published under the GNU GPL

to go
   make "counter 0
   ; define the value of the counter

   ; note if we start with counter at
   ; 0 then we get one more line
   ; than you may expect
   ; eg if :counter > 100 [ stop]
   ; will print 101 lines

   ct
   print (se "Starting "detention)
   do_detention
end

to do_detention
   ; every recursive function needs a stopping case    
   ; otherwise it will run forever.

   if :counter > 100 [
      print (se char 32 "I "have "finished "my "detention       "can "I "go "now "?)
      stop]

   print (se :counter "I "must "not "ridicule "the    "detention "system.)

   make "counter :counter + 1 ; count the lines
   do_detention               ; recursive call
end

if

if true-or-false list-to-run

Runs the instruction list only if the condition (first input) reports true.

Examples:

if colorunder = 15 [bk 50]
question [Are you ready?]
if answer = "yes [glide 100 5]

ifelse

ifelse true-or-false instruction-list1 instruction-list2

Runs the first instruction list if the condition is true. Runs the second instruction list if the condition is false.

Example:

ifelse colorunder = 15
[fd 50]
[bk 50]

This instruction can be used to get an answer to a question dialog box. If the answer is not empty, it is displayed in a text box.

to insist
question [Your name please...]

ifelse empty? answer
[insist]
[settext1 answer]
end

colorunder

Reports the color under the current turtle as a number. The portion of a turtle that recognizes a color is its center. Colorunder reports the background color as well as all the drawings.

Example:

t1, show colorunder

3

In a stop rule, always use the color number, not its name, to check the color under the turtle:

if colorunder = 15

[announce [You win!]]

Colorunder reports not only integers but also decimal numbers. Note that when MicroWorlds reports decimal numbers, it may report a slightly different number than the one expected. This is due to the recalculation of the RGB color.

setc 105.6

fill

show colorunder

105.4

setc 17.2

fill

show colorunder

17.1

Note: In order to use the full potential of MicroWorlds graphics, 16 bit color mode is recommended.

fill

Fills a closed shape or the whole screen with the turtle's color. Fill will work regardless of the turtle's pen state (up or down). See setc.
Example:

pd repeat 5 [fd 50 rt 72]

Drag the turtle inside the area.

setc "blue
fill

freezebg

Stands for freeze background. Freezes the background graphics in their current state. You can still draw over the background and erase the new drawings, but the background that was present before freezing won't be erased. See unfreezebg.
Example:

pd
rt 11 fd 5000
freezebg
lt 22 fd 5000
cg

mousepos

Stands for mouse position. Reports the page coordinates representing the current mouse position on the screen. See setpos.

Examples:

show mousepos
60 63

show first mousepos
60

If there is a turtle on the page, the turtle will follow the mouse.

t1,
pd
forever [setpos mousepos]

Choose the Cancel menu item, the Stop All menu item, or Ctrl+Break to stop this process.

Random

random number

Reports a random non-negative integer less than number.

Example:

show random 100

22

This procedure will simulate the roll of a die:

to die

show 1 + random 6

end

setinstrument

setinstrument name-or-number

Sets the instrument for the next note commands. There are 7 instrument names: piano, harpsichord vibraphone, guitar, violin, clarinet, and kalimba. You can also use any number from 1 to 128.

Examples:

setinstrument "violin

note 65 10

setinstrument 116

note 65 10

towards

towards turtle-name

Sets the heading of the current turtle to aim towards the one whose name is given as input. See distance.

Example:

t1,

towards "t2 T1 faces t2.
fd distance "t2 T1 meets t2.

   
   
   
   
   

APA citation:
Russell, R. (2016, July 04, 02:14 pm). Elements of programming microworlds logo.
     Retrieved December 23, 2024, from http://www.rupert.id.au/microworlds/programming.php


Last refreshed: December 23 2024. 06:16.01 am

rupert dot russell at acu dot edu dot au Support Wikipedia

Creative Commons License This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License.


1105 Visits since October 22, 2004