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. Other Discussions
  3. The Weird and The Wonderful
  4. String "bitmaps"

String "bitmaps"

Scheduled Pinned Locked Moved The Weird and The Wonderful
graphicsquestion
18 Posts 10 Posters 0 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.
  • G Gordon Kushner

    Can you think of why a programmer would ever use a string to act as a bitmap field? e.g.

    DECLARE @Bitmap varchar(20)
    SELECT @Bitmap = '00110100100011011110'

    The beauty of bitmasks is that the values are compact (at one bit each) and you get the benefit of bitwise ANDing and ORing. I winced at this, but can you think of an instance where this might make sense (except for the obvious "Hey, I just read a cool article about bitmaps! Computer scientists use 'em all the time.")

    L Offline
    L Offline
    Lost User
    wrote on last edited by
    #3

    I started out on a computer with a hex keyboard and learned there how to mask or test some bits. Nowadays I still often use them, for example in some entity in a web application. But along the way I met several young and promising code monkeys who easily understood that you should use some kind of integer for that and what the bits are good for. But all of them had real trouble with this arcane AND and OR stuff. I guess the real horror here is, how somebody can have trouble understanding such a fundamental thing.

    A while ago he asked me what he should have printed on my business cards. I said 'Wizard'. I read books which nobody else understand. Then I do something which nobody understands. After that the computer does something which nobody understands. When asked, I say things about the results which nobody understand. But everybody expects miracles from me on a regular basis. Looks to me like the classical definition of a wizard.

    G 1 Reply Last reply
    0
    • G Gordon Kushner

      Can you think of why a programmer would ever use a string to act as a bitmap field? e.g.

      DECLARE @Bitmap varchar(20)
      SELECT @Bitmap = '00110100100011011110'

      The beauty of bitmasks is that the values are compact (at one bit each) and you get the benefit of bitwise ANDing and ORing. I winced at this, but can you think of an instance where this might make sense (except for the obvious "Hey, I just read a cool article about bitmaps! Computer scientists use 'em all the time.")

      R Offline
      R Offline
      Richard A Dalton
      wrote on last edited by
      #4

      I must admit in the dim and distant past I did something not terribly dissimilar to that. Indeed if you search MSDN you can still find the evidence. http://msdn.microsoft.com/en-us/library/aa239702(VS.60).aspx[^] Now, It's too long ago for me to try justify exactly what I was doing, but here is what I remember of it: 1. The "bits" in this case represented meta-data which were stored in an XML document. 2. I wasn't going to be AND'ing or OR'ing the fields as a whole. 3. Any performance or space savings from using actual bits would have been outweighed by the benefit of being able to see the string of 1s and 0s in XML, rather than a cryptic Numerical value 4. Keeping the string of 1s and 0s in XML but actual bit logic in code would have meant translating back and forth needlessly. So there it is. I'm a huge fan of bitmap fields and use them all the time, but in that instance and at that time I felt comfortable with a string. But yes, my default attitude is that a string is rarely the right way to go. 99% of the time I'd expect it to be a bad idea, and the remaining 1% of times I'd expect it to be seriously debatable.

      G 1 Reply Last reply
      0
      • R Richard A Dalton

        I must admit in the dim and distant past I did something not terribly dissimilar to that. Indeed if you search MSDN you can still find the evidence. http://msdn.microsoft.com/en-us/library/aa239702(VS.60).aspx[^] Now, It's too long ago for me to try justify exactly what I was doing, but here is what I remember of it: 1. The "bits" in this case represented meta-data which were stored in an XML document. 2. I wasn't going to be AND'ing or OR'ing the fields as a whole. 3. Any performance or space savings from using actual bits would have been outweighed by the benefit of being able to see the string of 1s and 0s in XML, rather than a cryptic Numerical value 4. Keeping the string of 1s and 0s in XML but actual bit logic in code would have meant translating back and forth needlessly. So there it is. I'm a huge fan of bitmap fields and use them all the time, but in that instance and at that time I felt comfortable with a string. But yes, my default attitude is that a string is rarely the right way to go. 99% of the time I'd expect it to be a bad idea, and the remaining 1% of times I'd expect it to be seriously debatable.

        G Offline
        G Offline
        Gordon Kushner
        wrote on last edited by
        #5

        Cool article. Thanks for the thoughts.

        R 1 Reply Last reply
        0
        • L Lost User

          I started out on a computer with a hex keyboard and learned there how to mask or test some bits. Nowadays I still often use them, for example in some entity in a web application. But along the way I met several young and promising code monkeys who easily understood that you should use some kind of integer for that and what the bits are good for. But all of them had real trouble with this arcane AND and OR stuff. I guess the real horror here is, how somebody can have trouble understanding such a fundamental thing.

          A while ago he asked me what he should have printed on my business cards. I said 'Wizard'. I read books which nobody else understand. Then I do something which nobody understands. After that the computer does something which nobody understands. When asked, I say things about the results which nobody understand. But everybody expects miracles from me on a regular basis. Looks to me like the classical definition of a wizard.

          G Offline
          G Offline
          Gordon Kushner
          wrote on last edited by
          #6

          "But all of them had real trouble with this arcane AND and OR stuff." Believe me, I was in a fog about that my first two years programming. And XOR made me weep like a little girl! Thanks for sharing your dark secrets, Mr. Wizard.

          1 Reply Last reply
          0
          • G Gordon Kushner

            Cool article. Thanks for the thoughts.

            R Offline
            R Offline
            Richard A Dalton
            wrote on last edited by
            #7

            Thanks for the excuse to go back and look at that again. It's hard to believe that back then I thought that CCustomerCol was a good naming convention. And as for LetXML and GetXML!?!?! :sigh: To this day nobody has ever noticed (or at least admitted noticing) the following: CustCol.Customer(1).Company = "LA" CustCol.Customer(1).ContactName = "Sandy" CustCol.Customer(1).Phone = "555-2312" In the movie LA Story Sarah Jessica Parker's character is called Sandy and gives Steve Martin's character her phone number which is...555-2312. The movie happened to be on tv in the background when I was writing the article. Just when I needed a bit of sample data that scene happened. According to http://www.radivarl.demon.co.uk/nick/media/555.htm[^] I misspelled her name.

            G 1 Reply Last reply
            0
            • G Gordon Kushner

              Can you think of why a programmer would ever use a string to act as a bitmap field? e.g.

              DECLARE @Bitmap varchar(20)
              SELECT @Bitmap = '00110100100011011110'

              The beauty of bitmasks is that the values are compact (at one bit each) and you get the benefit of bitwise ANDing and ORing. I winced at this, but can you think of an instance where this might make sense (except for the obvious "Hey, I just read a cool article about bitmaps! Computer scientists use 'em all the time.")

              R Offline
              R Offline
              Rob Grainger
              wrote on last edited by
              #8

              With a shudder I remember my introduction to programming on a ZX81 with 1K RAM. After quickly exhausting the possibilities of BASIC in a 1K program (even when programs are stored tokenized, with each keyword a single byte), I had to resort to machine code. A program then consisted of a subroutine (using GOSUB/RETURN) that POKE'd bytes into memory, reading them from hexadecimal strings stored in DATA statements such as. 10 DATA "3AFB3C2A1F" I had to manually write these hex strings by looking up Z80 opcodes and converting registers etc into bitfields (not enough memory to run an assembler). Once it was all in memory, I'd write it to a file (cassette-based), then write another program to load the binary data and transfer control into it (can't remember how that was achieved though). On the other hand, it taught me all the basics of programming, in a very real and demanding environment. Binary though, I can see no good reason for that.

              R 1 Reply Last reply
              0
              • R Richard A Dalton

                Thanks for the excuse to go back and look at that again. It's hard to believe that back then I thought that CCustomerCol was a good naming convention. And as for LetXML and GetXML!?!?! :sigh: To this day nobody has ever noticed (or at least admitted noticing) the following: CustCol.Customer(1).Company = "LA" CustCol.Customer(1).ContactName = "Sandy" CustCol.Customer(1).Phone = "555-2312" In the movie LA Story Sarah Jessica Parker's character is called Sandy and gives Steve Martin's character her phone number which is...555-2312. The movie happened to be on tv in the background when I was writing the article. Just when I needed a bit of sample data that scene happened. According to http://www.radivarl.demon.co.uk/nick/media/555.htm[^] I misspelled her name.

                G Offline
                G Offline
                Gordon Kushner
                wrote on last edited by
                #9

                Oh yeah, SaNdee. Just after Steve Martin noted that at least she had a normal name. Best line in that movie when SaNdee persuades Steve to get an enema. Afterwards, she says something like "that really clears my head" and Steve replies, "clears your head? You must be doing it wrong." I'm guessing the Let and Get statements were more in vogue at the time you wrote the article what with VB6 and all.

                1 Reply Last reply
                0
                • G Gordon Kushner

                  Can you think of why a programmer would ever use a string to act as a bitmap field? e.g.

                  DECLARE @Bitmap varchar(20)
                  SELECT @Bitmap = '00110100100011011110'

                  The beauty of bitmasks is that the values are compact (at one bit each) and you get the benefit of bitwise ANDing and ORing. I winced at this, but can you think of an instance where this might make sense (except for the obvious "Hey, I just read a cool article about bitmaps! Computer scientists use 'em all the time.")

                  T Offline
                  T Offline
                  T M Gray
                  wrote on last edited by
                  #10

                  Are you sure it is a bitmask and not actually a bitmap? When we load our test or demo environments and need to sanitize the data we have strings in some of our setup sprocs that replace various fields like encrypted passwords, binary documents and images with pre-determined strings.

                  1 Reply Last reply
                  0
                  • R Rob Grainger

                    With a shudder I remember my introduction to programming on a ZX81 with 1K RAM. After quickly exhausting the possibilities of BASIC in a 1K program (even when programs are stored tokenized, with each keyword a single byte), I had to resort to machine code. A program then consisted of a subroutine (using GOSUB/RETURN) that POKE'd bytes into memory, reading them from hexadecimal strings stored in DATA statements such as. 10 DATA "3AFB3C2A1F" I had to manually write these hex strings by looking up Z80 opcodes and converting registers etc into bitfields (not enough memory to run an assembler). Once it was all in memory, I'd write it to a file (cassette-based), then write another program to load the binary data and transfer control into it (can't remember how that was achieved though). On the other hand, it taught me all the basics of programming, in a very real and demanding environment. Binary though, I can see no good reason for that.

                    R Offline
                    R Offline
                    Richard A Dalton
                    wrote on last edited by
                    #11

                    Man, this is the best thread ever. Talk about walks down memory lane. Your ZX81 tape recorder worked. You lucky sod. My first computer was a second hand zx81, that never managed to talk to the tape recorder, no matter how I tried. Every time I needed the ZX81 to do anything I had to write the code again from scratch. Tim Hartnell's books became well thumbed and dog eared. Am I right in recalling the RANDOMIZE keyboard being involved in launching machine code? I always thought that was funny because genuinely you never had any idea if the string of crap you transcribed would work. RANDOMIZE always seemed appropriate. Still. At the age of 10 the zx81 showed me what I wanted to do for a living and 26 years later I get paid for doing it. If Clive Sinclair had sold "Build Your Own Hedge Fund" kits I'd probably be broke and/or in jail by now. You know what? that's my new sig.

                    K 1 Reply Last reply
                    0
                    • G Gordon Kushner

                      Can you think of why a programmer would ever use a string to act as a bitmap field? e.g.

                      DECLARE @Bitmap varchar(20)
                      SELECT @Bitmap = '00110100100011011110'

                      The beauty of bitmasks is that the values are compact (at one bit each) and you get the benefit of bitwise ANDing and ORing. I winced at this, but can you think of an instance where this might make sense (except for the obvious "Hey, I just read a cool article about bitmaps! Computer scientists use 'em all the time.")

                      D Offline
                      D Offline
                      Dr Walt Fair PE
                      wrote on last edited by
                      #12

                      Yes, and the evidence is here on CP.[^] However, I wasn't doing any bit manipulations, needed to represent variable length ciphers, and was just too lazy to do the fancy bit-shifting, etc.

                      CQ de W5ALT

                      Walt Fair, Jr., P. E. Comport Computing Specializing in Technical Engineering Software

                      1 Reply Last reply
                      0
                      • R Richard A Dalton

                        Man, this is the best thread ever. Talk about walks down memory lane. Your ZX81 tape recorder worked. You lucky sod. My first computer was a second hand zx81, that never managed to talk to the tape recorder, no matter how I tried. Every time I needed the ZX81 to do anything I had to write the code again from scratch. Tim Hartnell's books became well thumbed and dog eared. Am I right in recalling the RANDOMIZE keyboard being involved in launching machine code? I always thought that was funny because genuinely you never had any idea if the string of crap you transcribed would work. RANDOMIZE always seemed appropriate. Still. At the age of 10 the zx81 showed me what I wanted to do for a living and 26 years later I get paid for doing it. If Clive Sinclair had sold "Build Your Own Hedge Fund" kits I'd probably be broke and/or in jail by now. You know what? that's my new sig.

                        K Offline
                        K Offline
                        Keith Barrow
                        wrote on last edited by
                        #13

                        Ditto, but replace ZX81 with Sinclair Spectrum (you must be a couple of years older than me :-)) <Shivers> Hedge Fund Management</Shivers> So lucky that didn't happen.

                        ragnaroknrol The Internet is For Porn[^]
                        Pete o'Hanlon: If it wasn't insulting tools, I'd say you were dumber than a bag of spanners.

                        R 1 Reply Last reply
                        0
                        • G Gordon Kushner

                          Can you think of why a programmer would ever use a string to act as a bitmap field? e.g.

                          DECLARE @Bitmap varchar(20)
                          SELECT @Bitmap = '00110100100011011110'

                          The beauty of bitmasks is that the values are compact (at one bit each) and you get the benefit of bitwise ANDing and ORing. I winced at this, but can you think of an instance where this might make sense (except for the obvious "Hey, I just read a cool article about bitmaps! Computer scientists use 'em all the time.")

                          N Offline
                          N Offline
                          Nagy Vilmos
                          wrote on last edited by
                          #14

                          #cough# years ago, I was working on an interface to the ATM / POS network for the bank. The message spec has a bitmap at the beginning indicating the fields that would be provided; IIR it was 4 or 8 bytes. We created it properly but communicated with the card server sending strings rather then byte arrays; don't ask. Windows in it's infinite wisdom saw that the two boxes had different code pages so converted the messages. It took us an age to find that one and I got a 3 1/2 year contract in Budapest on the back of it.


                          Panic, Chaos, Destruction. My work here is done. or "Drink. Get drunk. Fall over." - P O'H

                          1 Reply Last reply
                          0
                          • K Keith Barrow

                            Ditto, but replace ZX81 with Sinclair Spectrum (you must be a couple of years older than me :-)) <Shivers> Hedge Fund Management</Shivers> So lucky that didn't happen.

                            ragnaroknrol The Internet is For Porn[^]
                            Pete o'Hanlon: If it wasn't insulting tools, I'd say you were dumber than a bag of spanners.

                            R Offline
                            R Offline
                            Richard A Dalton
                            wrote on last edited by
                            #15

                            I might not be older than you. The Spectrum was available when I got my ZX81. My mother found one for £10 in a second hand shop. Hence the non working tape recorder issue. I upgraded to a Spectrum +2 in 1988. I convinced my mother to spend over £200 (Irish) on the +2 by keying in the following program in the store: 10 Print "Tick" 20 Pause 50 30 Print "Tock" 40 Pause 50 50 GOTO 10 I was rushing to get something up on screen, and didn't have time for CLS's I fear we've strayed a little from the topic. -Richard

                            K 1 Reply Last reply
                            0
                            • R Richard A Dalton

                              I might not be older than you. The Spectrum was available when I got my ZX81. My mother found one for £10 in a second hand shop. Hence the non working tape recorder issue. I upgraded to a Spectrum +2 in 1988. I convinced my mother to spend over £200 (Irish) on the +2 by keying in the following program in the store: 10 Print "Tick" 20 Pause 50 30 Print "Tock" 40 Pause 50 50 GOTO 10 I was rushing to get something up on screen, and didn't have time for CLS's I fear we've strayed a little from the topic. -Richard

                              K Offline
                              K Offline
                              Keith Barrow
                              wrote on last edited by
                              #16

                              Halcyon days, getting the graphics to work taught me more about binary than my all Uni lectures combined .... I remember Sh*tting myself in a branch of Rumbelows at the tender age of 7 when the Commodore I was trying to "program" gave the message "The operation you have performed is illegal", I expected the police to turn up! I got my Speccy straight out the trap in 1983, aged 8/9. After that, my dad bought every machine as it was becoming "redundant" we had a Sinclair QL (seriously - with free thermal printer) and an Electron so late, my mates all just got Amigas / STs. That said, the Acorn was a much better learning machine, my mates just played Uridium.

                              ragnaroknrol The Internet is For Porn[^]
                              Pete o'Hanlon: If it wasn't insulting tools, I'd say you were dumber than a bag of spanners.

                              R 1 Reply Last reply
                              0
                              • K Keith Barrow

                                Halcyon days, getting the graphics to work taught me more about binary than my all Uni lectures combined .... I remember Sh*tting myself in a branch of Rumbelows at the tender age of 7 when the Commodore I was trying to "program" gave the message "The operation you have performed is illegal", I expected the police to turn up! I got my Speccy straight out the trap in 1983, aged 8/9. After that, my dad bought every machine as it was becoming "redundant" we had a Sinclair QL (seriously - with free thermal printer) and an Electron so late, my mates all just got Amigas / STs. That said, the Acorn was a much better learning machine, my mates just played Uridium.

                                ragnaroknrol The Internet is For Porn[^]
                                Pete o'Hanlon: If it wasn't insulting tools, I'd say you were dumber than a bag of spanners.

                                R Offline
                                R Offline
                                Richard A Dalton
                                wrote on last edited by
                                #17

                                Ah yes, drawing graphics on 8x8 squares in a copy book and converting the rows into 1s and 0s then poking the resulting values. AS for AND, OR etc, did anyone ever play Make A Chip? I couldn't believe that in college they spent days drilling this stuff into people using examples on a blackboard instead of just letting us play with a program like Make A Chip for 20 minutes. http://www.clive.nl/retro-computer-software/make-chip[^]

                                1 Reply Last reply
                                0
                                • G Gordon Kushner

                                  Can you think of why a programmer would ever use a string to act as a bitmap field? e.g.

                                  DECLARE @Bitmap varchar(20)
                                  SELECT @Bitmap = '00110100100011011110'

                                  The beauty of bitmasks is that the values are compact (at one bit each) and you get the benefit of bitwise ANDing and ORing. I winced at this, but can you think of an instance where this might make sense (except for the obvious "Hey, I just read a cool article about bitmaps! Computer scientists use 'em all the time.")

                                  B Offline
                                  B Offline
                                  Blake Miller
                                  wrote on last edited by
                                  #18

                                  "Can you think of why a programmer would ever use a string to act as a bitmap field?" How about, they represent default boolean configuration settings. You can change them after the fact by patching the EX with a different string - once you find the string, of course.

                                  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