Add default text to each new code page

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
blueb
Addict
Addict
Posts: 1111
Joined: Sat Apr 26, 2003 2:15 pm
Location: Cuernavaca, Mexico

Add default text to each new code page

Post by blueb »

Since I occasionally get bugs that could easily be solved by using EnableExplicit...

Is it possible to add an Editbox on the General Preferences Dialog that would enable a user to add some default text to each new codepage?

example:

X - Add the following text to each new codepage:

Code: Select all


; ===============================
;  Fill in specific details:
;  Date:
;  Version:
;  Coded by:
; ===============================
EnableExplicit
- It was too lonely at the top.

System : PB 6.21(x64) and Win 11 Pro (x64)
Hardware: AMD Ryzen 9 5900X w/64 gigs Ram, AMD RX 6950 XT Graphics w/16gigs Mem
User avatar
Tenaja
Addict
Addict
Posts: 1959
Joined: Tue Nov 09, 2010 10:15 pm

Re: Add default text to each new code page

Post by Tenaja »

Yes, either a text header, or a default template file would be nice.
User avatar
luis
Addict
Addict
Posts: 3893
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: Add default text to each new code page

Post by luis »

You can already have many different templates in the Template tool.
Just select the one you want when starting a new program and double click on it.

I have for example a template with a minimal event loop and a window I use when I want to test something quickly.
"Have you tried turning it off and on again ?"
A little PureBasic review
User avatar
Tenaja
Addict
Addict
Posts: 1959
Joined: Tue Nov 09, 2010 10:15 pm

Re: Add default text to each new code page

Post by Tenaja »

luis wrote:You can already have many different templates in the Template tool....
This is an issue with the HELP file; the word "Template" turns up only one hit--WebGadget(), of all things.

I guess it has been a while since I started a new "project". Lately, I have either been working on existing ones, or short projects that do not need a "project" file.
User avatar
luis
Addict
Addict
Posts: 3893
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: Add default text to each new code page

Post by luis »

I'm not sure to understand the part about the projects in relation to the template tool :?:

About the template tool: if you search template"S" it will return that one too.
Sometimes you have try small variations to get a useful match from the search ...
"Have you tried turning it off and on again ?"
A little PureBasic review
xorc1zt
Enthusiast
Enthusiast
Posts: 276
Joined: Sat Jul 09, 2011 7:57 am

Re: Add default text to each new code page

Post by xorc1zt »

agreed and also adding macro would be nice

netbeans use dat for automatically licensing a whole project without typing the title, author, date,... on every new files.

example with gpl 3.0

Code: Select all

<#if licenseFirst??>
${licenseFirst}
</#if>
${licensePrefix}Copyright (C) ${date?date?string("yyyy")} ${project.organization!user}
${licensePrefix?replace(" +$", "", "r")}
${licensePrefix}This program is free software; you can redistribute it and/or
${licensePrefix}modify it under the terms of the GNU General Public License
${licensePrefix}as published by the Free Software Foundation; either version 2
${licensePrefix}of the License, or (at your option) any later version.
${licensePrefix?replace(" +$", "", "r")}
${licensePrefix}This program is distributed in the hope that it will be useful,
${licensePrefix}but WITHOUT ANY WARRANTY; without even the implied warranty of
${licensePrefix}MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
${licensePrefix}GNU General Public License for more details.
${licensePrefix?replace(" +$", "", "r")}
${licensePrefix}You should have received a copy of the GNU General Public License
${licensePrefix}along with this program; if not, write to the Free Software
${licensePrefix}Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
<#if licenseLast??>
${licenseLast}
</#if>
User avatar
Tenaja
Addict
Addict
Posts: 1959
Joined: Tue Nov 09, 2010 10:15 pm

Re: Add default text to each new code page

Post by Tenaja »

luis wrote:I'm not sure to understand the part about the projects in relation to the template tool :?:
When I read this...
Just select the one you want when starting a new program and double click on it.
...somehow my eyes replaced "new program" with "new project"... I don't know why, but maybe it is because I have never seen the template option come up in recent months, and I could not find Template in the help file, so I guessed it must have been in the new project settings. Now I see it is in the Tools menu.

Nice to see a feature request get implemented so quickly! :D
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Re: Add default text to each new code page

Post by freak »

I added the possibility to execute a tool when a new source is created. This way you can generate any header you want with a simple tool like this:

Code: Select all

; Configure as
;
; Commandline: "%TEMPFILE"
; Trigger: "New Sourcecode created"
; [x] Wait until tool quits
; [x] Reload Source after tool has quit
;      (x) into current source
; [x] Hide tool from the Main menu
;
File$ = ProgramParameter()
If CreateFile(0, File$)
  WriteStringN(0, ";")
  WriteStringN(0, "; Created on: " + FormatDate("%dd/%mm/%yyyy %hh:%ii", Date()))
  WriteStringN(0, ";")
  CloseFile(0)
EndIf
It should be available in the next beta.
quidquid Latine dictum sit altum videtur
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: Add default text to each new code page

Post by ts-soft »

freak wrote:I added the possibility to execute a tool when a new source is created.
Good Idea, thanks :D
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
Post Reply