Menu

default code in new source file in v4.9.9.2

2006-02-01
2012-09-26
  • Nobody/Anonymous

    can anybody help? I want to set default code for new source files, but I can't seem to find where this is done in version 4.9.9.2. I have instructions for an earlier version that directs me to Environment Options, but the menus are now different...thanks....

     
    • S. Thomas Bradley

      Hi Everyone:

      Open your Dev-Cpp folder, then open the folder labeled Templates. In that folder you will find two types of files; Dev-C++ Template File and a corresponding Text document. Open the text document using a text editor and replace what you find with your stuff. Be sure to save it as a plain text file. It probably wouldn't be a bad idea to backup the file before changing it.

      See Ya
      Butch

       
    • Nobody/Anonymous

      Hi Everyone:

      Clifford is right, as usual. I just gave you a quick and dirty way to do what you wanted to do.

      Here is how you can create your own speciallized Project which will contain any source code you want.

      As an example, I am going create a project type called 'MyStuff' (ala drwayne).
      I want MyStuff to be a console app, but you can pick whichever type you want.
      And I want to always load the following code when I create a MyStuff project:

      include<iostream>

      include<stdlib.h> //only needed if you are using Dev 4 family

      using namespace std; //where the names are - like cout!

      int main(void)
      {
      cout << "This is what that putz Wayne said to do!\n";
      system("pause"); //keep the window open if running from Dev
      return 0;
      }

      So here is how you can do this:

      1) Open the folder Dev-Cpp\Templates
      2) Copy the Template called 2-ConsoleApp
      3) Rename this copy as 6-MyStuff and save it in the Template folder.
      4) Double click on 6-MyStuff to open it in Dev-Cpp
      5) When you open this it should look like this:

      [Template]
      ver=1
      Name=Console Application
      IconIndex=1
      Description=A console application (MSDOS window)
      Catagory=Basic

      [Unit0]
      CName=main.c
      CppName=main.cpp
      C=consoleapp_c.txt
      Cpp=consoleapp_cpp.txt

      [Project]
      UnitCount=1
      Type=1
      Name=Console App

      Change it to look like this:

      [Template]
      ver=1
      Name=My Stuff
      IconIndex=4
      Description=My projects
      Catagory=Basic

      [Unit0]
      CName=main.c
      CppName=main.cpp
      C=Myapp_c.txt
      Cpp=Myapp_cpp.txt

      [Project]
      UnitCount=1
      Type=1
      Name=Console App

      Note that I changed the following:
      Name=Console Application to Name=My Stuff
      Description=A console application (MSDOS window) to Description=My projects
      C=consoleapp_c.txt to C=Myapp_c.txt
      Cpp=consoleapp_cpp.txt to Cpp=Myapp_cpp.txt

      The code I listed above (where Wayne is a putz) is saved it as a text file called:
      Myapp_c.txt and Myapp_cpp.txt.

      You could create a different source code for the Myapp_cpp.txt if you wanted to.

      Anyway, after you save all this into the Template folder, when you create a new project with Dev-Cpp you should notice that your new project type is listed with the other types.
      I left the names CName=main.c and CppName=main.cpp but you could also change this. This is the name that appears in the tab at the top of your source code.

      Anyway, I hope this will help you out.

      See Ya
      Butch

       
      • Anonymous

        Anonymous - 2006-02-01

        I was just clarifying and indicating the further possibilities of templates, I did not intend you to go to that much trouble! ;) I hope the OP appreciates your efforts!

        Clifford

         
        • S. Thomas Bradley

          Clifford:

          Thats okay, isn't this why Wayne pays us the big bucks (excuse me, euros)! :-)

          See Ya
          Butch

           
    • Anonymous

      Anonymous - 2006-02-01

      Note that the template modification method required the you create your code using the project facility.

      It is also easy to add new templates, so you can have default code and compiler settings for a number of different project types.

      For the project settings you can cut and paste sections from the .dev file of a working project to get the samme settings for the template.

      Clifford

       

Log in to post a comment.

MongoDB Logo MongoDB