Author Topic: loading files loses tag info?  (Read 6875 times)

cgsna@yahoo.com

  • Community Member
  • Posts: 13
  • Hero Points: 0
loading files loses tag info?
« on: January 17, 2007, 03:01:29 PM »
Ok, this is a new question after getting the "traverse subdirectories" one solved (with Graeme's help, of course).  This is the code I currently have:

defmain()

   int i = 0;
   int j = 0;

   parse arg(1) with StartPath FileType[0] FileType[1] FileType[2] FileType[3] .;

   while(FileType[j] != '')
   {
      _str filename = file_match(StartPath :+ '\' :+ FileType[j++]' +d +t',1);

      while(filename != '')
      {
         load_files('+w 'filename);
         i++;       
         _set_focus();
     
         sticky_message('file found='filename);     
         filename= file_match(filename,0);
         delay(5);         
      }
   }
   sticky_message(i' files loaded');
}

This works fine (for the most part, but more on that later), and opens up all of the files of the types specified on the command line in the parrent directory and all subdirectories.  However, all tag information, I guess, or something, is gone, and I can't seem to get it back.  For example, I have a 'Defs' pane open in the editor, and if I go open files in my test path manually, as each file opens, all of the Defs information is there, showing a list of functions in each file, global symbols, etc.  However, when I open the same files with the script above, all that shows is the filenames alone, and I have to manually close the Defs pane and then reopen it before I can even get that. 

The tag functions are many in number, and of course, lacking in the documentation department.  Could anyone shed any light? 

Thanks,
Clark

hs2

  • Senior Community Member
  • Posts: 2761
  • Hero Points: 292
Re: loading files loses tag info?
« Reply #1 on: January 17, 2007, 04:04:53 PM »
I think it's better to use edit() instead of (low level) load_files().
edit automatcally selects the right 'mode' (e.g. 'C' ) and invokes all neccessary callbacks to update the toolbars etc.
Using 'edit' _set_focus() is also not longer needed.

HS2

cgsna@yahoo.com

  • Community Member
  • Posts: 13
  • Hero Points: 0
Re: loading files loses tag info?
« Reply #2 on: January 17, 2007, 10:01:05 PM »
Thanks HS2.  However, when I substitued edit() or e() for load_files(), it loaded only one file, and then the program ended normally with "1 file found".  So something must have killed my loop structure causing the subsequent file_match call to return a ' '.  Next I tried edit_file(), and it behaved identically to load_files() both with and without the _set_focus() included.  Any ideas?

hs2

  • Senior Community Member
  • Posts: 2761
  • Hero Points: 292
Re: loading files loses tag info?
« Reply #3 on: January 18, 2007, 02:34:32 PM »
Hi Clark

I tried to re-arrange your macro (split into 1. build file list 2. load/edit file list). I think this will help to get it working and allows to take care about load order. It also gives an idea about using (very helpful) lists in Slick-C.

Code: [Select]
defmain()
{
   parse arg(1) with StartPath FileType[0] FileType[1] FileType[2] FileType[3] .;

   int i, j = 0;
   while(FileType[j] != '')
   {
      // build list of files
      typeless filelist[];

      _str filename = file_match(StartPath :+ '\' :+ FileType[j++]' +d +t',1);
      while( filename != '' );
      {
         filelist [ filelist._length() ] = filename;

         sticky_message('file found='filename);
         delay(5);

         // get next file
         filename = file_match(filename,0);
      }

      sticky_message( filelist._length()' files found' );
      delay(5);

      // edit list of files
      int numfiles = filelist._length();
      for ( i = filelist._length() -1; i >= 0; i-- )
      {
         status = edit('+l ' maybe_quote_filename( filelist [ i ] ));

         // adjust some buffer props
         if ( !status )
         {
            p_buf_flags=p_buf_flags & (~VSBUFFLAG_HIDDEN);
            if ( p_window_state=='I' ) p_window_state='N';
         }
         else
         {
            // edit failed
            numfiles--;
         }
      }

      sticky_message( numfiles' files successfully loaded' );
   }
}

Good luck,

HS2

cgsna@yahoo.com

  • Community Member
  • Posts: 13
  • Hero Points: 0
Re: loading files loses tag info?
« Reply #4 on: January 20, 2007, 04:12:13 AM »
Thanks HS2.  I have not had an opportunity to try to incorporate any or all of your suggested code, but I will let you know the results the minute I do.

cgsna@yahoo.com

  • Community Member
  • Posts: 13
  • Hero Points: 0
Re: loading files loses tag info?
« Reply #5 on: January 20, 2007, 10:03:32 PM »
HS2.  Something in your code caused my machine to lock up, consistently, requiring me to kill the task before proceeding.  I have not, yet at least, taken the time to figure out exactly what.  However, I did use parts of your code, and your idea about using a list and splitting it into 2 parts, and it is now working nicely.  Thanks.

cgsna@yahoo.com

  • Community Member
  • Posts: 13
  • Hero Points: 0
Re: loading files loses tag info?
« Reply #6 on: January 22, 2007, 04:08:37 PM »
One of my coworkers who will also be using the batch file wants a little something different.  So, my next question would be:   

How do I accomplish the very same thing, with one exception, i.e. loading the buffers but not opening them into their respective windows?  I searched for this but never found what I was looking for.  Once I figure out how to do this, I can offer the option as a command line switch.

Here is the code as it exists today:

Code: [Select]
#include "slick.sh"

defmain()

   int i=0, j=0, k=0;
   typeless filelist[];

   parse arg(1) with StartPath FileType[0] FileType[1] FileType[2] FileType[3] .;

   while(FileType[j] != '')
   {
      _str filename = file_match(StartPath :+ '\' :+ FileType[j++]' +d +t',1);

      while(filename != '')
      {
         i++;
         filelist[filelist._length()] = filename;     
         filename= file_match(filename,0);
      }
   }

   for(j = filelist._length() -1; j >= 0; j--)
   {
      status = edit('+l ' maybe_quote_filename(filelist [j]));
      if(!status)
      {
         sticky_message('file loaded = 'filelist[j]);     
         delay(5);
         k++;
      }
   }

   sticky_message(i' files found. 'k' files sucessfully loaded.');
}

Thanks,
Clark