Next: File handling
Up: The workspace
Previous: Concept of variables
Contents
Index
Now, you can define property lists with XLogo. Each list has a specific name and contains some key-value couples.
For example, we can consider a property list named ''car``. It should contain the key ''color`` associated to the value ''red``, or the key ''type`` and the value ''4x4``.
To handle these lists, we can use the following primitives:
- pprop putproperty: Syntax: pprop listname key value
Adds a property to the property list named listname. value will be accessible with the key key. If no property list named listname exists, then it will be created.
- gprop getproperty: Syntax: gprop listname key
Returns the value associated with the key key in the property list called listname. If this property list doesn't exist or if there isn't any valid key, it returns an empty list.
- rprop removeproperty: Syntax: rprop listname key
Removes the corresponding couple key-value in the property list listname.
- plist propertylist: Syntax: plist listname
Displays all key-value couples contained in the property list called textttlistname.
Let's return to the property list called ''car``.
# Filling property list
pprop "car "color "red
pprop "car "type "4x4
pprop "car "vendor "Citroën
# Display one value
print gprop "car "color
red
# Display all elements
print plist "car
color red type 4x4 vendor Citroën
Next: File handling
Up: The workspace
Previous: Concept of variables
Contents
Index
Loïc
2008-06-08