Jump to content
bazzer747

What .PAS file does a form use?

Recommended Posts

Is there a simple way to find out what .pas file a form uses? 

 

I use ACE Reporter for my reporting and usually name my .pas file in a format like uRepCustomerList.pas so I can easily see all the report forms and what they do. I have a lot of .pas files in my project and for some reason when I created a certain report I didn't follow the usual system. So it could be named anything. I don't really want to open up every .pas file until the one I want pops up, so I'm thinking is there an easier way.

 

I might not be seeing the woods for the trees here, so apologies if this is a silly question.

Share this post


Link to post

Unless I misunderstand you completely, the .pas file have the same name as the .dfm file containing the form. 

 

37 minutes ago, bazzer747 said:

I might not be seeing the woods for the trees here

Well, that might indeed be the case, but you might describe your situation in more detail to clarify.

Share this post


Link to post

Using search, search all files in the project for the reporter component name and the unusual file name will be it.

  • Like 1

Share this post


Link to post

Uwe,

 

OK, more clarity :-). When I run my project, one of the buttons runs an Ace Report with a "sctRepCustList.Run" command. This runs the report which is on a form. I don't get to see the form, just the report output. It isn't like I have the report form open in the IDE where I would know know exactly what it is called and what name I save it with.

 

Mark,

 

A global search in all files doesn't show anything other than the form where I run the Ace Report from. 

  • Confused 1

Share this post


Link to post

 

Not sure to get entirely the issue scope, but if it is a units list related need, perhaps my 2 cents remain valuable : 

 

-> About Unit's list or unit depandancy (hell) issue, I personnaly used --graphviz delphi compiler option to get a "graphviz" file of units dependancy graph.
 

This option is available since delphi 12 (not sure) but it is relatively new... 

--> (graphviz)

 

I do not render really this graph, because it is not very usable (quickly complex :)), but I use it sometimes the *.gv file itself, which is pretty readable, in notepad or in ide to get a global idea of the mess 😉
 

We get a txt file with things such as :

