Index: trunk/ippTools/src/regtool.c
===================================================================
--- trunk/ippTools/src/regtool.c	(revision 12096)
+++ trunk/ippTools/src/regtool.c	(revision 12131)
@@ -41,5 +41,5 @@
 // static guidePendingExpRow *newToP1PendingExp(newExpRow *newExp);
 static chipPendingExpRow *newTochipPendingExp(pxConfig *config, newExpRow *newExp);
-static chipPendingImfileRow *rawImfileTochipPendingImfile(pxConfig *config, rawImfileRow *rawImfile);
+static chipPendingImfileRow *rawImfileTochipPendingImfile(pxConfig *config, psS64 chip_id, rawImfileRow *rawImfile);
 
 static rawExpRow *newToRawExp(pxConfig *config, newExpRow *exp);
@@ -664,4 +664,7 @@
             return false;
         }
+
+        // get the chip_id for the imfiles
+        psS64 chip_id = psDBLastInsertID(config->dbh);
         psFree(chipPendingExp);
 
@@ -712,5 +715,5 @@
         for (long i = 0; i < psArrayLength(rawImfiles); i++) {
             rawImfileRow *rawImfile = rawImfiles->data[i];
-            chipPendingImfileRow *pendingImfile = rawImfileTochipPendingImfile(config, rawImfile);
+            chipPendingImfileRow *pendingImfile = rawImfileTochipPendingImfile(config, chip_id, rawImfile);
             if (!chipPendingImfileInsertObject(config->dbh, pendingImfile)){
                 // rollback
@@ -890,11 +893,11 @@
 
     chipPendingExpRow *chipExp = chipPendingExpRowAlloc(
-        exp->exp_tag,
-        0x0,            // chip version XXX calc version number
-        0xdeadbeef,     // guide version
-        label,
-        "my recipe",
-        NULL,           // groupa
-        NULL            // dvodb
+            0,              // chip ID, assigned by db
+            exp->exp_tag,
+            0xdeadbeef,     // guide version
+            label,
+            "my recipe",    // recipe
+            NULL,           // expgroup
+            NULL            // dvodb
     );
 
@@ -903,13 +906,13 @@
 
 
-static chipPendingImfileRow *rawImfileTochipPendingImfile(pxConfig *config, rawImfileRow *rawImfile)
+static chipPendingImfileRow *rawImfileTochipPendingImfile(pxConfig *config, psS64 chip_id, rawImfileRow *rawImfile)
 {
     return chipPendingImfileRowAlloc(
-        rawImfile->exp_tag,
-        0x0,          // chip version XXX calc version number
-        0xdeadbeef,   // guide version
-        rawImfile->class_id,
-        "my recipe",
-        rawImfile->uri
+            chip_id,
+            rawImfile->exp_tag,
+            0xdeadbeef,     // guide version
+            rawImfile->class_id,
+            "my recipe",    // recipe
+            rawImfile->uri
     );
 }
