Book a Demo

Author Topic: Code with quotes  (Read 3402 times)

DanG83616

  • EA User
  • **
  • Posts: 180
  • Karma: +0/-0
    • View Profile
Code with quotes
« on: April 30, 2013, 06:45:18 am »
My model template needs to set the code attribute for an operation. The following intermediate does not parse because of nested quotes.

Code: [Select]
Operation
{
  name="Foo"
  code=" std::cout << "Hello, from aFoo" << std::endl;"
}

%qt% gets expanded and produces the same thing. I tried %pc%qt%pc% but of course the C++ code gen template doesn't convert that to ".

I will probably postpone the code snippet insertion to code-gen time and just insert a tag at this point. Still, it would be better if I could localize this special logic to the model transform, however.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Code with quotes
« Reply #1 on: April 30, 2013, 04:05:26 pm »
Just a wild thought: Have you tried escaping the quotes such as
Code: [Select]
code=" std::cout << \"Hello, from aFoo\" << std::endl;"
Geert

DanG83616

  • EA User
  • **
  • Posts: 180
  • Karma: +0/-0
    • View Profile
Re: Code with quotes
« Reply #2 on: May 01, 2013, 03:16:24 am »
Ha! \" works. Amazing how I can overlook the obvious.

Something I realized along the way is that I'm free to process %opCode% in the code template. That could come in handy for parsing AAL or text DSM from the PIM.

Thank you,
Dan