Author Topic: [SOLVED] How to run script automaticaly before create new project?  (Read 724 times)

Iosif Stalin

  • Community Member
  • Posts: 12
  • Hero Points: 0
Is it possible to insert script into custom project type which will run when I create a new project?
I want to add some default files into created project automaticaly.
« Last Edit: December 19, 2018, 01:43:47 pm by Iosif Stalin »

Graeme

  • Senior Community Member
  • Posts: 2449
  • Hero Points: 323
Re: How to run script automaticaly before create new project?
« Reply #1 on: December 19, 2018, 12:28:09 am »
There's a macro function you can call to add a file to the current project - project_add_file.

Another way is in the project properties dialog on the "Files" tab, in the bottom right corner there is an "import" button.  It allows you to import a list of files from a file  - see "import files" in the help.

Iosif Stalin

  • Community Member
  • Posts: 12
  • Hero Points: 0
Re: How to run script automaticaly before create new project?
« Reply #2 on: December 19, 2018, 05:49:21 am »
So, am I right that files can't be created and added automaticaly after creating a new project (and there is no "constructor" wich can run a *.bat for example)?
« Last Edit: December 19, 2018, 05:52:42 am by Iosif Stalin »

Graeme

  • Senior Community Member
  • Posts: 2449
  • Hero Points: 323
Re: How to run script automaticaly before create new project?
« Reply #3 on: December 19, 2018, 08:30:08 am »
um, well, if you don't mind making changes to the shipped slick C code you might be able to do it like this.  The lines of code below can be found in the workspace_new_project2 function in the project.e source file.  The first line was added by me.  It adds the gp123.txt file to the project just before the project properties dialog appears.  It's not a very nice way to do it though.

Code: [Select]
      project_add_file('c:/gp/gp123.txt');       // <<<<<<<<<<<<<< added
      if (ShowPropertiesDialog) {
         result=show('-modal -mdi -xy _project_form',new_project_name,_ProjectHandle(new_project_name),PROJECTPROPERTIES_TABINDEX_FILES);
         //toolbarUpdateFilterList(new_project_name);
      }

Another possibility is to create a new project but with no files in it.  Then open the project.vpj file in a text editor and scroll down to the "Files" xml node near the end.  You could write some software to add whatever source files you wanted to the project xml file and use it as the start of a new project file  - or if you don't want to modify the xml, make the workspace and the project active and call the project_add_file function (like I do above) to add whatever files you want.
So you could create a new dialog using the slick C form designer with an edit box on it for someone to enter the project name, you then make a copy of the project xml file template, give it a new name, create a workspace xml file as well, make it active, then call project_add_file repeatedly to add whatever files you want, then call the project_edit command to open the project properties dialog.  You can probably use the copy_file function to create any files you need.



Iosif Stalin

  • Community Member
  • Posts: 12
  • Hero Points: 0
Re: How to run script automaticaly before create new project?
« Reply #4 on: December 19, 2018, 01:43:14 pm »
Thank you very much!
« Last Edit: December 24, 2018, 06:53:16 am by Iosif Stalin »