|
-
March 31st, 1999, 05:34 PM
#1
Please get this to work
I am taking a string and breaking it down character by character and trying to send it out a port. I have no clue how
to get it out the port though. Could someone describe in detail how and what variable to use to get it to go out the
port. I suck at C++ because I just started so please be very explicit with instructions.
//*******My code starts here*******
//space is the emptiness between individual messages
CString space(" " ;
//lumps all messages into one data string to be sent out
CString data = m_display1 + space + m_display2 + space + m_display3 + space;
//get the length of the data string
int length = strlen(data);
int count = 0;
//initializes port
m_sendmessagesout.SetPortOpen(VARIANT_TRUE);
//transmission loop
while (count < length)
{
const struct tagVT_BSTR;
CString transfer = data.GetAt(count);
VT_BSTR.COleVariant(transfer);
m_sendmessagesout.SetOutput(VT_BSTR);
count++;
}
//close port
m_sendmessagesout.SetPortOpen(VARIANT_FALSE);
//*******My code ends here*******
-
April 1st, 1999, 03:41 AM
#2
Re: Please get this to work
Hi Bryan, it's me again!
I was wrong about the VARIANT_BOOL stuff - the MFC wrapper does the conversion from BOOL to VARIANT_BOOL for you.
So, where are we? I suggest you try the following:
#include <comdef.h> // for definition of _variant_t type
CString data("Stuff to send" ;
// convert data to a VARIANT
_variant_t var(data);
// select COM1
m_sendmessagesout.SetCommPort(1);
// open the port
m_sendmessagesout.SetPortOpen(TRUE);
// squirt data out of port
m_sendmessagesout.SetOutput(var);
// close port again
m_sendmessagesout.SetPortOpen(FALSE);
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|