Author Topic: Check/Modify Project Title in ProjectPathPage  (Read 4075 times)

Offline Napoleon

  • Multiple posting newcomer
  • *
  • Posts: 59
Check/Modify Project Title in ProjectPathPage
« on: July 08, 2017, 08:35:44 am »
Hi,  I'm writing a wizard to suit a particular project structure I regularly need.
I need to make sure that when the user types in the project title, they include a string extension, ".machine", before they leave the ProjectPathPage.
I am using the OnLeave_ProjectPathPage(fwd) event handler but I don't know how to set the Wizard's variables, in order to automatically add the necessary extension.

I've noticed that the project gets created in the filesystem by the time the SetupProject(project) method is called, so it seems to me that the only place I can do the above is in the OnLeave_ProjectPathPage(fwd) event handler.

I've read the Wizard Scripting Commands page but haven't found what I need.  (1) The page is under construction, so who knows what's missing, and (2) The ProjectPathPage call does not take parameters, not returns any values.  So where does the user input go?

Any suggestions for resources that further explain the internals of the Wizard namespace/object?

Cheers,
Nap
« Last Edit: July 08, 2017, 11:05:55 am by Napoleon »

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: Check/Modify Project Title in ProjectPathPage
« Reply #1 on: July 09, 2017, 08:14:59 pm »
The best documentation is the code of the wizard ;)
If you find the time it would be great if you could improve the wiki...

I think i don't understand your problem at whole:
You need to add ".machine" to the project file? Somewhere between .cbp or after .cbp?
Should the user get informed about this (block the wizard page until he adds ".machine" ) ? Add it automatically always?

Offline Napoleon

  • Multiple posting newcomer
  • *
  • Posts: 59
Re: Check/Modify Project Title in ProjectPathPage
« Reply #2 on: July 12, 2017, 06:22:38 pm »
Here is an example of what I am trying to achieve:
If the user types "BallFollower" as the title of the project in the ProjectPathPage, I would like to append ".machine" to it.  Our build process requires the .machine extension to be present in the name of the folder that contains all the sources.  This identifies the codebase to be a Logic Labelled Finite State Machine.  The actual cbp filename is not important as it is .gitignored anyway.
In order to make things easy to follow, I would like the title in the workspace and the project folder and cbp project names to be consistent, however, the folder name is the most important to get right.

I'm using a custom Wizard to massage the project's targets and set custom make commands to suit our needs. That part is working fine  :).  Since my original post, I have resorted to using a ShowMessage in the OnLeave_ProjectPathPage(fwd) event handler to alert the user that they need to enter the extension, and return false until they do so.

However, I would like to automate this.  So, the problem that I'm facing is that the user's input on the ProjectPathPage cannot be edited in the OnLeave_ProjectPathPage(fwd) event handler because the page does not expose any setters for it's variables.

I tried using:
Code
    local machineName= Wizard.GetProjectName();
    if (machineName.Find(_T(".machine")) < 1) {
      GetProjectManager().GetActiveProject().SetTitle(machineName + _T(".machine"));
    }
In the OnLeave_ProjectPathPage(fwd) event handler, to set the title but that does not set the same variable which is later used by the Wizard to create the project folder and cbp project file.  In fact, the above code cannot be used in the OnLeave_ProjectPathPage(fwd) event handler because it renames the wrong project if there are existing projects in the workspace, one of which will, naturally, be already active.

Delaying the above code to the start of the SetupProject(project) function allows me to change the title, but not the names of the folder and CB project.  So, only one out of three requirements achieved.

Is there a way of setting the Wizard's internal variables (like m_Wizards[index].title)?  (I've looked at wiz.cpp and it does not appear to be possible.)

[I have attached my wizard.script file, with a .txt extension to pass the forum's filter.]

Offline Napoleon

  • Multiple posting newcomer
  • *
  • Posts: 59
Re: Check/Modify Project Title in ProjectPathPage
« Reply #3 on: July 12, 2017, 06:38:58 pm »
@BlueHazzard : The 'concept' you suggested in response to my other question has solved the problem I was facing.
I can now append .machine automatically using:
Code
    local machineName= Wizard.GetProjectName();
    if (machineName.Find(_T(".machine")) < 1) {
      ShowMessage(_T("The '.machine' extension will be automatically added to the title of the project."));
      Wizard.SetTextControlValue(_T("ID_TEXTCTRL3"), machineName + _T(".machine"))
    }
In the OnLeave_ProjectPathPage(fwd) event handler.

Thank you for looking into this for me!

Cheers,
Nap

Offline Napoleon

  • Multiple posting newcomer
  • *
  • Posts: 59
Re: Check/Modify Project Title in ProjectPathPage
« Reply #4 on: July 13, 2017, 02:52:51 am »
I would be happy to update the information about the ProjectPathPage and other things I've worked out or been helped with.  I believe additional permissions are needed to edit content on that page?  I haven't tried yet.

You should also get connected to LetsEncrypt for https: access.