[...]

    "myApp.frame.errorInfoDisplay" -> { "myApp.types" "myApp.frame.core" "myApp.frame.windowLikeDisplay" DKLang }
    "myApp.frame.windowLikeDisplay" -> { "myApp.types" "myApp.frame.core" DKLang }
    "myApp.frame.cockpitView" -> { DKLang "GS.Bus.Components.Core" "myApp.dm.system.appBus" "myApp.dm.system.appLang" "myApp.dm.system.appScenes" "myApp.dm.system.appCentral" "myApp.frame.core" }
    "myApp.frame.cockpitView" -> { "myApp.dm.appWidgetSet" "myApp.frame.mandat" } [arrowhead=open,style=dashed]

    "myApp.taskManager" 
    "myApp.dm.backend.Connections" -> { "myApp.consts" "myApp.busMsg" "myApp.dm.system.appBus" }
    "myApp.dm.backend.Connections" -> "myApp.dm.system.appCentral" [arrowhead=open,style=dashed]
    "myApp.dm.appWidgetSet" -> { "myApp.frame.widgets.dateTimeHours" "myApp.frame.widgets.languageSelector" "myApp.frame.widgets.ca2AppInfoWidget" [arrowhead=open,style=dashed]

[...]

The "[arrowhead=open,style=dashed]" mark the implementation localized uses.

 

I let you see graphviz syntax to get meaning here. It is a graph, so many info are availables.

 

That perhaps help you to get your "per form" unit's list ? 

 

Edited by Vincent Gsell

Share this post


Link to post

I'm working on a project like that; New units are named consistently after strict rules so we can easily locate the relevant unit. Old units are named after whatever the developer had time to type (and apparently he was always in a rush).

So I introduced a "magic" key that when pressed at run-time displays the name of the active form/frame. It's basically just a TApplicationEvents.OnShortCut on the main form:

image.png.f8eb74a688f285ecd3395df96b026314.png

 

procedure TFormAnynymizedToProtectTheGuilty.ApplicationEventsShortCut(var Message: TWMKey; var Handled: Boolean);
begin
{$ifdef DEBUG}
  if (Menus.ShortCutFromMessage(Message) = ShortCut(VK_F1, [ssAlt])) then
  begin
    if (Screen.ActiveCustomForm <> nil) then
    begin
      var Msg := '';
      // Find frames in the form
      var Control := Screen.ActiveControl;
      while (Control <> nil) and (Control <> Screen.ActiveCustomForm) do
      begin
        if (Control is TFrame) then
          Msg := Msg + Format('Embedded frame: %s in %s.pas', [Control.ClassName, Control.UnitName]) + #13
        else
        if (Control is TForm) then
          Msg := Msg + Format('Embedded form: %s in %s.pas', [Control.ClassName, Control.UnitName]) + #13;
        Control := Control.Parent;
      end;
      Msg := Msg + Format('Active form: %s in %s.pas', [Screen.ActiveCustomForm.ClassName, Screen.ActiveCustomForm.UnitName]);

      TaskMessageDlg('YOU ARE IN A MAZE OF TWISTY LITTLE PASSAGES, ALL ALIKE.', Msg, mtInformation, [mbOK], 0);
    end;

    Handled := True;
  end;
{$endif DEBUG}
end;

 

Share this post


Link to post
38 minutes ago, bazzer747 said:

A global search in all files doesn't show anything other than the form where I run the Ace Report from.  

Then put a break point in the form button. I am confused how you know where the "report" is launched from and cannot find the "report" unit from the calling location.

Share this post


Link to post

Did you search for sctRepCustList? Then search for the type of that variable and you get your report form.

Share this post


Link to post

There must be something in the .DFM files where you can see if it is a specific report form, like a component class/name or a specific button name.

Can't you search in your .DFM text files for such indicator? The name of the .DFM file is then the same as the .PAS file.

Share this post


Link to post

Can you run your project under the debugger, then put a breakpoint on the button press and then single step into the code that shows the form. That will bring the form .pas (and .dfm) into the IDE

Share this post


Link to post

Roger,

Have tried the debugger route, after I press F7 on the "sctRepCustList.run" the report is created and the IDE just goes to the next line. Here is the code for the button that runs the report: So it doesn't step into the form where the report has been created.

 

procedure TfCompetitions.btnReportClick(Sender: TObject);
var
  bRec: TBookMark;
begin
//First save the record we are on in the dbgGrid dbgrid
bRec:= dm.qCompetitions.GetBookmark;
dm.qvCompEnrolments.Open('SELECT * FROM vPGCCompEnrolments ORDER BY Yes DESC, Maybe DESC');
dm.qvCompEnrolments.DisableControls;
//Run the report
fRepCompEnrolment.sctRepCustListt.Run;
dm.qvCompEnrolments.Open('SELECT * FROM vPGCCompEnrolments ORDER BY CompDate, Yes DESC, Maybe DESC, DateBooked DESC, SName');

//Now restore the record we were on in dbgGrid ...
dm.qCompetitions.GotoBookmark( bRec );
dm.qvCompEnrolments.EnableControls;
end;

 

I have also emailed the creator of Ace Report who is very good at responding to support queries. If/when he answers I'll post it here.

 

I'll maybe try some of the other suggestions, many thanks for helping.

Share this post


Link to post

Something to try: Look at a report .pas file for anything that will tell it apart from other non-report .pas files - like use of an ACE Report object/component name. Then do a Find in Files ... for it and see if any results have a .pas file with a name that doesn't follow your usual pattern.

Edited by Brian Evans

Share this post


Link to post
1 hour ago, bazzer747 said:

//Run the report
fRepCompEnrolment.sctRepCustListt.Run;

Then, unless I am more confused, fRepCompEnrolment is on the same form, in another form declared in a "uses" on the form, or global.

Edited by Mark-

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×