Index: src/client/c/hu/varadiistvan/xplra/xplra.cc
===================================================================
--- src/client/c/hu/varadiistvan/xplra/xplra.cc	(revision 14)
+++ src/client/c/hu/varadiistvan/xplra/xplra.cc	(revision 23)
@@ -34,5 +34,9 @@
 #include "Exception.h"
 
+#include <vector>
+#include <memory>
+
 #include <cstdio>
+#include <cassert>
 
 //------------------------------------------------------------------------------
@@ -40,4 +44,312 @@
 using hu::varadiistvan::xplra::XPlane;
 using hu::varadiistvan::xplra::Exception;
+using hu::varadiistvan::xplra::IOException;
+using hu::varadiistvan::xplra::ProtocolException;
+using hu::varadiistvan::xplra::NotConnectedException;
+using hu::varadiistvan::xplra::TypeMismatchException;
+using hu::varadiistvan::xplra::InvalidIDException;
+
+using std::exception;
+using std::string;
+using std::vector;
+using std::auto_ptr;
+
+//------------------------------------------------------------------------------
+
+namespace {
+
+//------------------------------------------------------------------------------
+
+/**
+ * Information about a connection.
+ */
+class Connection : public XPlane
+{
+private:
+    /**
+     * The last error code.
+     */
+    int lastErrorCode;
+
+    /**
+     * The last error subcode.
+     */
+    unsigned long lastErrorSubCode;
+
+    /**
+     * The string of the last error
+     */
+    std::string lastErrorString;
+
+public:
+    /**
+     * Construct the connection
+     */
+    Connection() throw();
+
+    /**
+     * Handle the currently pending exception.
+     */
+    void handleException() throw();
+
+    /**
+     * Get the last error code.
+     */
+    int getLastError(unsigned long* lastErrorSubCode) const throw();
+
+    /**
+     * Get the string representation of the last error code.
+     */
+    const char* getLastErrorString() const throw();
+
+    /**
+     * Clear the last error code.
+     */
+    void clearLastError() throw();
+};
+
+//------------------------------------------------------------------------------
+
+inline Connection::Connection() throw() :
+    lastErrorCode(0),
+    lastErrorSubCode(0)
+{
+}
+
+//------------------------------------------------------------------------------
+
+void Connection::handleException() throw()
+{
+    try {
+        throw;
+    } catch(const IOException& e) {
+        lastErrorCode = ERROR_IO;
+        lastErrorSubCode = e.getErrorCode();
+        lastErrorString = e.what();
+    } catch(const ProtocolException& e) {
+        lastErrorCode = ERROR_PROTOCOL;
+        lastErrorSubCode = static_cast<unsigned long>(e.getErrorCode());
+        lastErrorString = e.what();
+    } catch(const NotConnectedException& e) {
+        lastErrorCode = ERROR_NOT_CONNECTED;
+        lastErrorSubCode = 0;
+        lastErrorString = e.what();
+    } catch(const TypeMismatchException& e) {
+        lastErrorCode = ERROR_TYPE_MISMATCH;
+        lastErrorSubCode = 0;
+        lastErrorString = e.what();
+    } catch(const InvalidIDException& e) {
+        lastErrorCode = ERROR_INVALID_ID;
+        lastErrorSubCode = 0;
+        lastErrorString = e.what();
+    } catch(const exception& e) {
+        lastErrorCode = ERROR_OTHER;
+        lastErrorSubCode = 0;
+        lastErrorString = e.what();
+    } catch(...) {
+        lastErrorCode = ERROR_OTHER;
+        lastErrorSubCode = 0;
+        lastErrorString = "<Exception of an unknown type>";
+    }
+}
+
+//------------------------------------------------------------------------------
+
+inline int Connection::getLastError(unsigned long* lastErrorSubCode)
+    const throw()
+{
+    if (lastErrorSubCode!=0) *lastErrorSubCode = this->lastErrorSubCode;
+    return lastErrorCode;
+}
+
+//------------------------------------------------------------------------------
+
+inline const char* Connection::getLastErrorString() const throw()
+{
+    return (lastErrorCode==ERROR_NONE) ? 0 : lastErrorString.c_str();
+}
+
+//------------------------------------------------------------------------------
+
+inline void Connection::clearLastError() throw()
+{
+    lastErrorCode = ERROR_NONE;
+    lastErrorSubCode = 0;
+    lastErrorString.clear();
+}
+
+//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+
+/**
+ * Information about a connection slot in the vector of connections.
+ */
+struct Slot
+{
+private:
+    /**
+     * The slots.
+     */
+    static std::vector<Slot> slots;
+
+    /**
+     * The index of the first free slot.
+     */
+    static int firstFree;
+
+public:
+    /**
+     * Add a new connection.
+     */
+    static int addConnection(Connection* connection) throw();
+
+    /**
+     * Get the connection with the given ID.
+     */
+    static Connection* getConnection(int connectionID) throw();
+
+    /**
+     * Clear the connection with the given ID.
+     */
+    static void clearConnection(int connectionID) throw();
+
+    // Indicate if the slot contains a valid connection or not
+    bool valid;
+
+    union {
+        // The connection, if it is a valid connection
+        Connection* connection;
+
+        // The index of the next free slot
+        int nextFreeIndex;
+    };
+
+    /**
+     * Construct a slot with the given connection
+     */
+    Slot(Connection* connection) throw();
+
+    /**
+     * Set the connection and return the former next free index. It
+     * should be called for a slot with no connection.
+     */
+    int setConnection(Connection* connection) throw();
+
+    /**
+     * Get the connection if this slot contains a connection.
+     */
+    Connection* getConnection() const throw();
+
+    /**
+     * Clear the connection and set the given next free index.
+     */
+    void clear(int nextFreeIndex) throw();
+};
+
+//------------------------------------------------------------------------------
+
+vector<Slot> Slot::slots;
+
+//------------------------------------------------------------------------------
+
+int Slot::firstFree = -1;
+
+//------------------------------------------------------------------------------
+
+inline Slot::Slot(Connection* connection) throw() :
+    valid(true)
+{
+    this->connection = connection;
+}
+
+//------------------------------------------------------------------------------
+
+inline int Slot::setConnection(Connection* connection) throw()
+{
+    assert(!valid);
+    int nextFreeIndex = this->nextFreeIndex;
+    this->connection = connection;
+    valid = true;
+    return nextFreeIndex;
+}
+
+//------------------------------------------------------------------------------
+
+inline Connection* Slot::getConnection() const throw()
+{
+    return valid ? connection : 0;
+}
+
+//------------------------------------------------------------------------------
+
+inline void Slot::clear(int nextFreeIndex) throw()
+{
+    assert(valid);
+    valid = false;
+    this->nextFreeIndex = nextFreeIndex;
+}
+
+//------------------------------------------------------------------------------
+
+int Slot::addConnection(Connection* connection) throw()
+{
+    int id = firstFree;
+    if (id<0) {
+        id = slots.size();
+        slots.push_back(Slot(connection));
+    } else {
+        Slot& slot = slots[id];
+        firstFree = slot.setConnection(connection);
+    }
+
+    return id;
+}
+
+//------------------------------------------------------------------------------
+
+Connection* Slot::getConnection(int connectionID) throw()
+{
+    size_t index = static_cast<size_t>(connectionID);
+    return (index<slots.size()) ? slots[index].getConnection() : 0;
+}
+
+//------------------------------------------------------------------------------
+
+void Slot::clearConnection(int connectionID) throw()
+{
+    size_t index = static_cast<size_t>(connectionID);
+    if (index<slots.size()) {
+        slots[index].clear(firstFree);
+        firstFree = index;
+    }
+}
+
+//------------------------------------------------------------------------------
+
+} /* anonymous namespace */
+
+//------------------------------------------------------------------------------
+
+extern "C" int xplra_get_last_error(int connectionID, unsigned long* subCode)
+{
+    Connection* connection = Slot::getConnection(connectionID);
+    return (connection==0) ? -1 : connection->getLastError(subCode);
+}
+
+//------------------------------------------------------------------------------
+
+extern "C" const char* xplra_get_last_error_string(int connectionID)
+{
+    Connection* connection = Slot::getConnection(connectionID);
+    return (connection==0) ? 0 : connection->getLastErrorString();
+}
+
+//------------------------------------------------------------------------------
+
+extern "C" void xplra_clear_last_error(int connectionID)
+{
+    Connection* connection = Slot::getConnection(connectionID);
+    if (connection!=0) connection->clearLastError();
+}
 
 //------------------------------------------------------------------------------
