Author Topic: Problem with MDA transform double quotes  (Read 3064 times)

andymc73

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
  • Make the computer work for you
    • View Profile
Problem with MDA transform double quotes
« on: May 09, 2007, 05:23:23 pm »
Hi

I have a class with notes like:

  This is "something"

When I try an MDA transform on it, the transform fails.  The exact error varies but it is usually of the form:

  Unexpected symbol: something

Where 'something' was the thing in double quotes in the class notes.

I found several similar posts to do with escaping backslashes etc. but nothing that handles double quotes.

I tried to strip double quotes from the notes using various combinations of %REPLACE($notes,"\"","")% along the lines of C++ etc but none of them work.

Basically the problem seems to be:

1. Macros (e.g. replace) dont understand %qt%. Thus, %REPLACE($somevar,"%qt%","XXX")% fails, as does %REPLACE($somevar,%qt%,"XXX")%

2. Backslash escapes dont work for \".  Why would the program work for \t and \n but not for everything else which is a special character?

I hope there is a solution for this, other than "Dont use quotes in notes". This needs to be robust.

tia
--Andrew
« Last Edit: May 09, 2007, 05:35:21 pm by andymc73 »

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8063
  • Karma: +118/-20
    • View Profile
Re: Problem with MDA transform double quotes
« Reply #1 on: May 09, 2007, 08:00:06 pm »
Yes, there is a way, and you were close.

Firstly, parameters to function macros can be other (simple) macros, but they have the percent characters removed in this situation.

ie. %REPLACE($somevar,qt,"XXX")%

However, %qt%, %dl% and %pc% can't be used in this context.

But you can assign them to a variable and then do the replace.

$quote = %qt%
%REPLACE(classNotes, $quote, "\"")%

andymc73

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
  • Make the computer work for you
    • View Profile
Re: Problem with MDA transform double quotes
« Reply #2 on: May 16, 2007, 09:35:36 pm »
That works really well

Thank you! :D

Adam

  • EA Novice
  • *
  • Posts: 9
  • Karma: +0/-0
    • View Profile
Re: Problem with MDA transform double quotes
« Reply #3 on: August 20, 2007, 11:14:58 pm »
Ahh, but what if you are trying to replace \ with / ? for example to generate proper c++ includes...

to define a '\' character is impossible, you cannot go:
$backslash = "\"

you need to be a smartass:
$backslash = %TRIM("\ ")%

so the resulting code in my situation is:
$RSFileImports = %fileImports%
$backslash = %TRIM("\ ")%
$RSFileImports = %REPLACE($RSFileImports,$backslash,"/")%
$RSFileImports

glen_kidd

  • EA Novice
  • *
  • Posts: 13
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: Problem with MDA transform double quotes
« Reply #4 on: August 20, 2007, 11:23:31 pm »
And I thought my dumb*ss solution was cool:

Quote
$RSFileImports = %REPLACE($RSFileImports,"\a","/a")%
$RSFileImports = %REPLACE($RSFileImports,"\b","/b")%
...


Score 1 point for Adam... Total so far Adam 1; EA 93948 :P