Author Topic: Adding files to a project  (Read 3301 times)

preiter

  • Junior Community Member
  • Posts: 3
  • Hero Points: 0
Adding files to a project
« on: October 08, 2010, 09:46:17 pm »
Oftentimes when creating a new project I will find the files I need to edit by using an in-house search tool.

So I have a list of files in a shell that I want to make into a project. I have been copy/pasting them one at a time into the "Add Files" dialog box, but that's kind of tedious. Is there a better way?

On a similar note. Often I find myself editing a file that I reached via tags and I wish to add it to a project. Is there a way to do that directly? Or do I need to use the Add Files dialog, navigate to the file and add it that way?

dmw

  • Senior Community Member
  • Posts: 145
  • Hero Points: 15
Re: Adding files to a project
« Reply #1 on: October 08, 2010, 11:49:44 pm »
With the file you want to add loaded in the current buffer, you can add it to your project from the SlickEdit command line by entering project-add-file.

I believe there's a way to run SE macros by executing vs (or vs.exe) with an appropriate switch.  I don't remember off-hand, but you should be able to find it in the docs - something like "invocation options" IIRC.  With this and a little work, you should be able to add files in a batch.

Graeme

  • Senior Community Member
  • Posts: 2515
  • Hero Points: 327
Re: Adding files to a project
« Reply #2 on: October 09, 2010, 12:06:41 am »
As dmw said, you can use the project-add-file command on the command line or bind a key to it.

After writing the code below I noticed an (undocumented) "import" button in the project properties dialog (bottom right)  which appears to read a list of filenames from a file so you could try that!

You can also use the xadd command below to read a list of filenames from the current buffer.  To load the code, open (or create) vusrmac.e in your configuration folder and use the load module command on the macro menu.

Code: [Select]
#include "slick.sh"
static int prompt_add_file_to_project(_str filename)
{
   while (true) {
      _str info1 = 'Active project: ' :+ _project_name;
      _str info2 = 'Working dir:    ' :+ getcwd();

      int result = textBoxDialog(
         "Add file to project", // Form caption
         0,      // Flags
         0,             // textbox width
         "",               // Help item
         "&Yes,Yes to &all,&No,&Explore,Cancel:_cancel\t" info1 "\n" info2" \n",
         "",  // retrieve name
         "File :" filename);

      if (result == COMMAND_CANCELLED_RC) {
         return 0;
      }
      switch (result) {
         case 4 :
            explore(_param1);
            continue;
         default:
            return result;
      }
   }
   return 0;
}

_command void xadd_files_to_project() name_info(','VSARG2_READ_ONLY|VSARG2_REQUIRES_EDITORCTL)
{
   int mode = 0;
   top();
   _str line;
   while (1) {
      get_line(line);
      if (file_exists(line)) {
         if (mode != 2)
            mode = prompt_add_file_to_project(line);
         switch (mode) {
            case 0 : return;
            case 3 : break;   // No
            default: project_add_file(line); break;
         }
      }
      if (down()) {
         return;
      }
   }
}
« Last Edit: October 09, 2010, 02:57:13 am by Graeme »