Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Managed C++/CLI
  4. Looping sending me loopy!

Looping sending me loopy!

Scheduled Pinned Locked Moved Managed C++/CLI
csharpc++databasevisual-studiohelp
3 Posts 3 Posters 3 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    dyerstein
    wrote on last edited by
    #1

    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! ;-)

    M J 2 Replies Last reply
    0
    • D dyerstein

      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! ;-)

      M Offline
      M Offline
      monrobot13
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      • D dyerstein

        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! ;-)

        J Offline
        J Offline
        Jeff J
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups