Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5951413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:32:01+00:00 2026-05-22T17:32:01+00:00

My application sends debug data to the Output Window in Visual Studio using the

  • 0

My application sends debug data to the Output Window in Visual Studio using the TRACE macro. Some of these output strings are built using several calls to the TRACE macro, as is shown in the following snippet of code:

BYTE i, len;

len = pMsg[APP_LEN_OFFSET] + sizeof(appPktHead_t) - APP_MSG_CODE_LEN;

TRACE(_T("%s: "), fnName);
TRACE(GetCmdIdStr( pMsg[APP_MSG_CODE_OFFSET] ));
TRACE(_T(" 0x"));

for ( i = 0; i < len; i++ )
{
    TRACE(_T("%.2X "), pMsg[i]);
}

TRACE(_T("\r\n"));

How can I either lock the output to the Output Window for the duration of this function, or send the entire string in a single call to TRACE? Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T17:32:01+00:00Added an answer on May 22, 2026 at 5:32 pm

    Build a single string, before using the TRACE macro.

    byMsgLen = pMsg[DEV_LEN_OFFSET] + sizeof(devPktHead_t) + sizeof(devPktTail_t);
    cmd = pMsg[DEV_CMD_MSB_OFFSET];
    cmd <<= 8;
    cmd |= pMsg[DEV_CMD_LSB_OFFSET];
    pCmdIdStr = GetCmdIdStr( cmd );
    iPreOffset = ::wcsnlen_s(fnName, 128)       // function name
        + 2                                     // ": "
        + ::wcsnlen_s(pCmdIdStr, 128)           // command ID string
        + 3;                                    // " 0x"
    iPostOffset = iPreOffset + byMsgLen * 3;    // "%.2X " (formatted: 2 hex-nibble bytes and space)
    iStrLen = iPostOffset + 3;                  // "\r\n\0"
    pBuf = (wchar_t *)malloc( iStrLen * sizeof(wchar_t) );
    
    ::swprintf_s( pBuf, iStrLen, _T("%s: %s 0x"), fnName, pCmdIdStr);
    
    for ( i = iPreOffset; i < iPostOffset; i += 3 )
    {
        ::swprintf_s( &(pBuf[i]), 4, _T("%.2X "), pMsg[j++] );
    }
    
    ::swprintf_s( &(pBuf[i]), 3, _T("\r\n") );
    
    TRACE( pBuf );
    
    ::free( pBuf );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Among the data my application sends to a third-party SOA server are complex XMLs.
We are getting an error in a VB6 application that sends data back and
My web application sends email fairly often, and it sends 3 kinds of emails:
Our web application sends e-mails. We have lots of users, and we get lots
I have an application that sends messages to an external web service. I build
I have an application that sends the customer to another site to handle the
When developing an application that sends out notification email messages, what are the best
I have an application that sends broadcast messages and listens for response packets. Below
I have a client server application that sends XML over TCP/IP from client to
I'm an email n00b but I am working on an application that sends HTML

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.