diff -r e50aabc8ad7f flexiconvert.module
--- a/flexiconvert.module	Wed Jun 03 22:17:40 2009 -0400
+++ b/flexiconvert.module	Wed Jun 03 23:56:02 2009 -0400
@@ -276,6 +276,9 @@ function flexiconvert_form() {
                              '#suffix' => '</div><div id="flexiconvert_title"><em>Check all</em></div></div>',
   );
 	
+
+  $form['max_nodes'] = array('#type' => 'textfield', '#size' => 3, '#title' => t('Sample size'), '#description' => t("Number of nodes to process in the current run. Leave blank to process all nodes that can be completed within the PHP max_execution_time or memory_limit."));
+
   $form['submit'] = array(
                           '#type' => 'submit',
                           '#value' => 'Convert',
@@ -299,6 +302,8 @@ function flexiconvert_form_validate($for
  * Implementation of hook_form_submit().
  */
 function flexiconvert_form_submit($form_id, $form_values) {
+
+  drupal_set_message(t("starting main flexiconvert engine"));
   // Keep track of created fields so we don't get SQL duplication errors.
   $fields_submitted = array();
 	
@@ -327,7 +332,8 @@ function flexiconvert_form_submit($form_
       $type_obj->custom = TRUE;
       $type_obj->modified = FALSE;
       $type_obj->locked = FALSE;
-	    
+
+      drupal_set_message(t("processing flexinode type %name", array('%name' => $ftype['title'])));
       node_type_save($type_obj);
     }
   } // End type conversion loop...
@@ -337,8 +343,8 @@ function flexiconvert_form_submit($form_
     if ($ffield['checked']) {	
       $type = flexiconvert_get_type($ffield['title']);
       foreach($type->fields as $fd) {
-        //	Much of the code that appears below is straight from the CCK module.
-        //	The code is quite messy and a bit hard to read but it gets the job done.
+        // Much of the code that appears below is straight from the CCK module.
+        // The code is quite messy and a bit hard to read but it gets the job done.
         $field_name = trim($fd['label']);
         $field_name = drupal_strtolower($field_name);
         $field_name = str_replace(array(' ', '-'), '_', $field_name);
@@ -350,7 +356,9 @@ function flexiconvert_form_submit($form_
           // Prevent unnecessary duplication of fields.
           break;
         }
-		    
+        
+        drupal_set_message(t("found field %name (%type)", array('%name' => $field_name, '%type' => $fd['field_type'])));
+
         $cck_type = _flexiconvert_field_to_cck($fd['field_type']);
 
         db_query("INSERT INTO {node_field} (field_name, type, global_settings, required, multiple, db_storage) VALUES ('%s', '%s', '%s', %d, %d, %d)", 
@@ -400,10 +408,22 @@ function flexiconvert_form_submit($form_
   } // End field conversion loop...
 	
   // Data conversion
+
+  $max_nodes = $form_values['max_nodes'];
+  $count = 0;
+
+  if ($max_nodes) {
+    $limit = ' LIMIT %d';
+  } else {
+    $limit = '';
+    $max_nodes = '(no max)';
+  }
+
   foreach ($form_values['flexiconvert_type'] as $fdata) {
     if ($fdata['checked']) {
+      drupal_set_message(t("importing %count nodes from flexinode for %field", array('%count' => $max_nodes, '%field' => $fdata['title'])));
       $type = flexiconvert_get_type($fdata['title']);
-      $q = db_query("SELECT r.*, n.created, n.status, n.changed, n.comment, n.promote, n.moderate, n.sticky FROM {node_revisions} r, {node} n WHERE n.nid=r.nid AND n.type='%s'", ('flexinode-' . $type->ctype_id));
+      $q = db_query("SELECT r.*, n.created, n.status, n.changed, n.comment, n.promote, n.moderate, n.sticky FROM {node_revisions} r, {node} n WHERE n.nid=r.nid AND n.type='%s' ORDER BY n.nid" . $limit, ('flexinode-' . $type->ctype_id), $max_nodes);
 
       while ($node = db_fetch_object($q)) {
         $resave = new stdClass();
@@ -424,8 +444,8 @@ function flexiconvert_form_submit($form_
         $resave->sticky = $node->sticky;
 				
         $fq = db_query('SELECT * FROM {flexinode_data} WHERE nid=%d', $resave->nid);
+
         // Get the flexinode field data.
-				
         while ($fnode = db_fetch_object($fq)) {
           foreach ($type->fields as $fd) {
             if ($fd['field_id'] == $fnode->field_id) {
@@ -441,13 +461,15 @@ function flexiconvert_form_submit($form_
           }
         }
 				
-        content_submit($resave);
+        content_insert($resave);
         // No need to resave the node again-- it already exists!
         // So instead we go straight to CCK because it will need 
         // to populate the content type tables.
+
+        db_query("UPDATE {node} SET type='%s' WHERE type='%s' AND nid='%d'", _flexiconvert_fix_single_type(strtolower($type->name)), ('flexinode-' . $type->ctype_id), $node->nid);
+        $count++;
       }
     }
-    db_query("UPDATE {node} SET type='%s' WHERE type='%s'", _flexiconvert_fix_single_type(strtolower($type->name)), ('flexinode-' . $type->ctype_id));
   } // End data conversion loop...
 	
   menu_rebuild();
@@ -456,6 +478,8 @@ function flexiconvert_form_submit($form_
   // file does not, we've got problems.
   if ($image_type_exists && !$image_module_exists) {
     drupal_set_message(t('All content was converted (including image types) but it was found that your installation contains the content type "image" but the image.module file was not enabled.  If this is true or you don\'t have alternate "image" type, then content of type "image" may cause errors upon viewing and/or editing.  It is strongly advised that you enable the image module and upload all of the respective image files to your files directory.'), 'error');
+  } else {
+    drupal_set_message(t('%count out of %max nodes were converted', array('%count' => $count, '%max' => $max_nodes)), 'status');
   }
 }
 