@@ -46,10 +358,70 @@
 {
     try {
-        XPlane xplane;
+        auto_ptr<Connection> connection(new Connection());
+        connection->connect();
+        return Slot::addConnection(connection.release());
+    } catch(...) {
+        return -1;
+    }
+}
+
+//------------------------------------------------------------------------------
+
+extern "C" int xplra_get_int(int* value, int connectionID, const char* name)
+{
+    Connection* connection = Slot::getConnection(connectionID);
+    if (connection==0) return -1;
+    try {
+        *value = connection->getInt(name);
         return 0;
-    } catch(const Exception& e) {
-        printf("xplra_connect failed: %s\n", e.what());
+    } catch (...) {
+        connection->handleException();
         return -1;
     }
+}
+
+//------------------------------------------------------------------------------
+
+extern "C" int xplra_get_float(float* value, int connectionID, const char* name)
+{
+    Connection* connection = Slot::getConnection(connectionID);
+    if (connection==0) return -1;
+    try {
+        *value = connection->getFloat(name);
+        return 0;
+    } catch (...) {
+        connection->handleException();
+        return -1;
+    }
+}
+
+//------------------------------------------------------------------------------
+
+extern "C" int xplra_get_double(double* value,
+                                int connectionID, const char* name)
+{
+    Connection* connection = Slot::getConnection(connectionID);
+    if (connection==0) return -1;
+    try {
+        *value = connection->getDouble(name);
+        return 0;
+    } catch (...) {
+        connection->handleException();
+        return -1;
+    }
+}
+
+//------------------------------------------------------------------------------
+
+extern "C" int xplra_disconnect(int connectionID)
+{
+    Connection* connection = Slot::getConnection(connectionID);
+    if (connection==0) return -1;
+
+    Slot::clearConnection(connectionID);
+    connection->disconnect();
+    delete connection;
+
+    return 0;
 }
 
