Book a Demo

Author Topic: Using quote in transformation template  (Read 2812 times)

Bokkie

  • EA User
  • **
  • Posts: 80
  • Karma: +0/-0
  • Lima Bravo!
    • View Profile
Using quote in transformation template
« on: June 19, 2006, 01:19:19 am »
Goodmorning guru's,

How should I use quotes within a code section of a transformation template. E.g.:

Code: [Select]

Class
{
 name="MyClass"
 language="C++"
 Operation
 {
   name="MyOperation"
   code="
printf( %qt%Hello world\n%qt% );
"
}


This gives problems in the intermediate language: The %qt% is directly translated into a quote and thus the quotes don't match anymore. (using build 791)

Thanks!
Lima Bravo!

Bokkie

  • EA User
  • **
  • Posts: 80
  • Karma: +0/-0
  • Lima Bravo!
    • View Profile
Re: Using quote in transformation template
« Reply #1 on: June 19, 2006, 01:23:34 am »
Here's a working example and the errornous output:

Code: [Select]

Class
{
 name="test"
 Operation
 {
   name="test"
   code="
printf ( %qt%HelloWorld\n%qt% );
"
 }
}


and the output:
Code: [Select]

Class
{
 name="test"
 Operation
 {
   name="test"
   code="
printf ( "HelloWorld
" );
"
 }
}
Lima Bravo!

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Using quote in transformation template
« Reply #2 on: June 19, 2006, 03:10:34 pm »
Actually, the quotes there are working exactly as intended.  The %qt% is a macro to the code templates to produce a quote symbol.

You can escape the quote symbol for the parser by generating a slash before it.

The other problem you haven't mentioned is the newline in your string.  You have to go to special measures to get a literal \n generated as that is automatically handled by the templates too.  I've added my modifications of your code here.

Code: [Select]
$nl="\\" + "n"
Class
{
 name="test"
 Operation  
 {
   name="test"
   code="
printf ( \%qt%HelloWorld$nl\%qt% );
"
 }
}