Place a quote " in Trace output

I would like to output:
_Trace("if(Name() == " + """ + SymbolA + """){Msg = 1;}
I am getting an error that the """ is not recognized.
How do I output a quote in Trace?
In some languages the triple quote allows you to place a quote in the string field.

You are doing a complete mistake here.
_TRACE() is not a statement but it is a function.

You should do this instead:

if ( Name() == SymbolA ) {
    _TRACE( Name() + " == " + SymbolA );
    Msg = 1;
}

Or better (using %s string specifier):

if ( Name() == SymbolA ) {
    _TRACEF("%s == %s", Name(), SymbolA );
    Msg = 1;
}

(Note: String specifier "%s" is supported since AB 6.17!)


Instead of equality sign you may use StrMatch() function:

if ( StrMatch(Name(), SymbolA) ) {
    _TRACEF("%s matches %s", Name(), SymbolA );
    Msg = 1;
}

As for escaping double quote in string use backslash
Example:

_TRACE( "\"Hello World\"" );

or use single quote

_TRACE( "'Hello World'" );

Using your sample variable SymbolA:

_TRACE( "\"" + SymbolA + "\"" );

as well as

_TRACE( "'" + SymbolA + "'" );

or

_TRACEF( "\"%s\"", SymbolA );
_TRACEF( "'%s'", SymbolA );
8 Likes

Thanks but that is not what I was trying to print in the trace. Here is a simpler example:
_TRACE("STR: " + '"' + " ABC " + '"');
This should have produce: STR: " ABC "
What was printed in Trace result was: STR: 34 ABC 34
The 34 must be the hex for ".

@GBoard, please, see the examples @fxshrat provided you escaping double quote in string use backslash.

Like:

_TRACE("STR: " + "\"" + " ABC " + "\"");
1 Like

OK That got it. Thanks for the help.