Index: src/client/c/hu/varadiistvan/xplra/xplra.h
===================================================================
--- src/client/c/hu/varadiistvan/xplra/xplra.h	(revision 14)
+++ src/client/c/hu/varadiistvan/xplra/xplra.h	(revision 23)
@@ -38,5 +38,121 @@
 /*----------------------------------------------------------------------------*/
 
+/** No error occured */
+#define ERROR_NONE 0
+
+/**
+ * An I/O error has occured. The subcode is the errno value on Linux, or the
+ * Windows error code.
+ */
+#define ERROR_IO 1
+
+/**
+ * A protocol error has occured. The subcode is one of the
+ * ERROR_PROTOCOL_XXX values.
+ */
+#define ERROR_PROTOCOL 2
+
+/** Invalid command was passed to the plugin */
+#define ERROR_PROTOCOL_INVALID_COMMAND = 1
+
+/** An unknown dataref was specified */
+#define ERROR_PROTOCOL_UNKNOWN_DATAREF = 2
+
+/** An invalid type was specified */
+#define ERROR_PROTOCOL_INVALID_TYPE = 3
+
+/** An invalid length was specified */
+#define ERROR_PROTOCOL_INVALID_LENGTH = 4
+
+/** An invalid offset was specified */
+#define ERROR_PROTOCOL_INVALID_OFFSET = 5
+
+/** An invalid count was specified */
+#define ERROR_PROTOCOL_INVALID_COUNT = 6
+
+/** An invalid ID was specified */
+#define ERROR_PROTOCOL_INVALID_ID = 7
+
+/** Other protocol error  */
+#define ERROR_PROTOCOL_OTHER = 8
+
+/** A function requiring a connection is called without a connection */
+#define ERROR_NOT_CONNECTED 3
+
+/** A type-specific function was called for a dataref of a different type */
+#define ERROR_TYPE_MISMATCH 4
+
+/** An invalid ID was passed to a function */
+#define ERROR_INVALID_ID 5
+
+/** Some other error */
+#define ERROR_OTHER 255
+
+/*----------------------------------------------------------------------------*/
+
+/**
+ * Get the last error code with the subcode.
+ *
+ * @return the last error code, or -1 if the given connection ID is invalid.
+ */
+int xplra_get_last_error(int connectionID, unsigned long* subCode);
+
+/**
+ * Get a string representation of the last error.
+ *
+ * @return the string representation of the last error, or 0 if there
+ * was no last error, or the connection ID is invalid.
+ */
+const char* xplra_get_last_error_string(int connectionID);
+
+/**
+ * Clear the last error.
+ */
+void xplra_clear_last_error(int connectionID);
+
+/*----------------------------------------------------------------------------*/
+
+/**
+ * Connect to the simulator.
+ *
+ * @return an ID for the created connection, or -1 on error.
+ */
 int xplra_connect();
