Book a Demo

Author Topic: Code Template Macros: How can I escape \t (tab) character?  (Read 5627 times)

baron52

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Code Template Macros: How can I escape \t (tab) character?
« on: February 13, 2016, 05:41:41 am »
Hi!
I am writing a code template that contains JavaScript processing rules.  My issue is that I want to check if data being processed has \t (tab) like this:   
Code: [Select]
if(lines[i].indexof('\t')>0){//do something}  However, the generator does not seem to know how to escape tabs (I could not find a macro for this in docs either).  Is there a solution/workaround for this?

Thanks
Robert

MMA

  • EA User
  • **
  • Posts: 63
  • Karma: +3/-0
    • View Profile
Re: Code Template Macros: How can I escape \t (tab) character?
« Reply #1 on: February 17, 2016, 09:47:38 am »
I tried your template and generated

Code: [Select]
if(lines[i].indexof(' ')>0){//do something}


Although the following trick works, Aaron's Answer is much better.


if(lines.indexof('%TO_LOWER("\T")%')>0){//do something}


Then it will generate
Code: [Select]
if(lines[i].indexof('\t')>0){//do something}



« Last Edit: February 17, 2016, 10:01:41 am by MMA »

Aaron B

  • EA Administrator
  • EA User
  • *****
  • Posts: 941
  • Karma: +18/-0
    • View Profile
Re: Code Template Macros: How can I escape \t (tab) character?
« Reply #2 on: February 17, 2016, 09:57:29 am »
Or use %sl% to output the backslash character ...

Code: [Select]
if(lines[i].indexof('%sl%t')>0){//do something}
See:
http://sparxsystems.com/enterprise_architect_user_guide/12.1/software_engineering/literaltext.html

baron52

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Re: Code Template Macros: How can I escape \t (tab) character?
« Reply #3 on: February 18, 2016, 06:08:12 am »
Awesome.  Thanks!