Board logo

Subject: Script? Getting fully qualified file names of all files of an project [Print This Page]

Author: cnpackfan    Time: 2011-3-25 06:23     Subject: Script? Getting fully qualified file names of all files of an project

Hello again,

I'm looking for a way to get the fully qualified file names of all files of an project, mainly the source and header files. As a short term solution I'm looking for a script which copies the names to the clipboard. I can write it for the community, but need some suppport for starting. Another approach would be using the Source Statistics Wizard and add that functionality.

@ Passion and all the others: Thanks for that great tool!


Many thanks and greetings
cnpackfan
Author: Passion    Time: 2011-3-27 20:01

There's a Demo named OTADemo1.pas in PSDemo directory. It provides a way how to list all files of a project or projectgroup, or just opened files. But now it seems only works fine under Delphi 7 or above.

In BDS, maybe the Pascal Scrpit Engine has a bug that we can't get project modules. We're doing some research to avoid this problem.
Author: Passion    Time: 2011-4-1 20:40

We add some aux funtions in 0.9.7.598 nightly build. If this version installed, below script can be used to walk all module files from the project group.

{*******************************************************}
{                                                       }
{       Pascal Script Source File                       }
{       Run by RemObjects Pascal Script in CnWizards    }
{                                                       }
{       Generated by CnPack IDE Wizards                 }
{                                                       }
{*******************************************************}

program WalkingAllFiles;

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;

var
  PG: IOTAProjectGroup;
  P: IOTAProject;
  I, J, C1, C2: Integer;
begin
  PG := CnOtaGetProjectGroup;
  if PG = nil then
  begin
    Writeln('NO ProjectGroup. Exit.');
    Exit;
  end;
  C1 := CnOtaGetProjectCountFromGroup();
  Writeln('ProjectGroup got. Count ' + IntToStr(C1));

  for I  := 0 to C1 - 1 do
  begin
    P := CnOtaGetProjectFromGroupByIndex(I);
    if P <> nil then
    begin
      Writeln('Project ' + IntToStr(I) + '. Project File Name ' + P.GetFileName);
      C2 := CnOtaGetModuleCountFromProject(P);
      Writeln('Project ' + IntToStr(I) + '. Project Module Count ' + IntToStr(C2));
      for J := 0 to C2 - 1 do
        Writeln('Project ' + IntToStr(I) + ' . File ' + IntToStr(J) +
          '. File Name ' + CnOtaGetModuleFromProjectByIndex(P, J).GetFileName);
     end;
  end;
end.
Author: cnpackfan    Time: 2011-4-5 21:54

Hello again Passion,

many thanks for that script. Will try it.


Greetings
cnpackfan




Welcome to CnPack Forum (http://bbs.cnpack.org/) Powered by Discuz! 5.0.0