CnPack Forum


 
Subject: Script? Getting fully qualified file names of all files of an project
cnpackfan
灌水科科长
Rank: 3Rank: 3



UID 22133
Digest Posts 0
Credits 124
Posts 43
点点分 124
Reading Access 10
Registered 2007-8-4
Status Offline
Post at 2011-3-25 06:23  Profile | Blog | P.M. 
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
Top
Passion (LiuXiao)
管理员
Rank: 9Rank: 9Rank: 9


UID 359
Digest Posts 19
Credits 6838
Posts 3591
点点分 6838
Reading Access 102
Registered 2004-3-28
Status Offline
Post at 2011-3-27 20:01  Profile | Blog | P.M. 
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.
Top
Passion (LiuXiao)
管理员
Rank: 9Rank: 9Rank: 9


UID 359
Digest Posts 19
Credits 6838
Posts 3591
点点分 6838
Reading Access 102
Registered 2004-3-28
Status Offline
Post at 2011-4-1 20:40  Profile | Blog | P.M. 
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.
Top
cnpackfan
灌水科科长
Rank: 3Rank: 3



UID 22133
Digest Posts 0
Credits 124
Posts 43
点点分 124
Reading Access 10
Registered 2007-8-4
Status Offline
Post at 2011-4-5 21:54  Profile | Blog | P.M. 
Hello again Passion,

many thanks for that script. Will try it.


Greetings
cnpackfan
Top
 




All times are GMT++8, the time now is 2024-11-25 00:15

    本论坛支付平台由支付宝提供
携手打造安全诚信的交易社区 Powered by Discuz! 5.0.0  © 2001-2006 Comsenz Inc.
Processed in 0.007073 second(s), 9 queries , Gzip enabled

Clear Cookies - Contact Us - CnPack Website - Archiver - WAP