+
+/*----------------------------------------------------------------------------*/
+
+/**
+ * Get an integer value from the simulator.
+ *
+ * @return 0 on success, -1 on error
+ */
+int xplra_get_int(int* value, int connectionID, const char* name);
+
+/*----------------------------------------------------------------------------*/
+
+/**
+ * Get a float value from the simulator.
+ *
+ * @return 0 on success, -1 on error
+ */
+int xplra_get_float(float* value, int connectionID, const char* name);
+
+/*----------------------------------------------------------------------------*/
+
+/**
+ * Get a double value from the simulator.
+ *
+ * @return 0 on success, -1 on error
+ */
+int xplra_get_double(double* value, int connectionID, const char* name);
+
+/*----------------------------------------------------------------------------*/
+
+/**
+ * Destroy the connection with the given ID.
+ *
+ * @return 0 on success, -1 on error.
+ */
+int xplra_disconnect(int connectionID);
 
 /*----------------------------------------------------------------------------*/
Index: test/Makefile.am
===================================================================
--- test/Makefile.am	(revision 21)
+++ test/Makefile.am	(revision 23)
@@ -6,5 +6,5 @@
 endif
 
-noinst_PROGRAMS=ctest basictest multigettest multisettest
+noinst_PROGRAMS=ctest basictest basicctest multigettest multisettest
 
 ctest_SOURCES=ctest.c
@@ -15,4 +15,9 @@
 basictest_SOURCES=basictest.cc
 
+basicctest_SOURCES=basicctest.c
+if TARGET_API_WIN32
+basicctest_LDFLAGS=-lstdc++
+endif
+
 multigettest_SOURCES=multigettest.cc
 
