! object message sends the message "message" to the object "object" A message is a word (property name or method name) a list of the form [ < parameters> ] With a property name ! outputs the property value or an empty list if no value is found. With a method name, the procedure corresponding to the method is runed and a result is returned when the procedure returns a result. If the procedure is not found an empty list is returned. This produces an error " I don't know what to do with [] " if the method is a command (don't return a result). Example: ! "object [create "human] ! "human[make "food [milk meat vegetables]] show ! "human "food ! "human "destroy ----------------------------------------------------------------------------------- !O message message to current object. !o sends the message "message" to the current object It is equivalent to ! :object At run time the variable :object contain the name of the object receiving the message. The tittle of ! is to ! :object :&p and while ! is running :object is containing the name of the object, if not masked by an other call of ! . !o should be used in a method. The current object is the object that has received a message with that method. A message is a word (property name or method name) a list of the form [ ] With a property name ! outputs the property value or an empty list if no value is found. With a method name, the procedure corresponding to the method is runed and a result is returned when the procedure returns a result. If the procedure is not found an empty list is returned. This produces an error I don't know what to do with [] if the method is a command (a command doesn't return a result). Example: ! "object [create "poly] ! "poly [make "nside 5 ] ; 5 will be the default number of sides for all ; descendants of poly ! "poly [make "size 100] ; 100 will be the default size for all descendants of ; poly ! "poly [method "draw] ; will open the editor with to poly.draw as title of the ;procedure. ; in the editor : to poly.draw localmake "ns !o "nside localmake "s !o "size repeat :ns [fd :s rt 360/:ns] end ; This will define the method draw while exiting the editor. ! "poly "draw ; will draw a polygone with 5 sides and size 100 ! "poly [create "square] ! "square [make "nside 4] cs ! "square "draw ; will draw a square since in the line : ; localmake "ns !o "nside, ; ns will get nside from the object square that receives ; the message draw. ---------------------------------------------------------------------------------- !S object message message to super class sends "message" to parent of "object" Example ! "object [create "poly] ! "poly [make "nside 5 ] ; 5 will be the default number of sides for all ; descendants of poly ! "poly [make "size 100] ; 100 will be the default size for all descendants ; of poly ! "poly [method "draw] ; will open the editor with to poly.draw as title of the ; procedure in the editor : to poly.draw localmake "ns !o "nside localmake "s !o "size repeat :ns [fd :s rt 360/:ns] end ; This will define the method draw while exiting the editor. ! "poly "draw ; will draw a polygone with 5 sides and size 100 ! "poly [create "square] ! "square [make "nside 4] cs ! "square "draw ; will draw a square since in the line : ; localmake "ns !o "nside, ; ns will get nside from the object square that received ; the message draw. !s "square "draw ; Will draw a polygone (5 sides) since the message is send to ; the parent of square which is polygon. ---------------------------------------------------------------------------------- Predefined methods. CREATE object creates a new object with the current object as parent. Example: ! "object [create "poly] ; will create the object poly which has object as parent. ;(object is the root of all objects.) ! "poly [create "square] ; Will create the object square with the object poly as : parent. ---------------------------------------------------------------------------------- METHOD method_name Define a method for the current object. It opens the editor with the name of the procedure corresponding to the method. The name of the procedure is made as . Example: ! "object [create "poly] ! "poly [make "nside 5 ] ; 5 will be the default number of sides for all ; descendants of poly ! "poly [make "size 100] ; 100 will be the default size for all descendants of ; poly ! "poly [method "draw] ; will open the editor with to poly.draw as title of ; the procedure in the editor : to poly.draw localmake "ns !o "nside localmake "s !o "size repeat :ns [fd :s rt 360/:ns] end ; This will define the method draw while exiting the editor. ! "poly "draw ; will draw a polygone with 5 sides and size 100 ---------------------------------------------------------------------------------- DESTROY Destroy the current object and all its descendants but does not erase the procedures corresponding to the methods. Example: ! "poly "destroy ---------------------------------------------------------------------------------- ADD property property_value If the old value of the property is a word, the method ADD will replace the property by a list with the old value and the new one. if old value the property is a list the method ADD will add the new property at the end of the list. Example: ! "object [create "human] ! "human [make "food [milk meat vegetables]] ! "human [add "food "sugar] show ! "human "food [milk meat vegetables sugar] ! "human [make "drink "water] ! "human[add "drink "wine] show ! "human "drink [water wine] ----------------------------------------------------------------------------------- REMOVE property property_value The method REMOVE removes a property_value of a property Example: ! "human [make "drink "water] ! "human[add "drink "wine] show ! "human "drink [water wine] ! "human [remove "drink "wine] show ! "human "drink [water] ------------------------------------------------------------------------------------ ER property The method ER erases the property . If the property is a method the corresponding procedure is not erased. ! "human [make "drink "water] show ! "human "drink [water] ! "human [er "drink] show ! "human "drink [] ------------------------------------------------------------------------------------ ANCESTORS Returns the ancestors of the current object Example: ! "object [create "human] show ! "human "ancestors [object] ------------------------------------------------------------------------------------ DESCENDANTS Returns the descendants of the current object Example: ! "object [create "human] show ! "object "descendants [human]