Index: /trunk/gui/apps/driver
===================================================================
--- /trunk/gui/apps/driver	(revision 364)
+++ /trunk/gui/apps/driver	(revision 365)
@@ -26,4 +26,5 @@
 # wish executes everything from here on...
 
+package require Itcl
 package require Rappture
 package require RapptureGUI
Index: /trunk/include/core/RpLibrary.h
===================================================================
--- /trunk/include/core/RpLibrary.h	(revision 364)
+++ /trunk/include/core/RpLibrary.h	(revision 365)
@@ -21,4 +21,5 @@
 #include <errno.h>
 #include <time.h>
+#include <iterator>
 
 #include <list>
@@ -33,4 +34,5 @@
 #define _RpLIBRARY_H
 
+
 class RpLibrary
 {
@@ -47,4 +49,5 @@
                                             std::string path);
 
+        bool isNull();
 
         // should return RpObject& but for simplicity right now it doesnt
@@ -55,4 +58,7 @@
                                 std::string type = "",
                                 int* childCount = NULL  );
+
+        RpLibrary& childCount ( std::string path,
+                                int* childCount);
 
         RpLibrary& copy       ( std::string toPath,
Index: /trunk/src/core/RpLibrary.cc
===================================================================
--- /trunk/src/core/RpLibrary.cc	(revision 364)
+++ /trunk/src/core/RpLibrary.cc	(revision 365)
@@ -110,39 +110,42 @@
     parent = scew_element_parent(node);
 
-    // if (name == NULL) {
-    if (name.empty()) {
-        siblings = scew_element_list(parent, type, &count);
-        if (count > 0) {
-            tmpCount = count;
-            while ((index < tmpCount) && (siblings[index] != node)) {
-                index++;
-            }
-
-            if (index < tmpCount) {
-
-                if (index > 0) {
-
-                    retVal << type << --index;
+    if (parent) {
+
+        // if (name == NULL) {
+        if (name.empty()) {
+            siblings = scew_element_list(parent, type, &count);
+            if (count > 0) {
+                tmpCount = count;
+                while ((index < tmpCount) && (siblings[index] != node)) {
+                    index++;
                 }
-                else {
-
-                    retVal << type;
+
+                if (index < tmpCount) {
+
+                    if (index > 0) {
+
+                        retVal << type << --index;
+                    }
+                    else {
+
+                        retVal << type;
+                    }
+
+                    /*
+                    if (retVal == NULL) {
+                        // error with allocating space
+                        return NULL;
+                    }
+                    */
                 }
-
-                /*
-                if (retVal == NULL) {
-                    // error with allocating space
-                    return NULL;
-                }
-                */
-            }
-        }
-
-        scew_element_list_free(siblings);
-
-    }
-    else {
-
-        retVal << name;
+            }
+
+            scew_element_list_free(siblings);
+
+        }
+        else {
+
+            retVal << name;
+        }
     }
 
@@ -173,33 +176,35 @@
     parent = scew_element_parent(node);
 
-    if (name.empty()) {
-        siblings = scew_element_list(parent, type, &count);
-        if (count > 0) {
-            tmpCount = count;
-            // figure out what the index value should be
-            while ((index < tmpCount) && (siblings[index] != node)) {
-                index++;
-            }
-
-            if (index < tmpCount) {
-                if (index > 0) {
-                    retVal << type << --index;
+    if (parent) {
+        if (name.empty()) {
+            siblings = scew_element_list(parent, type, &count);
+            if (count > 0) {
+                tmpCount = count;
+                // figure out what the index value should be
+                while ((index < tmpCount) && (siblings[index] != node)) {
+                    index++;
                 }
-                else {
-                    retVal << type;
+
+                if (index < tmpCount) {
+                    if (index > 0) {
+                        retVal << type << --index;
+                    }
+                    else {
+                        retVal << type;
+                    }
                 }
-            }
+
+            }
+            else {
+                // count == 0 ??? this state should never be reached
+            }
+            scew_element_list_free(siblings);
 
         }
         else {
-            // count == 0 ??? this state should never be reached
-        }
-        scew_element_list_free(siblings);
-
-    }
-    else {
-        // node has attribute id
-        retVal << type << "(" << name << ")";
-
+            // node has attribute id
+            retVal << type << "(" << name << ")";
+
+        }
     }
 
@@ -781,6 +786,6 @@
 
     if (path.empty()) {
-        // an empty path returns the current RpLibrary
-        return this;
+        // an empty path returns the parent of the current RpLibrary
+        path = this->nodePath();
     }
 
@@ -945,4 +950,57 @@
 
     return retLib;
+}
+
+/**********************************************************************/
+// METHOD: children()
+/// Returns a std::list<RpLibrary*> of all children under 'path'
+//
+// 
+/**
+ */
+
+RpLibrary&
+RpLibrary::childCount ( std::string path,
+                        int* childCount)
+{
+    scew_element* parentNode;
+    int myChildCount = 0;
+
+    if (this->root) {
+
+        if (path.empty()) {
+            // an empty path uses the current RpLibrary as parent
+            parentNode = this->root;
+        }
+
+        if (parentNode) {
+            myChildCount = scew_element_count(parentNode);
+        }
+
+        if (childCount) {
+            *childCount = myChildCount;
+        }
+
+    }
+
+    return *this;
+}
+
+/**********************************************************************/
+// METHOD: isNull()
+/// returns whether this RpLibrary is a valid library node
+//
+// 
+/**
+ */
+
+bool
+RpLibrary::isNull ()
+{
+    if (this->root) {
+        return false;
+    }
+
+    return true;
 }
 
Index: /trunk/src/tcl/src/RpLibraryTclInterface.cc
===================================================================
--- /trunk/src/tcl/src/RpLibraryTclInterface.cc	(revision 364)
+++ /trunk/src/tcl/src/RpLibraryTclInterface.cc	(revision 365)
@@ -178,5 +178,5 @@
     std::stringstream libName;
 
-    libName << "library" << libCount++;
+    libName << "::libraryObj" << libCount++;
 
     Tcl_CreateCommand(interp, libName.str().c_str(),
@@ -232,46 +232,60 @@
             if (strncmp(argv[nextarg],"-as",3) == 0) {
                 nextarg++;
-                if (    (*argv[nextarg] == 'c') &&
-                        (strncmp(argv[nextarg],"component",9) == 0) ) {
-                    asProc = &RpLibrary::nodeComp;
-                    nextarg++;
+                if (nextarg < argc) {
+                    if (    (*argv[nextarg] == 'c') &&
+                            (strncmp(argv[nextarg],"component",9) == 0) ) {
+                        asProc = &RpLibrary::nodeComp;
+                        nextarg++;
+                    }
+                    else if ((*argv[nextarg] == 'i') &&
+                             (strncmp(argv[nextarg],"id",2) == 0 ) ) {
+                        asProc = &RpLibrary::nodeId;
+                        nextarg++;
+                    }
+                    else if ((*argv[nextarg] == 't') &&
+                             (strncmp(argv[nextarg],"type",4) == 0 ) ) {
+                        asProc = &RpLibrary::nodeType;
+                        nextarg++;
+                    }
+                    else if ((*argv[nextarg] == 'p') &&
+                             (strncmp(argv[nextarg],"path",4) == 0 ) ) {
+                        asProc = &RpLibrary::nodePath;
+                        nextarg++;
+                    }
+                    else if ((*argv[nextarg] == 'o') &&
+                             (strncmp(argv[nextarg],"object",6) == 0 ) ) {
+                        asProc = NULL;
+                        nextarg++;
+                    }
+                    else {
+                        Tcl_AppendResult(interp, "bad flavor \"", argv[nextarg],
+                            "\": should be component, id, type, path, object",
+                            (char*)NULL);
+                        return TCL_ERROR;
+                    }
                 }
-                else if ((*argv[nextarg] == 'i') &&
-                         (strncmp(argv[nextarg],"id",2) == 0 ) ) {
-                    asProc = &RpLibrary::nodeId;
-                    nextarg++;
+                else {
+                    Tcl_AppendResult(interp, "bad flavor \"", argv[nextarg],
+                        "\": should be component, id, type, path, object",
+                        (char*)NULL);
+                    return TCL_ERROR;
                 }
-                else if ((*argv[nextarg] == 't') &&
-                         (strncmp(argv[nextarg],"type",4) == 0 ) ) {
-                    asProc = &RpLibrary::nodeType;
-                    nextarg++;
-                }
-                else if ((*argv[nextarg] == 'p') &&
-                         (strncmp(argv[nextarg],"path",4) == 0 ) ) {
-                    asProc = &RpLibrary::nodePath;
-                    nextarg++;
-                }
-                else if ((*argv[nextarg] == 'o') &&
-                         (strncmp(argv[nextarg],"object",6) == 0 ) ) {
-                    asProc = NULL;
+            }
+            else if (strncmp(argv[nextarg],"-type",5) == 0) {
+                nextarg++;
+                if (argc > nextarg) {
+                    type = std::string(argv[nextarg]);
                     nextarg++;
                 }
                 else {
-                    Tcl_AppendResult(interp, "bad option \"", argv[nextarg],
-                        "\": should be -as <fval> where <fval> is ", 
-                        "\'component\', \'id\', \'type\',",
-                        "\'path\', \'object\'",
+                    Tcl_AppendResult(interp, "bad flavor \"empty type\"",
+                        "\": should be a type of node within the xml",
                         (char*)NULL);
                     return TCL_ERROR;
                 }
             }
-            else if (strncmp(argv[nextarg],"-type",5) == 0) {
-                nextarg++;
-                type = std::string(argv[nextarg]);
-                nextarg++;
-            }
             else {
                 Tcl_AppendResult(interp, "bad option \"", argv[nextarg],
-                    "\": should be -as", (char*)NULL);
+                    "\": should be -as or -type", (char*)NULL);
                 return TCL_ERROR;
             }
@@ -472,35 +486,41 @@
             if (strncmp(argv[nextarg],"-as",3) == 0) {
                 nextarg++;
-                if (    (*argv[nextarg] == 'c') &&
-                        (strncmp(argv[nextarg],"component",9) == 0) ) {
-                    asProc = &RpLibrary::nodeComp;
-                    nextarg++;
-                }
-                else if ((*argv[nextarg] == 'i') &&
-                         (strncmp(argv[nextarg],"id",2) == 0 ) ) {
-                    asProc = &RpLibrary::nodeId;
-                    nextarg++;
-                }
-                else if ((*argv[nextarg] == 't') &&
-                         (strncmp(argv[nextarg],"type",4) == 0 ) ) {
-                    asProc = &RpLibrary::nodeType;
-                    nextarg++;
-                }
-                else if ((*argv[nextarg] == 'p') &&
-                         (strncmp(argv[nextarg],"path",4) == 0 ) ) {
-                    asProc = &RpLibrary::nodePath;
-                    nextarg++;
-                }
-                else if ((*argv[nextarg] == 'o') &&
-                         (strncmp(argv[nextarg],"object",6) == 0 ) ) {
-                    asProc = NULL;
-                    nextarg++;
+                if (nextarg < argc) {
+                    if (    (*argv[nextarg] == 'c') &&
+                            (strncmp(argv[nextarg],"component",9) == 0) ) {
+                        asProc = &RpLibrary::nodeComp;
+                        nextarg++;
+                    }
+                    else if ((*argv[nextarg] == 'i') &&
+                             (strncmp(argv[nextarg],"id",2) == 0 ) ) {
+                        asProc = &RpLibrary::nodeId;
+                        nextarg++;
+                    }
+                    else if ((*argv[nextarg] == 't') &&
+                             (strncmp(argv[nextarg],"type",4) == 0 ) ) {
+                        asProc = &RpLibrary::nodeType;
+                        nextarg++;
+                    }
+                    else if ((*argv[nextarg] == 'p') &&
+                             (strncmp(argv[nextarg],"path",4) == 0 ) ) {
+                        asProc = &RpLibrary::nodePath;
+                        nextarg++;
+                    }
+                    else if ((*argv[nextarg] == 'o') &&
+                             (strncmp(argv[nextarg],"object",6) == 0 ) ) {
+                        asProc = NULL;
+                        nextarg++;
+                    }
+                    else {
+                        Tcl_AppendResult(interp, "bad flavor \"", argv[nextarg],
+                            "\" for -as: should be component, id, type, path, object",
+                            (char*)NULL);
+                        return TCL_ERROR;
+                    }
                 }
                 else {
-                    Tcl_AppendResult(interp, "bad option \"", argv[nextarg],
-                        "\": should be -as <fval> where <fval> is ", 
-                        "\'component\', \'id\', \'type\',",
-                        "\'path\', \'object\'",
-                        (char*)NULL);
+                    Tcl_AppendResult(interp, "bad flavor \"\" for -as:", 
+                           " should be component, id, type, path, object",
+                            (char*)NULL);
                     return TCL_ERROR;
                 }
@@ -515,11 +535,15 @@
 
     argsLeft = (argc-nextarg);
-    if (argsLeft == 1) {
+    if (argsLeft > 1) {
+        Tcl_AppendResult(interp,
+            "wrong # args: should be \"element ?-as <fval>? ?<path>?\"",
+            (char*)NULL);
+        return TCL_ERROR;
+    }
+    else if (argsLeft == 1) {
         path = std::string(argv[nextarg++]);
     }
     else {
-        Tcl_AppendResult(interp, "incorrect number of arguments \"", argv[nextarg],
-            "\":", (char*)NULL);
-        return TCL_ERROR;
+        path = "";
     }
 
@@ -595,6 +619,6 @@
         Tcl_ResetResult(interp);
         Tcl_AppendResult(interp, 
-            "wrong # args: should be \"get ?path?\"",
-            "\":", (char*)NULL);
+            "wrong # args: should be \"isa <objType>\"",
+            (char*)NULL);
         return TCL_ERROR;
     }
@@ -636,34 +660,40 @@
             if (strncmp(argv[nextarg],"-as",3) == 0) {
                 nextarg++;
-                if (    (*argv[nextarg] == 'c') &&
-                        (strncmp(argv[nextarg],"component",9) == 0) ) {
-                    asProc = &RpLibrary::nodeComp;
-                    nextarg++;
-                }
-                else if ((*argv[nextarg] == 'i') &&
-                         (strncmp(argv[nextarg],"id",2) == 0 ) ) {
-                    asProc = &RpLibrary::nodeId;
-                    nextarg++;
-                }
-                else if ((*argv[nextarg] == 't') &&
-                         (strncmp(argv[nextarg],"type",4) == 0 ) ) {
-                    asProc = &RpLibrary::nodeType;
-                    nextarg++;
-                }
-                else if ((*argv[nextarg] == 'p') &&
-                         (strncmp(argv[nextarg],"path",4) == 0 ) ) {
-                    asProc = &RpLibrary::nodePath;
-                    nextarg++;
-                }
-                else if ((*argv[nextarg] == 'o') &&
-                         (strncmp(argv[nextarg],"object",6) == 0 ) ) {
-                    asProc = NULL;
-                    nextarg++;
+                if (nextarg < argc) {
+                    if (    (*argv[nextarg] == 'c') &&
+                            (strncmp(argv[nextarg],"component",9) == 0) ) {
+                        asProc = &RpLibrary::nodeComp;
+                        nextarg++;
+                    }
+                    else if ((*argv[nextarg] == 'i') &&
+                             (strncmp(argv[nextarg],"id",2) == 0 ) ) {
+                        asProc = &RpLibrary::nodeId;
+                        nextarg++;
+                    }
+                    else if ((*argv[nextarg] == 't') &&
+                             (strncmp(argv[nextarg],"type",4) == 0 ) ) {
+                        asProc = &RpLibrary::nodeType;
+                        nextarg++;
+                    }
+                    else if ((*argv[nextarg] == 'p') &&
+                             (strncmp(argv[nextarg],"path",4) == 0 ) ) {
+                        asProc = &RpLibrary::nodePath;
+                        nextarg++;
+                    }
+                    else if ((*argv[nextarg] == 'o') &&
+                             (strncmp(argv[nextarg],"object",6) == 0 ) ) {
+                        asProc = NULL;
+                        nextarg++;
+                    }
+                    else {
+                        Tcl_AppendResult(interp, "bad flavor \"", argv[nextarg],
+                            "\": should be component, id, type, path, object",
+                            (char*)NULL);
+                        return TCL_ERROR;
+                    }
                 }
                 else {
-                    Tcl_AppendResult(interp, "bad option \"", argv[nextarg],
-                        "\": should be -as <fval> where <fval> is ", 
-                        "\'component\', \'id\', \'type\',",
-                        "\'path\', \'object\'",
+                    Tcl_AppendResult(interp, "bad flavor \"", argv[nextarg],
+                        "\": should be component, id, type, path, object",
                         (char*)NULL);
                     return TCL_ERROR;
@@ -683,6 +713,7 @@
     }
     else {
-        Tcl_AppendResult(interp, "incorrect number of arguments \"", argv[nextarg],
-            "\":", (char*)NULL);
+        Tcl_AppendResult(interp, 
+            "wrong # args: should be \"parent ?-as <fval>? ?<path>?\"",
+            (char*)NULL);
         return TCL_ERROR;
     }
@@ -730,7 +761,24 @@
         if (nextarg < argc && *argv[nextarg] == '-') {
             if (strncmp(argv[nextarg],"-append",7) == 0) {
-                if (strncmp(argv[++nextarg],"yes",3) == 0 ) {
-                    append = 1;
-                    nextarg++;
+                ++nextarg;
+                if (nextarg < argc) {
+                    if (strncmp(argv[nextarg],"yes",3) == 0 ) {
+                        append = 1;
+                        nextarg++;
+                    }
+                    else if (strncmp(argv[nextarg],"no",2) == 0 ) {
+                        append = 0;
+                        nextarg++;
+                    }
+                    else {
+                        Tcl_AppendResult(interp, "expected boolean value but got \"",
+                            argv[nextarg], "\"", (char*)NULL);
+                        return TCL_ERROR;
+                    }
+                }
+                else {
+                    Tcl_AppendResult(interp, "expected boolean value but got \"",
+                        argv[nextarg], "\"", (char*)NULL);
+                    return TCL_ERROR;
                 }
             }
@@ -757,6 +805,7 @@
     }
     else {
-        Tcl_AppendResult(interp, "incorrect number of arguments \"", argv[nextarg],
-            "\":", (char*)NULL);
+        Tcl_AppendResult(interp, "wrong # args: should be ",
+            "\"put ?-append yes? ?-id num? ?<path>? <string>\"",
+            (char*)NULL);
         return TCL_ERROR;
     }
@@ -855,5 +904,5 @@
     if ( argc != 3 ) {
         Tcl_AppendResult(interp,
-            "usage: ", argv[0], " <xmlobj> <path>",
+            "wrong # args: should be \"value <xmlobj> <path>\"",
             (char*)NULL);
         return TCL_ERROR;
@@ -920,4 +969,10 @@
     std::string retStr = ""; // return value of rappture get fxn
 
+    if ( argc != 2 ) {
+        Tcl_AppendResult(interp, "wrong # args: should be \"", 
+                argv[0], " xml\"", (char*)NULL);
+        return TCL_ERROR;
+    }
+
     // call the Rappture Library xml Function
     retStr = ((RpLibrary*) cdata)->xml();
@@ -944,5 +999,6 @@
     // parse through command line options
     if (argc != 2) {
-        Tcl_AppendResult(interp, "usage: ", argv[0], " <xmlobj>", (char*)NULL);
+        Tcl_AppendResult(interp, "wrong # args: should be \"", 
+                argv[0], " <xmlobj>\"", (char*)NULL);
         return TCL_ERROR;
     }
Index: /trunk/test/src/RpLibrary_test.cc
===================================================================
--- /trunk/test/src/RpLibrary_test.cc	(revision 364)
+++ /trunk/test/src/RpLibrary_test.cc	(revision 365)
@@ -326,4 +326,5 @@
     lib = new RpLibrary(std::string(argv[1]));
 
+    test_element(lib,"");
     test_element(lib,"input.number(min)");
     test_element(lib,"input.number(max)");