Index: test/basicctest.c
===================================================================
--- test/basicctest.c	(revision 23)
+++ test/basicctest.c	(revision 23)
@@ -0,0 +1,288 @@
+// Copyright (c) 2013 by István Váradi
+
+// This file is part of XPLRA, a remote-access plugin for X-Plane
+
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+
+// 1. Redistributions of source code must retain the above copyright notice, this
+//    list of conditions and the following disclaimer.
+// 2. Redistributions in binary form must reproduce the above copyright notice,
+//    this list of conditions and the following disclaimer in the documentation
+//    and/or other materials provided with the distribution.
+
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// The views and conclusions contained in the software and documentation are those
+// of the authors and should not be interpreted as representing official policies,
+// either expressed or implied, of the FreeBSD Project.
+
+//------------------------------------------------------------------------------
+
+#include <hu/varadiistvan/xplra/xplra.h>
+
+#include <stdio.h>
+
+//------------------------------------------------------------------------------
+
+int main()
+{
+    int retval = 0;
+    const char* errorString = 0;
+    int numEngines = 0;
+    float spoolTime = 0.0;
+    double latitude = 0.0, longitude = 0.0;
+
+    printf("Connection to X-Plane...\n");
+    int connectionID = xplra_connect();
+
+    if (connectionID>=0) {
+        printf("Connected.\n\n");
+    } else {
+        printf("Connection failed.\n");
+        goto cleanup;
+    }
+
+    printf("Querying the number of the engines...\n");
+    if (xplra_get_int(&numEngines, connectionID,
+                      "sim/aircraft/engine/acf_num_engines")<0)
+    {
+        goto error;
+    }
+    printf("The number of engines: %d\n\n", numEngines);
+
+    printf("Querying an invalid dataref...\n");
+    if (xplra_get_int(&numEngines, connectionID,
+                      "sim/aircraft/engine/num_engines")==0) {
+        printf("\n>>>>>>>>>>>> Succeeded!!!!!!!!!!!!!!!!!!!!!!\n\n");
+    } else {
+        printf("Error occured: %s\n\n",
+               xplra_get_last_error_string(connectionID));
+        xplra_clear_last_error(connectionID);
+    }
+
+    printf("Querying the spool time of a jet engine...\n");
+    if (xplra_get_float(&spoolTime, connectionID,
+                        "sim/aircraft/engine/acf_spooltime_jet")<0)
+    {
+        goto error;
+    }
+    printf("The spool time: %f\n\n", spoolTime);
+
+    printf("Querying the spool time of a propeller...\n");
+    if (xplra_get_float(&spoolTime, connectionID,
+                        "sim/aircraft/engine/acf_spooltime_prop")<0)
+    {
+        goto error;
+    }
+    printf("The spool time: %f\n\n", spoolTime);
+
+    printf("Querying the coordinates...\n");
+    if (xplra_get_double(&latitude, connectionID,
+                         "sim/flightmodel/position/latitude")<0)
+    {
+        goto error;
+    }
+    if (xplra_get_double(&longitude, connectionID,
+                         "sim/flightmodel/position/longitude")<0)
+    {
+        goto error;
+    }
+    printf("The coordinates: %f, %f\n\n", latitude, longitude);
+
+    goto cleanup;
+error:
+    errorString = xplra_get_last_error_string(connectionID);
+    if (errorString==0) {
+        printf("\nUnknown error occured!\n");
+    } else {
+        printf("\nError: %s\n", errorString);
+    }
+
+    retval = 1;
+cleanup:
+    if (connectionID>=0) xplra_disconnect(connectionID);
+    return retval;
+
+    // try {
+
+    //     printf("Querying the aircraft's description as an array of a fixed size...\n");
+    //     uint8_t result[260];
+    //     size_t length = xplane.getByteArray("sim/aircraft/view/acf_descrip",
+    //                                         result, sizeof(result)/sizeof(result[0]));
+    //     printf("Got %zu bytes, as a string: '%s'\n\n", length, result);
+
+    //     printf("Querying the aircraft's description as a dynamically created array...\n");
+    //     uint8_t* result1 = xplane.getByteArray("sim/aircraft/view/acf_descrip", length);
+    //     printf("Got %zu bytes, as a string: '%s'\n\n", length, result1);
+
+    //     printf("Querying the aircraft's description as a string, with an offset of 3...\n");
+    //     string result2 = xplane.getString("sim/aircraft/view/acf_descrip", 3);
+    //     printf("Got: '%s'\n\n", result2.c_str());
+
+    //     printf("Querying the aircraft's engine types as an array of a fixed size...\n");
+    //     int32_t result3[8];
+    //     length = xplane.getIntArray("sim/aircraft/prop/acf_en_type",
+    //                                 result3, sizeof(result3)/sizeof(result3[0]));
+    //     printf("Got %zu values:", length);
+    //     for(size_t i = 0; i<length; ++i) {
+    //         if (i>0) printf(",");
+    //         printf(" %d", result3[i]);
+    //     }
+    //     printf("\n\n");
+
+    //     printf("Querying the aircraft's engine types as a dynamically created array...\n");
+    //     length = 0;
+    //     int32_t* result4 = xplane.getIntArray("sim/aircraft/prop/acf_en_type", length);
+    //     printf("Got %zu values:", length);
+    //     for(size_t i = 0; i<length; ++i) {
+    //         if (i>0) printf(",");
+    //         printf(" %d", result4[i]);
+    //     }
+    //     printf("\n\n");
+
+    //     printf("Querying the aircraft's propeller direction as an array of a fixed size...\n");
+    //     float result5[8];
+    //     length = xplane.getFloatArray("sim/aircraft/prop/acf_prop_dir",
+    //                                   result5, sizeof(result5)/sizeof(result5[0]));
+    //     printf("Got %zu values:", length);
+    //     for(size_t i = 0; i<length; ++i) {
+    //         if (i>0) printf(",");
+    //         printf(" %f", result5[i]);
+    //     }
+    //     printf("\n\n");
+
+    //     printf("Querying the aircraft's propeller direction as a dynamically created array...\n");
+    //     length = 0;
+    //     float* result6 = xplane.getFloatArray("sim/aircraft/prop/acf_prop_dir", length);
+    //     printf("Got %zu values:", length);
+    //     for(size_t i = 0; i<length; ++i) {
+    //         if (i>0) printf(",");
+    //         printf(" %f", result6[i]);
+    //     }
+    //     printf("\n\n");
+
+    //     printf("Setting the number of the engines to %d...\n", numEngines + 1);
+    //     xplane.setInt("sim/aircraft/engine/acf_num_engines", numEngines + 1);
+    //     numEngines = xplane.getInt("sim/aircraft/engine/acf_num_engines");
+    //     printf("The new number of engines: %d\n\n", numEngines);
+
+    //     float acfElevUp = xplane.getFloat("sim/aircraft/controls/acf_elev_up");
+    //     printf("Setting the aircraft elevator up control from %f to %f...\n",
+    //            acfElevUp, acfElevUp + 15.0);
+    //     xplane.setFloat("sim/aircraft/controls/acf_elev_up", acfElevUp);
+    //     acfElevUp = xplane.getFloat("sim/aircraft/controls/acf_elev_up");
+    //     printf("The aircraft elevator up control set to %f\n\n", acfElevUp);
+
+    //     double localX = xplane.getDouble("sim/flightmodel/position/local_x");
+    //     printf("Setting the aircraft's local X-coordinate from %f to %f...\n",
+    //            localX, localX + 15.0);
+    //     xplane.setDouble("sim/flightmodel/position/local_x", localX + 15.0);
+    //     localX = xplane.getDouble("sim/flightmodel/position/local_x");
+    //     printf("The aircraft's local X-coordinate set to %f\n\n", localX);
+
+    //     float numBlades[8];
+    //     length = xplane.getFloatArray("sim/aircraft/prop/acf_num_blades",
+    //                                   numBlades, sizeof(numBlades)/sizeof(numBlades[0]));
+
+    //     printf("Setting the number of blades\n    from:");
+    //     for(size_t i = 0; i<length; ++i) {
+    //         if (i>0) printf(",");
+    //         printf(" %f", numBlades[i]);
+    //     }
+    //     printf("\n    to:");
+    //     for(size_t i = 0; i<length; ++i) {
+    //         numBlades[i] += 2.5;
+    //         if (i>0) printf(",");
+    //         printf(" %f", numBlades[i]);
+    //     }
+    //     printf("\n");
+    //     xplane.setFloatArray("sim/aircraft/prop/acf_num_blades",
+    //                          numBlades, length);
+    //     length = xplane.getFloatArray("sim/aircraft/prop/acf_num_blades",
+    //                                   numBlades, sizeof(numBlades)/sizeof(numBlades[0]));
+    //     printf("The result:");
+    //     for(size_t i = 0; i<length; ++i) {
+    //         if (i>0) printf(",");
+    //         printf(" %f", numBlades[i]);
+    //     }
+    //     printf("\n\n");
+
+    //     int32_t batteryArrayOn[8];
+    //     length = xplane.getIntArray("sim/cockpit/electrical/battery_array_on",
+    //                                 batteryArrayOn,
+    //                                 sizeof(batteryArrayOn)/sizeof(batteryArrayOn[0]));
+
+    //     printf("Setting the batteries\n    from:");
+    //     for(size_t i = 0; i<length; ++i) {
+    //         if (i>0) printf(",");
+    //         printf(" %d", batteryArrayOn[i]);
+    //     }
+    //     printf("\n    to:");
+    //     for(size_t i = 0; i<length; ++i) {
+    //         batteryArrayOn[i] = !batteryArrayOn[i];
+    //         numBlades[i] += 2.5;
+    //         if (i>0) printf(",");
+    //         printf(" %d", batteryArrayOn[i]);
+    //     }
+    //     printf("\n");
+    //     xplane.setIntArray("sim/cockpit/electrical/battery_array_on",
+    //                        batteryArrayOn, length);
+    //     length = xplane.getIntArray("sim/cockpit/electrical/battery_array_on",
+    //                                 batteryArrayOn,
+    //                                 sizeof(batteryArrayOn)/sizeof(batteryArrayOn[0]));
+    //     printf("The result:");
+    //     for(size_t i = 0; i<length; ++i) {
+    //         if (i>0) printf(",");
+    //         printf(" %d", batteryArrayOn[i]);
+    //     }
+    //     printf("\n\n");
+
+    //     uint8_t tailNum[40];
+    //     memset(tailNum, 0, sizeof(tailNum));
+    //     strcpy(reinterpret_cast<char*>(tailNum), "HA-VAI");
+    //     printf("Setting the tail number to %s as a byte array...\n", tailNum);
+    //     xplane.setByteArray("sim/aircraft/view/acf_tailnum",
+    //                         tailNum, sizeof(tailNum));
+    //     printf("The tail number is: '%s'\n\n",
+    //            xplane.getString("sim/aircraft/view/acf_tailnum").c_str());
+
+    //     static const char* tailNum1 = "VAI";
+    //     printf("Setting the tail number to %s as a string...\n", tailNum1);
+    //     xplane.setString("sim/aircraft/view/acf_tailnum", tailNum1, 40);
+    //     printf("The tail number is: '%s'\n\n",
+    //            xplane.getString("sim/aircraft/view/acf_tailnum").c_str());
+
+    //     try {
+    //         printf("Querying an invalid dataref...\n");
+    //         xplane.getInt("sim/aircraft/engine/num_engines");
+    //         printf("\n>>>>>>>>>>>> Succeeded!!!!!!!!!!!!!!!!!!!!!!\n\n");
+    //     } catch(const ProtocolException& exception) {
+    //         printf("Exception caugth: %s\n\n", exception.what());
+    //     }
+
+
+    //     return 0;
+    // } catch(const Exception& exception) {
+    //     printf("\n>>>>>>>>>>>>>>>>> Exception caugth: %s\n", exception.what());
+
+    //     return 1;
+    // }
+}
+
+//------------------------------------------------------------------------------
+
+// Local Variables:
+// mode: C++
+// c-basic-offset: 4
+// indent-tabs-mode: nil
+// End:
