473,325 Members | 2,342 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

__boxing helena - i mean parity...

OK, I'm mixing old style with new style, so sue me... : )

Will under old syntax, I'm able to create a SerialPort instance. But, when I
try to convert the Parity proerty to a String*, I get the following compiler
error:

error C3610: value type must be 'boxed'

Here is the code:

SerialPort* port = new SerialPort() ;
Parity parity = port->Parity() ;
String* port_str = parity.ToString() ; // 'boxing' error

Never 'boxed' before, don't know how. How do I convert Parity to a String*
equivalent (i.e., how do I change the above code to properly box 'parity' so
ToString() can be evaluated)? If I write the equivalent code in /clr format
no boxing is necessary ('natch), but I need to do this (for now) in old
syntax.

Thanks in advance for responses! : )

[==P==]

PS - I'm writnig a home project using the new /clr syntax. If you START
using this syntax its awesome! If you have to convert old syntax managed C++
to it, its an intimidating task to say the least... : )
Nov 17 '05 #1
2 1455
Peter,
OK, I'm mixing old style with new style, so sue me... : )

Will under old syntax, I'm able to create a SerialPort instance. But, when
I try to convert the Parity proerty to a String*, I get the following
compiler error:

error C3610: value type must be 'boxed'

Here is the code:

SerialPort* port = new SerialPort() ;
Parity parity = port->Parity() ;
String* port_str = parity.ToString() ; // 'boxing' error

Never 'boxed' before, don't know how. How do I convert Parity to a String*
equivalent (i.e., how do I change the above code to properly box 'parity'
so ToString() can be evaluated)? If I write the equivalent code in /clr
format no boxing is necessary ('natch), but I need to do this (for now) in
old syntax.


You need to box the value here because in old style MC++, you couldn't
directly access inherited methods in a value (i.e. an instance of a value
type) unless the type overrode those methods (that's why you can call
ToString() directly on some value types and not on others).

In this case, you need to box it, which can be done using the __box()
operator:

String* port_str = __box(parity)->ToString() ;
--
Tomas Restrepo
to****@mvps.org
http://www.winterdom.com/
Nov 17 '05 #2
Yup, that did the trick! Thanks! : )

[==P==]

"Tomas Restrepo (MVP)" <to****@mvps.org> wrote in message
news:Os**************@TK2MSFTNGP12.phx.gbl...
Peter,
OK, I'm mixing old style with new style, so sue me... : )

Will under old syntax, I'm able to create a SerialPort instance. But,
when I try to convert the Parity proerty to a String*, I get the
following compiler error:

error C3610: value type must be 'boxed'

Here is the code:

SerialPort* port = new SerialPort() ;
Parity parity = port->Parity() ;
String* port_str = parity.ToString() ; // 'boxing' error

Never 'boxed' before, don't know how. How do I convert Parity to a
String* equivalent (i.e., how do I change the above code to properly box
'parity' so ToString() can be evaluated)? If I write the equivalent code
in /clr format no boxing is necessary ('natch), but I need to do this
(for now) in old syntax.


You need to box the value here because in old style MC++, you couldn't
directly access inherited methods in a value (i.e. an instance of a value
type) unless the type overrode those methods (that's why you can call
ToString() directly on some value types and not on others).

In this case, you need to box it, which can be done using the __box()
operator:

String* port_str = __box(parity)->ToString() ;
--
Tomas Restrepo
to****@mvps.org
http://www.winterdom.com/

Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: snacktime | last post by:
Is there a module that sets the parity of a string? I have an application that needs to communicate with a host using even parity So what I need is before sending the message, convert it from...
2
by: Petr Jakes | last post by:
Hi, I am trying to set-up communication to the coin change-giver from my Linux box using the Python code. The change giver uses MDB (Multi Drop Bus) serial protocol to communicate with the...
15
by: Herbert Haas | last post by:
Hi everyone, is there a simple and fast method to check the parity of a word (e. g. a 4-byte integer)? That is I want to know whether the number of ones are even or odd. Of course I could do...
0
by: Loren | last post by:
I am using parity error checking as I receive data into the input buffer from the comm port. The data I receive consists of a parity error, followed by received data, followed by a parity error. ...
11
by: nick.stefanov | last post by:
I am trying to compute an even parity bit for a variable of type char. Are there any C++, C# examples on how to first compute the bit and then check it. Thank you very much ahead of time. Nick
0
by: Rogoras | last post by:
I use termios.h and have following problem: My computer comunicates to host computer usig serial RS232. Host is using parity bit as wake up bit and 8 data bits. In other words parity bit is...
0
by: Radu Crisan | last post by:
Hi all, i have this RS232 settings public static string portName; public static Int16 baudRate = 19200; public static Parity parity = Parity.Mark; public static Int16 dataBits = 8; public...
8
by: philbo30 | last post by:
I admit, I didn't spend any time researching this yet so this is the first step... Is there a C function available to determine byte parity or is the usual course to just count the 1s?
4
by: sunfeifei | last post by:
Your job is to write a C++ program that reads in a matrix and checks if it has the parity property. If not, your program should check if the parity property can be established by changing only one...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.