Looping sending me loopy!
-
Visual Studio 6 ** loads a string of "len" byte in message at the given index ** message has to be able to contain "len" + idx bytes */ void CMessageProtocol::LoadValueInMessage( char *message , int idx, string &command, int len ) {//private: int i; // this loop load the command in message for ( i = 0; command[i] && (i < len) ; i++ ) { message[idx] = command[i]; idx++; } // this loop is used for padding for ( ; i < len; i++) { message[idx] = PROT_PADDING; idx++; } } Visual Studio .NET void GEMBrokerMessengerProtocol::CGEMMessageProtocol::LoadValueInMessage(SByte* Message, Int32 idx, System::String& Command, Int32 len) { Int32 i; // This loop loads the command in the message // We need to convert the value of i(Int32(int)) to // command(System::String&) for(i = 0; Command[i] && (i < len); i++) { Message[idx] = Command[i]; idx++; } // This loop is used for padding // this loop is used for padding for ( ; i < len; i++) { Message[idx] = PROT_PADDING; idx++; } } When i try and compile I get the following errors: c:\Documents and Settings\mdyer\My Documents\Visual Studio Projects\CGEMBroker\GEMBrokerMessengerProtocol.cpp(83): error C2676: binary '[' : 'System::String' does not define this operator or a conversion to a type acceptable to the predefined operator Ha! And I though .NET was going to be cool!! I'm gaining a headache pretty fast! ;-)
-
Visual Studio 6 ** loads a string of "len" byte in message at the given index ** message has to be able to contain "len" + idx bytes */ void CMessageProtocol::LoadValueInMessage( char *message , int idx, string &command, int len ) {//private: int i; // this loop load the command in message for ( i = 0; command[i] && (i < len) ; i++ ) { message[idx] = command[i]; idx++; } // this loop is used for padding for ( ; i < len; i++) { message[idx] = PROT_PADDING; idx++; } } Visual Studio .NET void GEMBrokerMessengerProtocol::CGEMMessageProtocol::LoadValueInMessage(SByte* Message, Int32 idx, System::String& Command, Int32 len) { Int32 i; // This loop loads the command in the message // We need to convert the value of i(Int32(int)) to // command(System::String&) for(i = 0; Command[i] && (i < len); i++) { Message[idx] = Command[i]; idx++; } // This loop is used for padding // this loop is used for padding for ( ; i < len; i++) { Message[idx] = PROT_PADDING; idx++; } } When i try and compile I get the following errors: c:\Documents and Settings\mdyer\My Documents\Visual Studio Projects\CGEMBroker\GEMBrokerMessengerProtocol.cpp(83): error C2676: binary '[' : 'System::String' does not define this operator or a conversion to a type acceptable to the predefined operator Ha! And I though .NET was going to be cool!! I'm gaining a headache pretty fast! ;-)
I don't use managed c++ very often so I could be way off, but I think you need to use the
String::Chars
property to access a specific character in MC++ String. - monrobot13 -
Visual Studio 6 ** loads a string of "len" byte in message at the given index ** message has to be able to contain "len" + idx bytes */ void CMessageProtocol::LoadValueInMessage( char *message , int idx, string &command, int len ) {//private: int i; // this loop load the command in message for ( i = 0; command[i] && (i < len) ; i++ ) { message[idx] = command[i]; idx++; } // this loop is used for padding for ( ; i < len; i++) { message[idx] = PROT_PADDING; idx++; } } Visual Studio .NET void GEMBrokerMessengerProtocol::CGEMMessageProtocol::LoadValueInMessage(SByte* Message, Int32 idx, System::String& Command, Int32 len) { Int32 i; // This loop loads the command in the message // We need to convert the value of i(Int32(int)) to // command(System::String&) for(i = 0; Command[i] && (i < len); i++) { Message[idx] = Command[i]; idx++; } // This loop is used for padding // this loop is used for padding for ( ; i < len; i++) { Message[idx] = PROT_PADDING; idx++; } } When i try and compile I get the following errors: c:\Documents and Settings\mdyer\My Documents\Visual Studio Projects\CGEMBroker\GEMBrokerMessengerProtocol.cpp(83): error C2676: binary '[' : 'System::String' does not define this operator or a conversion to a type acceptable to the predefined operator Ha! And I though .NET was going to be cool!! I'm gaining a headache pretty fast! ;-)
monrobot13 already answered your question, but just to give a syntax example:
for(i=0; Command->get_Chars(i) && (i < len); i++) {
dyerstein wrote: Ha! And I though .NET was going to be cool!! I'm gaining a headache pretty fast! I keep a bottle of pain relievers around for the headaches (not that it helps much), but I can't say the transition to MC++ is exactly fun. C# is a much better fit for .Net, however MC++ is our only practical way to use C++ with it. Cheers