Book a Demo

Author Topic: code templates: how to extract a part of a string?  (Read 4744 times)

Andreas_G

  • EA User
  • **
  • Posts: 125
  • Karma: +0/-0
  • And that's the way the cookie crumbles.
    • View Profile
code templates: how to extract a part of a string?
« on: June 28, 2004, 04:21:04 am »
Hi all,

I try to change my code templates. And in the header of our files should be placed the actual year.

So I tried to use %eaDateTime% and extract the year out of it.

For that I need a fuction-macro like MID() to extract the year out of this. Did anybody knows a possibility to do that?
bye
Andreas

AdamHearn

  • EA User
  • **
  • Posts: 58
  • Karma: +0/-0
    • View Profile
Re: code templates: how to extract a part of a str
« Reply #1 on: June 28, 2004, 05:10:41 am »
I posted a feature request a couple of weeks backs. It's coming in Build 730... ;D

Andreas_G

  • EA User
  • **
  • Posts: 125
  • Karma: +0/-0
  • And that's the way the cookie crumbles.
    • View Profile
Re: code templates: how to extract a part of a str
« Reply #2 on: June 28, 2004, 05:12:32 am »
Hey, that sound's good. Till there I can wait.  :D
bye
Andreas

AdamHearn

  • EA User
  • **
  • Posts: 58
  • Karma: +0/-0
    • View Profile
Re: code templates: how to extract a part of a str
« Reply #3 on: June 30, 2004, 01:51:17 am »
A quick 'demo' of the new Macros...

Here's a chunk of CGT that supplies a DD/MM/YY date format in the variable $myCreateDate
Code: [Select]

$myDateSep="/"
$myCreateDate=%LEFT(eaDateTime,"2")%
$myCreateDate+=$myDateSep
$tmp=%MID(eaDateTime,"3","3")%
%if $tmp == "Jan"%
$myCreateDate+="01"
%elseIf $tmp == "Feb"%
$myCreateDate+="02"
%elseIf $tmp == "Mar"%
$myCreateDate+="03"
%elseIf $tmp == "Apr"%
$myCreateDate+="04"
%elseIf $tmp == "May"%
$myCreateDate+="05"
%elseIf $tmp == "Jun"%
$myCreateDate+="06"
%elseIf $tmp == "Jul"%
$myCreateDate+="07"
%elseIf $tmp == "Aug"%
$myCreateDate+="08"
%elseIf $tmp == "Sep"%
$myCreateDate+="09"
%elseIf $tmp == "Oct"%
$myCreateDate+="10"
%elseIf $tmp == "Nov"%
$myCreateDate+="11"
%elseIf $tmp == "Dec"%
$myCreateDate+="12"
%endIf%
$myCreateDate+=$myDateSep
$myCreateDate+=%MID(eaDateTime,"9","2")%