Index: .hgignore
===================================================================
--- .hgignore	(revision 11)
+++ .hgignore	(revision 32)
@@ -11,2 +11,3 @@
 ltmain.sh
 m4/.*\.m4
+.*\.pyc
Index: src/client/python/xplra.py
===================================================================
--- src/client/python/xplra.py	(revision 31)
+++ src/client/python/xplra.py	(revision 32)
@@ -155,5 +155,43 @@
         """Get the value of the byte array dataref with the given name as a
         string."""
-        return self.getByteArray(name, offset = offset).tostring()
+        s = ""
+        for b in self.getByteArray(name, offset = offset):
+            if b==0: break
+            s += chr(b)
+        return s
+
+    def setInt(self, name, value):
+        """Set the value of the integer dataref with the given name."""
+        self._setSingle(name, TYPE_INT, value)
+
+    def setFloat(self, name, value):
+        """Set the value of the float dataref with the given name."""
+        self._setSingle(name, TYPE_FLOAT, value)
+
+    def setDouble(self, name, value):
+        """Set the value of the double dataref with the given name."""
+        self._setSingle(name, TYPE_DOUBLE, value)
+
+    def setFloatArray(self, name, value, offset = 0):
+        """Set the value of the float array dataref with the given name."""
+        self._setSingle(name, TYPE_FLOAT_ARRAY, value, offset = offset)
+
+    def setIntArray(self, name, value, offset = 0):
+        """Set the value of the integer array dataref with the given name."""
+        self._setSingle(name, TYPE_INT_ARRAY, value, offset = offset)
+
+    def setByteArray(self, name, value, offset = 0):
+        """Set the value of the byte array dataref with the given name."""
+        self._setSingle(name, TYPE_BYTE_ARRAY, value, offset = offset)
+
+    def setString(self, name, value, length, offset = 0):
+        """Set the value of the byte array dataref with the given name from a
+        string.
+
+        The string will be padded with 0's so that its length is the given
+        one."""
+        value = [ord(c) for c in value[:length]]
+        value += [0] * (length - len(value))
+        self.setByteArray(name, value, offset)
 
     def disconnect(self):
@@ -211,4 +249,36 @@
             return arr
 
+    def _setSingle(self, name, type, value, offset = None):
+        """Set the single value of the given name and type."""
+        self._writeU8(COMMAND_SET_SINGLE)
+        self._writeString(name)
+        self._writeU8(type)
+        if offset is not None:
+            self._writeS32(len(value))
+            self._writeS32(offset)
+
+        self._writeValue(type, value)
+        self._flush()
+        self._checkResult()
+
+    def _writeValue(self, type, value):
+        """Write a value of the given type."""
+        if type==TYPE_INT:
+            self._writeS32(int(value))
+        elif type==TYPE_FLOAT:
+            self._writeFloat(float(value))
+        elif type==TYPE_DOUBLE:
+            self._writeDouble(float(value))
+        else:
+            arr = None
+            if type==TYPE_FLOAT_ARRAY:
+                arr = array.array("f")
+            elif type==TYPE_INT_ARRAY:
+                arr = array.array("i")
+            elif type==TYPE_BYTE_ARRAY:
+                arr = array.array("B")
+            arr.fromlist(value)
+            self._stream.write(arr.tostring())
+
     def _writeU8(self, x):
         """Write the given value as an unsigned, 8-bit value."""
Index: test/basictest.py
===================================================================
--- test/basictest.py	(revision 31)
+++ test/basictest.py	(revision 32)
@@ -51,5 +51,6 @@
         print "Querying the aircraft's description as a string, with an offset of 3..."
         result2 = xplane.getString("sim/aircraft/view/acf_descrip", offset = 3);
-        print "Got: '" + result2 + "'"
+        print "Got: '" + result2 + "' (" + `len(result2)` + ")"
+        print result2=="h 8 Q400"
         print
 
@@ -64,4 +65,67 @@
         print
 
+        print "Setting the number of the engines to", numEngines + 1
+        xplane.setInt("sim/aircraft/engine/acf_num_engines", numEngines + 1)
+        numEngines = xplane.getInt("sim/aircraft/engine/acf_num_engines")
+        print "The new number of engines:", numEngines
+        print
+
+        acfElevUp = xplane.getFloat("sim/aircraft/controls/acf_elev_up")
+        print "Setting the aircraft elevator up control from %f to %f..." % \
+            (acfElevUp, acfElevUp + 15.0)
+        xplane.setFloat("sim/aircraft/controls/acf_elev_up", acfElevUp + 15.0)
+        acfElevUp = xplane.getFloat("sim/aircraft/controls/acf_elev_up")
+        print "The aircraft elevator up control set to", acfElevUp
+        print
+
+        localX = xplane.getDouble("sim/flightmodel/position/local_x")
+        print "Setting the aircraft's local X-coordinate from %f to %f..." % \
+            (localX, localX + 15.0)
+        xplane.setDouble("sim/flightmodel/position/local_x", localX + 15.0)
+        localX = xplane.getDouble("sim/flightmodel/position/local_x")
+        print "The aircraft's local X-coordinate set to", localX
+        print
+
+        numBlades = xplane.getFloatArray("sim/aircraft/prop/acf_num_blades").tolist()
+        print "Setting the number of blades"
+        print "    from:", numBlades
+        numBlades = [n+2.5 for n in numBlades]
+        print "    to:", numBlades
+        xplane.setFloatArray("sim/aircraft/prop/acf_num_blades",  numBlades)
+
+        numBlades = xplane.getFloatArray("sim/aircraft/prop/acf_num_blades").tolist()
+        print "The result:", numBlades
+        print
+
+        batteryArrayOn = xplane.getIntArray("sim/cockpit/electrical/battery_array_on").tolist()
+        print "Setting the batteries"
+        print "    from:", batteryArrayOn
+        batteryArrayOn = [1 if b==0 else 0 for b in batteryArrayOn]
+        print "    to:", batteryArrayOn
+        xplane.setIntArray("sim/cockpit/electrical/battery_array_on", batteryArrayOn)
+        batteryArrayOn = xplane.getIntArray("sim/cockpit/electrical/battery_array_on").tolist()
+        print "The result:", batteryArrayOn
+        print
+
+        tailNum = [0] * 40
+        tailNum[0] = ord('H')
+        tailNum[1] = ord('A')
+        tailNum[2] = ord('-')
+        tailNum[3] = ord('V')
+        tailNum[4] = ord('A')
+        tailNum[5] = ord('I')
+
+        print "Setting the tail number to %s as a byte array..." % (tailNum,)
+        xplane.setByteArray("sim/aircraft/view/acf_tailnum", tailNum)
+        print "The tail number is:", xplane.getString("sim/aircraft/view/acf_tailnum")
+        print
+
+        tailNum1 = "VAIS"
+        print "Setting the tail number to " + tailNum1 + " as a string..."
+        xplane.setString("sim/aircraft/view/acf_tailnum", tailNum1, 40)
+        print "The tail number is:", xplane.getString("sim/aircraft/view/acf_tailnum")
+        print
+
+
     except Exception as e:
         print ">>>>>>>>>>>>>>>>>>>>>> Exception caught:", str(e)
