Author Topic: macro newbie - how to run a macro on all files in a project?  (Read 4241 times)

PChady

  • Community Member
  • Posts: 18
  • Hero Points: 1
macro newbie - how to run a macro on all files in a project?
« on: April 07, 2008, 05:16:29 pm »
Hi,
I've not written any macros before.  I'm not sure how to approach what seems like
a simple problem - run a macro on all files in a project.

I was hoping to run an existing macro that a coworker wrote on all files within a single project.
Using active project or selecting project are fine.. but I want to isolate to one project, because
the macro I want to run alters the files - it's a reformatting thing.

I see from the demo linecount.e that there is the possibility of running a macro function
on everything in a workspace.
the demo uses:
    _GetWorkspaceFiles( )
 and then GetProjectfiles( )

After discovering the macros folder under slickedit, and looking at how some functions are written,
it looks like I may just want call GetProjectfiles( ) with the variable    _project_name.
  Sound right?
I'm guessing this based on usage - I haven't seen a description for _project_name.

(This all seems sort of obscure..  is there something more obvious I haven't noticed?
Surely this has been done many times before...)
I was also looking at making this a project command in the project properties, under tools.
I just can't figure out how to apply a "macro command" to many files at once,
without writing a new macro to perform the looping..

any tips appreciated..

thanks,
P Chady


PChady

  • Community Member
  • Posts: 18
  • Hero Points: 1
Re: macro newbie - how to run a macro on all files in a project?
« Reply #1 on: April 09, 2008, 09:41:45 pm »
Answering my own original question, for the sake of search results..

yes, calling GetProjectfiles( ) with the variable    _project_name gets the list of files in the current project.

                       _project_name =  the name of the Current Active project,

and furthermore,    p_buf_name   =  name of the current buffer / file / window in the editor.

I couldn't find these listed in docs, I just found references in the macros files in C:\Program Files\SlickEdit 2007\macros

Modifying the "linecount.e" demo was an easy way to apply a task to many files.

Now if I could get my modified files to save...
I keep getting errors reported when I try to do               status = _save_file('+FD') ;

P

hs2

  • Senior Community Member
  • Posts: 2733
  • Hero Points: 285
Re: macro newbie - how to run a macro on all files in a project?
« Reply #2 on: April 09, 2008, 10:32:00 pm »
'save_all' could be an easy way.
Good luck, HS2