# Template.pde variables?

**URL:** https://discourse.processing.org/t/template-pde-variables/15767
**Category:** Processing
**Created:** [November 24, 2019, 2:10pm UTC](https://discourse.processing.org/t/template-pde-variables/15767 "2019-11-24T14:10:07Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![ddownn](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/ddownn/32/2731_2.png) [@ddownn](https://discourse.processing.org/u/ddownn)
#### Post date: [November 24, 2019, 2:10pm UTC](https://discourse.processing.org/t/template-pde-variables/15767/1 "2019-11-24T14:10:08Z")

</div>

Are there any date/time variables available to use in a sketch.pde template so new files will have the current date inside them when a new sketch is created?

I’m referring to the idea of creating a template as shown in [https://github.com/processing/processing/wiki/Templates](https://github.com/processing/processing/wiki/Templates)

---

<div class="post-metadata">

### Author: ![Lexyth](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/lexyth/32/7403_2.png) [@Lexyth](https://discourse.processing.org/u/Lexyth)
#### Post date: [November 24, 2019, 2:37pm UTC](https://discourse.processing.org/t/template-pde-variables/15767/2 "2019-11-24T14:37:13Z")

</div>

What do you mean? Something like this :

```auto
// ***Date:10/10/19*** //
//SketchName:“NewSketch“//
//Template:“SimpleTemplate“//

void setup() {

}

void draw() {

}

```

For that you‘d need to have a way to convert a part of the text into a variable text… which i don‘t think is possible, or even really feasable, since that should only be a Text file, and nothing more…

But there is a way! You just need to override the way a template is inserted! Or in other words, look for the class that takes care of the initialization of the TextArea in a new Sketch. Now find the method that looks for available templates!

Now add in a method that reads the template and looks for a text that starts with what you decide to be a marker, like „\<%variable„ and read that until it ends with „%variable/\>“.

So the Template would look like this :

```auto
//The current Date is : <%variable String date = str(month())+str(day())+str(year());%variable/> //
//SketchName : //
//TemplateName : //

```

Now, how you get this String, i have no idea, but i‘ll take a look at that later on… Anyway, once you got that String, you just interfere in the template text, and replace the \<%var…%var…/\> with the result of your codesnippet, in this case the current date…

Note that this is not really worth the effort… Also, there might actually be a simpler way, but i don‘t know of it, so that‘s the best i could do to help you.

Edit :  
Since you only want to get the Date, you can probably get away with adding this where the template is added into the TextArea :

```auto
TextArea.append(„\//Date: „ + str(month()) + str(day()) + str(year()) + „\//„);

```

Although that only works if the template isn‘t added with a .set method… then you‘ll need to insert the Date text.

---

<div class="post-metadata">

### Author: ![ddownn](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/ddownn/32/2731_2.png) [@ddownn](https://discourse.processing.org/u/ddownn)
#### Post date: [November 24, 2019, 4:41pm UTC](https://discourse.processing.org/t/template-pde-variables/15767/3 "2019-11-24T16:41:22Z")

</div>

Interesting… I agree though, probably not worth the effort

---

<div class="post-metadata">

### Author: ![ddownn](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/ddownn/32/2731_2.png) [@ddownn](https://discourse.processing.org/u/ddownn)
#### Post date: [November 24, 2019, 7:05pm UTC](https://discourse.processing.org/t/template-pde-variables/15767/4 "2019-11-24T19:05:34Z")

</div>

I’ve never seen a quote mark on the floor like this, is that a thing these days? 🤔

> [@Lexyth](#):
>
> „

---

<div class="post-metadata">

### Author: ![Lexyth](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/lexyth/32/7403_2.png) [@Lexyth](https://discourse.processing.org/u/Lexyth)
#### Post date: [November 24, 2019, 8:24pm UTC](https://discourse.processing.org/t/template-pde-variables/15767/5 "2019-11-24T20:24:32Z")

</div>

No, technically it would be this „Hello“, but since i used spaces the last quote went down too 😅 It‘s just a normal Quote written on the IPhone.
