2Nmw2.0 Englishprojectsize[744 426]turtles-have[]globals[]globals-list[globals-vars]shapes[12 green_sq]((x !$'09BKT]fox[13 red_sq]((x !$'09BKT]foxxxxxxxxxxxxxxxxx[14 clear_sq](( !$'0?N]l{  #&)[15 ||](( !$'0?N]l{  #&)procedurestext{\rtf1\ansi\deff0\deftab720{\fonttbl{\f0\fswiss MS Sans Serif;}{\f1\froman\fcharset2 Symbol;}{\f2\fswiss\fprq2 System;}{\f3\fswiss Arial;}{\f4\fmodern\fprq1 Courier New;}{\f5\fswiss\fprq2 Arial;}{\f6\fswiss Arial;}} {\colortbl\red0\green0\blue0;\red0\green0\blue128;\red0\green128\blue128;\red0\green0\blue255;\red0\green128\blue0;\red255\green0\blue0;} \deflang1033\pard\plain\f4\fs20\cf2 ; Purpose: To demonstrate incrementing a counter. \par ; Copyright \plain\lang3081\f4\fs20\cf2 \'a9\plain\f4\fs20\cf2 2004 by Rupert Russell \par ; e-mail: r.russell@ballarat.edu.au \par ; URL: http://velorum.ballarat.edu.au/~rrussell/microworlds/ \par ; Created: October 29, 2004\plain\f4\fs20\cf1 \par \plain\f4\fs20\cf2 ; \par ; This program is free software; you can redistribute it and/or modify \par ; it under the terms of the GNU General Public License as published by \par ; the Free Software Foundation; either version 2 of the License, or \par ; (at your option) any later version. \par ; \par ; This program is distributed in the hope that it will be useful, \par ; but WITHOUT ANY WARRANTY; without even the implied warranty of \par ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the \par ; GNU General Public License for more details. \par ; \par ; You should have received a copy of the GNU General Public License \par ; along with this program; if not, write to the Free Software \par ; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. \par ; ---------------------------------------------------------------------\plain\f4\fs20\cf0 \par \plain\f4\fs20\b \par \plain\f6\fs20 \par \par \plain\f5\fs20\cf3\b to setup\plain\f5\fs20\cf0\b \par \plain\f5\fs20\cf0 make "counter 0\tab \tab \tab \plain\f5\fs20\cf2 \tab ; create the counter and set its initial value to 0\plain\f5\fs20\cf0 \par show_value_of_counter \par cg \par \plain\f5\fs20\cf3\b end \par \plain\f6\fs20\cf3 \par \plain\f5\fs20\cf3\b to increment\plain\f5\fs20\cf0\b \par \plain\f5\fs20\cf0 carefully [show_value_of_counter] [setup] \plain\f5\fs20\cf2 \tab ; check that the counter has been created \par \tab \tab \tab \tab \tab \tab ; if the counter has not been created then the \par \tab \tab \tab \tab \tab \tab ; command carefully will not cause an \par \tab \tab \tab \tab \tab \tab ; error but will run the procedure setup\plain\f5\fs20\cf0\b \par \plain\f5\fs20\cf0 cg \par if :counter < 10 [\tab \tab \tab \plain\f5\fs20\cf2 \tab ; if the current value of :counter \par \tab \tab \tab \tab \tab \tab ; is less than 10 then\plain\f5\fs20\cf0 \par \plain\f6\fs20\cf0 \plain\f5\fs20\cf0\b make "counter :counter + 1\plain\f6\fs20\cf0 \tab \plain\f5\fs20\cf2\b \tab ; increment the :counter by 1\plain\f6\fs20\cf3 \par \plain\f5\fs20\cf0 show_value_of_counter\tab \tab \plain\f5\fs20\cf2 \tab ; show the vale of the :counter\plain\f6\fs20\cf3 \par \plain\f6\fs20\cf0 ] \par stamp_turtles \par \plain\f5\fs20\cf3\b end \par \par to decrement\plain\f5\fs20\cf0\b \par \plain\f5\fs20\cf0 carefully [show_value_of_counter] [setup]\plain\f5\fs20\cf2 \tab ; check that the counter has been created \par \tab \tab \tab \tab \tab \tab ; if the counter has not been created then the \par \tab \tab \tab \tab \tab \tab ; command carefully will not cause an error \par \tab \tab \tab \tab \tab \tab ; but will run the procedure setup\plain\f5\fs20\cf0\b \par \par \plain\f5\fs20\cf0 if :counter > -10 [\plain\f6\fs20\cf0 \par \plain\f5\fs20\cf0\b make "counter :counter - 1 \tab \plain\f5\fs20\cf2\b \tab ; decrement the counter by 1\plain\f6\fs20\cf2 \par \plain\f6\fs20\cf0 ] \par \plain\f5\fs20\cf0 \par cg \par show_value_of_counter\plain\f6\fs20\cf3 \par \plain\f6\fs20\cf0 stamp_turtles\plain\f6\fs20\cf3 \par \par \plain\f5\fs20\cf3\b end \par \par to show_value_of_counter\plain\f5\fs20\cf0\b \par \plain\f5\fs20\cf0 ct \par if :counter = -10 [ \par insert ( sentence "Minimum "value "reached )\plain\f5\fs20\cf2 \tab ; Minimum value reached \plain\f5\fs20\cf0 \par ] \par \par if :counter = 10 [ \par insert ( sentence "Maximum "value "reached )\plain\f5\fs20\cf2 \tab ; Maximum value reached\plain\f5\fs20\cf0 \par ] \par \par \plain\f5\fs20\cf2 ; insert the value of the counter in the current text box\plain\f5\fs20\cf0 \par if (and :counter > -10 :counter < 10) [ \par insert ( sentence "The "counters "value "is " )\tab \par insert :counter \par \plain\f5\fs20\cf0\b \plain\f5\fs20\cf0 ] \par \plain\f5\fs20\cf3\b end\plain\f6\fs20\cf3 \par \par \plain\f5\fs20\cf3\b to stamp_turtles \par \par \plain\f6\fs20\cf0 if :counter = 0 [ \par setshape "clear_sq \par stamp \par ]\plain\f5\fs20\cf3\b \par \plain\f6\fs20\cf0 \par if :counter > 0 [ \par setshape "clear_sq \par stamp \par \par repeat :counter [ \par setshape "\plain\f6\fs20\cf4 green_sq \par \plain\f6\fs20\cf0 fd 18 \par stamp \par ] \par ] \par \par if :counter < 0 [ \par setshape "clear_sq \par stamp \par \par setshape "\plain\f6\fs20\cf5 red_sq\plain\f6\fs20\cf0 \par repeat abs :counter [ \par bk 18 \par stamp \par ] \par ] \par \par if :counter = 0 [ \par setshape "clear_sq \par stamp \par ] \par \plain\f5\fs20\cf3\b end\plain\f6\fs20\cf3 \par \par \plain\f5\fs20\cf3\b to reset\plain\f6\fs20\cf0 \par ct \par cg \par make "counter 0 \par \plain\f6\fs20\cf3 \plain\f5\fs20\cf0 show_value_of_counter \par \plain\f6\fs20\cf0 stamp_turtles \par \plain\f5\fs20\cf3\b end\plain\f6\fs20\cf0 \par \par } /pagenameCountercurturtlefillercurtexttext1transition0Dturtle-deamons[[] [] [] [] [] [] [] [] [] [] [] [] [] [] [] []]Cmouse-deamons[[] [] [] [] [] [] [] [] [] [] [] [] [] [] [] []]bg07%buffer %$6HZl~ 2DVhz .@Rdv*<N`r&8J\n"4FXj| 0BTfx,>Pbt(:L^p  $ 6 H Z l ~  2 D V h z  . @ R d v   * < N ` r   & 8 J \ n "4FXj|3Ni  2DVhz .@Rdv*<N`r&8J\n"4FXj| 0BTfx,>Pbt(:L^p$6HZl~ 2DVhz .@Rdv*<N`r&8J\n"4FXj| 0BTfobject typetnamefillerlocked?false xpos372 ypos213 shape15penstate0 size40pencolor8427712 heading0 pensize1shown?truefcn[filler_t] kind0shapeinclear_sqhave-list[has]colorin35objecttypebuttonnamebutton2rect[212 332 93 31]show-name?falselocked?falsefcn[increment] kind1objecttypebuttonnamebutton3rect[35 333 93 30]show-name?falselocked?falsefcn[decrement] kind14object typetextnametext1rect[34 371 323 46]show-name?falselocked?falsevisible?truesnaped?falsetext{\rtf1\ansi\deff0\deftab720{\fonttbl{\f0\fswiss MS Sans Serif;}{\f1\froman\fcharset2 Symbol;}{\f2\fswiss\fprq2 System;}{\f3\fswiss Arial;}{\f4\fmodern\fprq1 Courier New;}{\f5\fswiss\fprq2 Arial;}{\f6\fswiss Arial;}} {\colortbl\red0\green0\blue0;\red0\green0\blue128;\red0\green128\blue128;\red0\green0\blue255;\red0\green128\blue0;\red255\green0\blue0;} \deflang1033\pard\plain\f5\fs28 The counters value is 0 \par } object typetextnametext2rect[112 60 446 28]show-name?falselocked?falsevisible?falsesnaped?truetext{\rtf1\ansi\deff0\deftab720{\fonttbl{\f0\fswiss MS Sans Serif;}{\f1\froman\fcharset2 Symbol;}{\f2\fswiss\fprq2 System;}{\f3\fswiss Arial;}{\f4\fmodern\fprq1 Courier New;}{\f5\fswiss\fprq2 Arial;}{\f6\fswiss Arial;}} {\colortbl\red0\green0\blue0;\red0\green0\blue128;\red0\green128\blue128;\red0\green0\blue255;\red0\green128\blue0;\red255\green0\blue0;} \deflang1033\pard\plain\f5\fs24\cf0 make "counter :counter + 1\tab \tab \plain\f5\fs24\cf3 ; increment the counter by 1\plain\f6\fs20\cf0 \par } object typetextnametext3rect[108 107 448 28]show-name?falselocked?falsevisible?falsesnaped?truetext{\rtf1\ansi\deff0\deftab720{\fonttbl{\f0\fswiss MS Sans Serif;}{\f1\froman\fcharset2 Symbol;}{\f2\fswiss\fprq2 System;}{\f3\fswiss Arial;}{\f4\fmodern\fprq1 Courier New;}{\f5\fswiss\fprq2 Arial;}{\f6\fswiss Arial;}} {\colortbl\red0\green0\blue0;\red0\green0\blue128;\red0\green128\blue128;\red0\green0\blue255;\red0\green128\blue0;\red255\green0\blue0;} \deflang1033\pard\plain\f5\fs24\cf0 make "counter :counter - 1\tab \tab \plain\f5\fs24\cf3 ; decrement the counter by 1\plain\f6\fs20\cf0 \par } objecttypebuttonnamebutton1rect[136 333 70 29]show-name?falselocked?falsefcn[reset] kind1