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. The Lounge
  3. Programming Question: C++ Builder String

Programming Question: C++ Builder String

Scheduled Pinned Locked Moved The Lounge
c++questionvisual-studioannouncementcareer
19 Posts 10 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.
  • R rastaVnuce

    Paul Selormey wrote:

    will produce sub==BillyBob. Wow! No! that should throw an exception Confused

    Why an exception? Shouldn't sub become "illyBob" ? We agree on the 0-based index. It is an awful idea to present anything different that a 0-based index in C/C++ world. But, I don't think it would be good to throw an exception because there aren't 8 characters left for the whole sub string to fill up. (I presume that's why you think an exception is required?)

    To hell with circumstances; I create opportunities.

    P Offline
    P Offline
    Paul Selormey
    wrote on last edited by
    #9

    rastaVnuce wrote:

    Why an exception?

    May be I should have added s.Length == 19, so that you do not need the count.

    rastaVnuce wrote:

    Shouldn't sub become "illyBob" ?

    Length("illyBob") == 7. Best regards, Paul.

    Jesus Christ is LOVE! Please tell somebody.

    R 1 Reply Last reply
    0
    • P Paul Selormey

      rastaVnuce wrote:

      Why an exception?

      May be I should have added s.Length == 19, so that you do not need the count.

      rastaVnuce wrote:

      Shouldn't sub become "illyBob" ?

      Length("illyBob") == 7. Best regards, Paul.

      Jesus Christ is LOVE! Please tell somebody.

      R Offline
      R Offline
      rastaVnuce
      wrote on last edited by
      #10

      I am aware of both strings' lengths. My point is... it's much more convenient to have substring return shorter string, that throw an exception.

      To hell with circumstances; I create opportunities.

      P 1 Reply Last reply
      0
      • P Paul Selormey

        I was assigned to update an application created with the C++ Builder 6, but after trying the IDE and realized it is not even close to VC++ 4.x, I asked and got the permission to port the whole application to WTL. I was happily doing the porting until today, when I saw something "strange" and could not understand. Investigating further, it turns out that in BCB, this code found here...[^]

        String s = "My name is BillyBob";
        String sub = s.SubString(12, 8);

        will produce sub==BillyBob. Wow! No! that should throw an exception :confused: Then the notes claim the String indexing is a 1-based not a 0-based. :mad: Is there a C++Builder user here? Are you comfortable using that string class? I think you will need a double salary. Now, I have to say goodbye to my weekend X| Best regards, Paul.

        Jesus Christ is LOVE! Please tell somebody.

        B Offline
        B Offline
        blackjack2150
        wrote on last edited by
        #11

        I did a cards game in BCB 6 in my 2nd year in college. It was the first nontrivial program that had a UI and then I liked how easy it was to design the forms. VC++ 6 was a mystery to me as I couldn't stand that class wizard way of doing things. What I absolutely hated about BCB was that if you had an error in the source code, even a missing semicolon, the Code Complete feature would not work anymore. Awful!

        1 Reply Last reply
        0
        • P Paul Selormey

          I was assigned to update an application created with the C++ Builder 6, but after trying the IDE and realized it is not even close to VC++ 4.x, I asked and got the permission to port the whole application to WTL. I was happily doing the porting until today, when I saw something "strange" and could not understand. Investigating further, it turns out that in BCB, this code found here...[^]

          String s = "My name is BillyBob";
          String sub = s.SubString(12, 8);

          will produce sub==BillyBob. Wow! No! that should throw an exception :confused: Then the notes claim the String indexing is a 1-based not a 0-based. :mad: Is there a C++Builder user here? Are you comfortable using that string class? I think you will need a double salary. Now, I have to say goodbye to my weekend X| Best regards, Paul.

          Jesus Christ is LOVE! Please tell somebody.

          D Offline
          D Offline
          Dave Parker
          wrote on last edited by
          #12

          In the one C++ module we had at university ( most of it was in java :( ) we had to use Borland Builder. Never liked it, it doesn't even seem like C/C++ to me it's more of some weird delphi / C++ hybrid thing that crashes a lot. Where possible (such as for console apps for which I wouldn't get penalized for not using VCL or whatever borland's framework was called) I used VC++ 6 on my own PC instead and just didn't use any compiler-specific extensions.

          Y 1 Reply Last reply
          0
          • P Paul Selormey

            I was assigned to update an application created with the C++ Builder 6, but after trying the IDE and realized it is not even close to VC++ 4.x, I asked and got the permission to port the whole application to WTL. I was happily doing the porting until today, when I saw something "strange" and could not understand. Investigating further, it turns out that in BCB, this code found here...[^]

            String s = "My name is BillyBob";
            String sub = s.SubString(12, 8);

            will produce sub==BillyBob. Wow! No! that should throw an exception :confused: Then the notes claim the String indexing is a 1-based not a 0-based. :mad: Is there a C++Builder user here? Are you comfortable using that string class? I think you will need a double salary. Now, I have to say goodbye to my weekend X| Best regards, Paul.

            Jesus Christ is LOVE! Please tell somebody.

            N Offline
            N Offline
            Niall Barr
            wrote on last edited by
            #13

            Many years ago I ported an app from Turbo C++ to VC++ - one quirk of Turbo was that it had a class that encapsulated Pascal style strings where the first character of the structure is the string length, so the actual string starts at offset 1 (and is limited to 255 characters).

            P 1 Reply Last reply
            0
            • R rastaVnuce

              I am aware of both strings' lengths. My point is... it's much more convenient to have substring return shorter string, that throw an exception.

              To hell with circumstances; I create opportunities.

              P Offline
              P Offline
              Paul Selormey
              wrote on last edited by
              #14

              rastaVnuce wrote:

              it's much more convenient to have substring return shorter string, that throw an exception.

              It is not about convenience, but correctness, which I think is more important to avoid problems in programming tasks. In this case, the request is beyond the content, and as in any array operation, it should not be allowed. You can easily check this before making the call to the array, if you do not want an exception. Best regards, Paul.

              Jesus Christ is LOVE! Please tell somebody.

              1 Reply Last reply
              0
              • N Niall Barr

                Many years ago I ported an app from Turbo C++ to VC++ - one quirk of Turbo was that it had a class that encapsulated Pascal style strings where the first character of the structure is the string length, so the actual string starts at offset 1 (and is limited to 255 characters).

                P Offline
                P Offline
                Paul Selormey
                wrote on last edited by
                #15

                This might explain the issue. They are most likely using the Delphi library for the C++ Builder, I do not know how many C++ Developers will like that joke. Best regards, Paul.

                Jesus Christ is LOVE! Please tell somebody.

                Y 1 Reply Last reply
                0
                • K ktm TechMan

                  Yes we have BCB 6 in our project for quite some time now, and after some time you get the hang of it. You can always use the std::string class, thats the flexibility.

                  J Offline
                  J Offline
                  Joe Woodbury
                  wrote on last edited by
                  #16

                  std:string is the lamest string class I've ever used.

                  Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke

                  1 Reply Last reply
                  0
                  • L leppie

                    Paul Selormey wrote:

                    Is there a C++Builder user here? Are you comfortable using that string class? I think you will need a double salary.

                    No, they are all retired with that extra cash :)

                    xacc.ide - now with TabsToSpaces support
                    IronScheme - 1.0 beta 2 - out now!
                    ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))

                    Y Offline
                    Y Offline
                    Yayozama
                    wrote on last edited by
                    #17

                    leppie wrote:

                    No, they are all retired with that extra cash Smile

                    Sorry, with all the pain in my heart I have to say that I still programme in Builder 6 (well... me and 30+ other peoples in my office :~) And... to put salt in the cut, we dont have free internet access (we can only check microsoft, java, Codeproject and a few other webpages). The fear of the owners in the change of technology is amazing... Cheers!

                    1 Reply Last reply
                    0
                    • D Dave Parker

                      In the one C++ module we had at university ( most of it was in java :( ) we had to use Borland Builder. Never liked it, it doesn't even seem like C/C++ to me it's more of some weird delphi / C++ hybrid thing that crashes a lot. Where possible (such as for console apps for which I wouldn't get penalized for not using VCL or whatever borland's framework was called) I used VC++ 6 on my own PC instead and just didn't use any compiler-specific extensions.

                      Y Offline
                      Y Offline
                      Yayozama
                      wrote on last edited by
                      #18

                      Dave Parker wrote:

                      Never liked it, it doesn't even seem like C/C++ to me it's more of some weird delphi / C++ hybrid thing that crashes a lot.

                      I have 3 or 4 crashes per day (in B6... in B5 had way more) And (by the law of Murphy) they happens in the worst moment possible.

                      1 Reply Last reply
                      0
                      • P Paul Selormey

                        This might explain the issue. They are most likely using the Delphi library for the C++ Builder, I do not know how many C++ Developers will like that joke. Best regards, Paul.

                        Jesus Christ is LOVE! Please tell somebody.

                        Y Offline
                        Y Offline
                        Yayozama
                        wrote on last edited by
                        #19

                        Well, Builder 5 (and 6) is builded under Delphi. By the way, the use of the strings is really a PITA in Builder (even using the AnsiString), and some things use the 0-index, others use the -1-index and a few others use the 1-index... (and try to remember all that when in the other time part job you use VB.net or C# :sigh: ) And we are not even mentioning the pointers and double pointers (and how use them with all the different data types X| ). 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