Book a Demo

Author Topic: MDA templates string determination with addin  (Read 4178 times)

Oliver F.

  • EA User
  • **
  • Posts: 573
  • Karma: +2/-1
  • Aren´t we all in the model business ?
    • View Profile
    • Karl Storz homepage
MDA templates string determination with addin
« on: September 28, 2015, 08:39:44 pm »
There is one thing about MDA transformations which is driving me straight into crazyness: String handling via addin.

I am trying to transform classes with attributes which have default values (initialValues).
Some attribute default values are of type char[] and others are unsigned int. These attributes are processed with a C# addin.

Now to the interesting part:

The addin tries to determine whether the type is integer or char[] and returns the original, unprocessed value if it´s a string.

What I see when I read out attInitial of that attribute is an escaped string like:
"\"Hey there\"".
Sending the string back to the transformation process without modification leads to the escaping chars ('\') being stripped away and the template code

Code: [Select]
$values = %EXEC_ADD_IN("Parameter_AddIn","modifyParameterArray", attInitial)%
default = %qt%$values%qt%

leads to ""Hey there"" in the transformation log thus failing the process.
The surrounding %qt% statements are mandatory for assignments in the template so they can´t be skipped anyway and this would not be of use anyway.

Handling the string determination inside the MDA template also failed as I have been unable to find the correct escaping sequence to identify the \" sequence.

So any idea what is the correct way to return a quoted string from an addin or a clever way for string determination inside the MDA templates?

Thanks in advance.

Oliver

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: MDA templates string determination with addin
« Reply #1 on: September 28, 2015, 09:17:37 pm »
Not that I can help here. But this is one of the reasons I stopped using this proprietary Sparxian macro language and started using scripting instead.

q.

Oliver F.

  • EA User
  • **
  • Posts: 573
  • Karma: +2/-1
  • Aren´t we all in the model business ?
    • View Profile
    • Karl Storz homepage
Re: MDA templates string determination with addin
« Reply #2 on: October 06, 2015, 06:56:17 pm »
So for the records, it looks as if a string can be returned by escaping it with
Code: [Select]
strReturn = "\\\""+strReturn+"\\\"";
which then lets you use the template with the %qt% macro:

Code: [Select]
default = %qt%$values%qt%
with $values holding the string from the addin.

Funny because I had situations in which the \" sequence has been stripped away.

Seems to work now.

Oliver