Announcement

Collapse
No announcement yet.

What is an elegant way to do this? String to Chr$

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • What is an elegant way to do this? String to Chr$

    Have a string that looks like this"

    "02 01 00 00 00 06 00 00 00 00 00 00 00 00 00 00 42 4D 36 4B 00 00 00 00 00 00 36 00 00 00 28 00 00 00 50 00 00 00 50 00 00 00 01 00 18 00 00 00 00 00 00 4B 00 00 C4 0E 00 00 C4 0E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"

    I need it to look like this CHR$(02, 01, 00, 00 ETC....)

    What is an elegant way to do this?
    Before I get lost in some screwy way to do it....

  • #2
    Don't understand CHR$ if you already have a string, but REPLACE maybe can be a way..
    Code:
      LOCAL sBuf AS STRING
      sBuf = "02 01 00 00 00 06 00 00 00 00 00 00 00 00 00 00 42 4D 36 4B 00"
      REPLACE " " WITH ", " IN sBuf
      ? sBuf

    Comment


    • #3
      I gave that a try and no good.

      This is what it looks like
      String that works:

      CHR$(2,1,0,0,0,6,0,0,0,0,0,0,0,0,0,0)+"BM6K"+CHR$(0,0,0,0,0,0)+"6"+CHR$(0,0,0)+"("+CHR$(0,0,0)+"P"+CHR$(0,0,0)+"P"+CHR$(0,0,0,1,0,24,0,0,0,0,0,0)+"K"+CHR$(0,0)+"Ä"+CHR$(14,0,0)+"Ä"+CHR$(14,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0

      String that doesn't work:
      "02, 01, 00, 00, 00, 06, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 42, 4D, 36, 4B, 00, 00, 00, 00, 00, 00, 36, 00, 00, 00, 28, 00, 00, 00, 50, 00, 00, 00, 50, 00,


      The device I am writing to is expecting something like CHR$(2) + CHR$(1) etc Or CHR$(2, 1) etc...

      Comment


      • #4
        The device I am writing to is expecting something like CHR$(2) + CHR$(1) etc Or CHR$(2, 1) etc...
        Your first question used hex digits. This is a new question.

        Why the leading zero in each string that is ignored.
        I thought you were trying to do CHR$("02 ","01 ")
        CHR$(02, 01, 00, 00 ETC....)

        This no longer applies, but you want the reverse converting hex digits to decimal.

        Do you know the value of each position?
        Working with HEX$ and want a space between hex digits.
        Function can be eliminated using MID$(s,position*3-2) = HEX$(value,2,1)
        Code:
        FUNCTION PBMAIN () AS LONG
         LOCAL s           AS STRING
         LOCAL value       AS LONG
         LOCAL position    AS LONG
         s = REPEAT$(3,HEX$(0,2,1))
         MakeHex s,255,3
         ? s   '00 00 FF
        END FUNCTION
        
        FUNCTION MakeHex(s AS STRING, value AS LONG,position AS LONG) AS LONG
         MID$(s,position*3-2) = HEX$(value,2,1)
        END FUNCTION
        https://duckduckgo.com instead of google

        Comment


        • #5
          StringBuilder
          Code:
          FUNCTION PBMAIN AS LONG
           LOCAL x AS LONG
           LOCAL s1 AS STRING
           LOCAL sb AS ISTRINGBUILDERA
           sb = CLASS "STRINGBUILDERA"
           s1 = "41 42 43"
           FOR x = 1 TO LEN(s1) STEP 3
            sb.add CHR$(VAL("&h"+ MID$(s1,x,2)))
           NEXT
           ? sb.string
          END FUNCTION
          https://duckduckgo.com instead of google

          Comment


          • #6
            Deleted

            Comment


            • #7
              This is kind of a screwy thing. Grabbed the data from a USB analyzer and need to reassemble into a .bmp file. Looks like the for i = 1 to 1024 thing is required.

              Comment


              • #8
                "02 01 00 00 00 06 00 00 00 00 00 00 00 00 00 00 42 4D 36 4B 00 00 00 00 00 00 36 00 00 00 28 00 00 00 50 00 00 00 50 00 00 00 01 00 18 00 00 00 00 00 00 4B 00 00 C4 0E 00 00 C4 0E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
                00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

                I need it TO look like THIS CHR$(02, 01, 00, 00 ETC....)
                David,
                I thought you were trying to convert a string of hex values to a string of ascii values.
                StringBuilder
                Code:
                FUNCTION PBMAIN AS LONG
                 LOCAL x AS LONG
                 LOCAL s1 AS STRING
                 LOCAL sb AS ISTRINGBUILDERA
                 sb = CLASS "STRINGBUILDERA"
                 s1 = "41 42 43"
                 FOR x = 1 TO LEN(s1) STEP 3
                  sb.add CHR$(VAL("&h"+ MID$(s1,x,2)))
                 NEXT
                 ? sb.string
                END FUNCTION
                https://duckduckgo.com instead of google

                Comment


                • #9
                  David,

                  Unless I mis-understand what you want, the REPEAT$ function seems to be what you want to use for creating the "00" sequences.

                  Comment


                  • #10
                    Hi Gary, There is real data in there among all the zeros. This relates to my question about making a bmp in memory. You have done some of that right?

                    Comment


                    • #11
                      Is the size of the bitmap 258 X by 1536 Y? That is the first 4 bytes and the second 4 bytes converted from little endian hex to decimal. (but in that case a lot of bytes missing (even for monochrome bitmap))

                      If I stumbled on something … yay (else I'm just thinking out loud, and ignore!)

                      Cheers,
                      Dale

                      Comment


                      • #12
                        Hi Dale, The bmp starts at the "BM" mark. This string is the first of a bunch of strings that talk to a microcontroller at the end of a usb.
                        This is the device - https://www.elgato.com/en/gaming/stream-deck-mini

                        These strings let me put bmp images on the buttons. Very cool!

                        Comment


                        • #13
                          I used this function for something in the distant past for some type of network data conversion. Can't remember exactly what but perhaps it will be useful.

                          Code:
                          '//////////////////////////////////////////////////////////////////////////////////////////////////
                          '  zHex2Byte - Converts a string of hex values to a string of byte values.
                          '
                          '  Note that this is a very specific implementation of hex character processing. It is intended to
                          '  take strings of printable hex characters (2 bytes) and convert them to strings of single bytes
                          '  that are machine readable. A common use for this would be reading encrypted data in a text file.
                          '  Each hex value MUST be 2 bytes long or the function will return an empty string (i.e. the input
                          '  byte count must be even). If invalid characters are received (i.e. NOT 0-9, A-F), then the
                          '  function will also return an empty string. Of course, this means that there can be no spaces in
                          '  the input string.
                          '//////////////////////////////////////////////////////////////////////////////////////////////////
                          FUNCTION zHex2Byte ALIAS "zhex2Byte" (BYREF sHex AS STRING) AS STRING
                             REGISTER n  AS LONG           ' Loop counter
                             LOCAL x     AS LONG           ' Pointer for output buffer
                             LOCAL sOut  AS STRING         ' Output buffer
                             LOCAL sChr  AS STRING * 4     ' Hex string buffer for conversion
                          
                             '-- First make sure input is valid.
                             IF LEN(sHex) MOD 2 THEN EXIT FUNCTION
                             IF VERIFY (UCASE$(sHex), "0123456789ABCDEF") THEN EXIT FUNCTION
                          
                             sChr = "&H"                               ' Preload HEX char buffer
                             sOut = SPACE$(ROUND(LEN(sHex)/ 2, 0))     ' Build an output buffer
                             FOR n = 1 TO LEN(sHex) STEP 2             ' Look at hex chars (byte pairs)
                                INCR x
                                MID$(sChr, 3) = MID$(shex, n, 2)       ' Move Hex value to char buffer
                              MID$(sOut, x, 1) = CHR$(VAL(sChr))       ' Move converted value to output buffer
                             NEXT n
                             FUNCTION = sOut                           ' Return output buffer
                          END FUNCTION  ' zHex2Byte

                          Comment


                          • #14
                            How about:
                            Code:
                            Pc& = PARSECOUNT(SomeData$, $SPC)
                            Dim SomeArray$(1 TO Pc&)
                            PARSE(SomeData$, SomeArray$(), $SPC)
                            FOR I& = 1 TO Pc&
                              SomeArray$(I) = CHR$(SomeArray$(I))
                            NEXT I
                            A$ = JOIN(SomeAray$())
                            Walt Decker

                            Comment


                            • #15
                              This is what it looks like
                              String that works:
                              CHR$(2,1,0,0,0,6,0,0,0,0,0,0,0,0,0,0)+"BM6K"+CHR$(0,0,0,0,0,0)+"6"+CHR$(0,0,0)+"("+CHR$(0,0,0)+"P"+CHR$(0,0,0)+"P"+CHR$(0,0,0,1,0,24,0,0,0,0,0,0)+"K"+CHR$(0,0)+"Ä"+CHR$(14,0,0)+"Ä"+CHR$(14,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0

                              If it really does work even though it is missing the final ")" in the CHR$( statement then this should also work:
                              Code:
                              LOCAL SOMETHING AS STRING
                              
                              SOMETHING = CHR$(2,1)+$NUL+$NUL+$NUL+CHR$(6)+ _
                              $NUL+$NUL+$NUL+$NUL+$NUL+$NUL+$NUL+$NUL+$NUL+$NUL+ _
                              "BM6K"+$NUL+$NUL+$NUL+$NUL+$NUL+$NUL+"6"+$NUL+$NUL+$NUL+ _
                              "("+$NUL+$NUL+$NUL+"P"+$NUL+$NUL+$NUL+"P"+$NUL+$NUL+$NUL+ _
                              CHR$(1)+$NUL+CHR$(24)+$NUL+$NUL+$NUL+$NUL+$NUL+$NUL+"K"+ _
                              $NUL+$NUL+"Ä"+CHR$(14)+$NUL+$NUL+"Ä"+CHR$(14)+$NUL+$NUL+ _
                              $NUL+$NUL+$NUL+$NUL+$NUL+$NUL+$NUL+$NUL+$NUL+$NUL+$NUL+ _
                              $NUL+$NUL+$NUL+$NUL+$NUL+$NUL+$NUL+$NUL+$NUL+$NUL+$NUL+ _
                              $NUL+$NUL+$NUL+$NUL+$NUL+$NUL+$NUL+$NUL+$NUL+$NUL+$NUL+ _
                              $NUL+$NUL+$NUL+$NUL+$NUL+$NUL+$NUL+$NUL+$NUL+$NUL+$NUL+ _
                              $NUL+$NUL+$NUL+$NUL+$NUL+$NUL+$NUL+$NUL+$NUL+$NUL+$NUL+ _
                              $NUL+$NUL+$NUL+$NUL+$NUL+$NUL+$NUL+$NUL+$NUL+$NUL+$NUL+ _
                              $NUL+$NUL+$NUL+$NUL+$NUL+$NUL+$NUL+$NUL+$NUL+$NUL+$NUL+ _
                              $NUL+$NUL+$NUL+$NUL+$NUL+$NUL+$NUL+$NUL+$NUL+$NUL+$NUL+ _
                              $NUL+$NUL+$NUL+$NUL+$NUL+$NUL+$NUL+$NUL+$NUL+$NUL+$NUL+ _
                              $NUL+$NUL+$NUL+$NUL+$NUL+$NUL+$NUL+$NUL+$NUL+$NUL+$NUL+ _
                              $NUL+$NUL+$NUL+$NUL+$NUL+$NUL+$NUL+$NUL+$NUL+$NUL+$NUL+ _
                              $NUL+$NUL+$NUL+$NUL+$NUL+$NUL+$NUL+$NUL+$NUL+$NUL+$NUL+ _
                              $NUL+$NUL+$NUL+$NUL+$NUL+$NUL+$NUL+$NUL+$NUL+$NUL+$NUL+ _
                              $NUL+$NUL+$NUL+$NUL+$NUL+$NUL+$NUL+$NUL+$NUL+$NUL+$NUL+ _
                              $NUL+$NUL+$NUL+$NUL+$NUL
                              
                              'OR
                              
                              SOMETHING = CHR$(2,1)+REPEAT$(3, $NUL)+CHR$(6)+ _
                              REPEAT$(10, $NUL)+ _
                              "BM6K"+REPEAT$(6, $NUL)+"6"+REPEAT$(3, $NUL)+ _
                              "("+REPEAT$(3, $NUL)+"P"+REPEAT$(3, $NUL)+"P"+REPEAT$(3, $NUL)+ _
                              CHR$(1)+$NUL+CHR$(24)+REPEAT$(6, $NUL)+"K"+ _
                              REPEAT$(2, $NUL)+"Ä"+CHR$(14)+REPEAT$(2, $NUL)+"Ä"+CHR$(14)+REPEAT$(2, $NUL)+ _
                              REPEAT$(11, $NUL)+ _
                              REPEAT$(11, $NUL)+ _
                              REPEAT$(11, $NUL)+ _
                              REPEAT$(11, $NUL)+ _
                              REPEAT$(11, $NUL)+ _
                              REPEAT$(11, $NUL)+ _
                              REPEAT$(11, $NUL)+ _
                              REPEAT$(11, $NUL)+ _
                              REPEAT$(11, $NUL)+ _
                              REPEAT$(11, $NUL)+ _
                              REPEAT$(11, $NUL)+ _
                              REPEAT$(11, $NUL)+ _
                              REPEAT$(11, $NUL)+ _
                              REPEAT$(11, $NUL)+ _
                              REPEAT$(5, $NUL)
                              
                              'OR
                              
                              SOMETHING = _
                              CHR$(2,1)+ REPEAT$(3, $NUL)+ _
                              CHR$(6)+ REPEAT$(10, $NUL)+ _
                              "BM6K"+ REPEAT$(6, $NUL)+_
                              "6"+REPEAT$(3, $NUL)+ _
                              "("+REPEAT$(3, $NUL)+ _
                              "P"+REPEAT$(3, $NUL)+ _
                              "P"+REPEAT$(3, $NUL)+ _
                              CHR$(1)+$NUL+ _
                              CHR$(24)+REPEAT$(6, $NUL)+ _
                              "K"+REPEAT$(2, $NUL)+ _
                              "Ä"+CHR$(14)+REPEAT$(2, $NUL)+ _
                              "Ä"+CHR$(14)+REPEAT$(2, $NUL)+ _
                              REPEAT$(159, $NUL)
                              Elegant maybe not but it is sure easier to read.

                              Comment


                              • #16
                                Just one line of code in a loop to step through the original data.
                                Code:
                                #COMPILE EXE
                                #DIM ALL
                                #INCLUDE ONCE "WIN32API.INC"
                                
                                FUNCTION PBMAIN () AS LONG
                                    LOCAL str1,str2 AS STRING
                                    LOCAL x AS LONG
                                str1 = "02 01 00 00 00 06 00 00 00 00 00 00 00 00 00 00 42 4D 36 4B 00 00 00 00 00 00 36 00 00 00 28 00 00 00 50 00 00 00 50 00 00 00 01 00 18 00 00 00 00 00" & _
                                " 00 4B 00 00 C4 0E 00 00 C4 0E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00" & _
                                " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00" & _
                                " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00" & _
                                " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00" & _
                                " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00" & _
                                " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00" & _
                                " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00" & _
                                " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00" & _
                                " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00" & _
                                " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00" & _
                                " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00" & _
                                " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00" & _
                                " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00" & _
                                " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00" & _
                                " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00" & _
                                " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00" & _
                                " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00" & _
                                " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00" & _
                                " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00" & _
                                " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
                                
                                FOR x = 1 TO LEN(str1) STEP 3
                                    str2 += CHR$(VAL("&H" & MID$(str1,x,2)))
                                NEXT
                                
                                END FUNCTION

                                Comment


                                • #17
                                  Dave,

                                  Have a look at ASMDATA. While it is static non writable, it is not hard to make a copy of it then modify the few bytes that need to be changed.
                                  hutch at movsd dot com
                                  The MASM Forum

                                  www.masm32.com

                                  Comment


                                  • #18
                                    Are you sure about the spaces between data? Is typical that Hex editors/viewers insert spaces to make it easier to view data, but in real file data usually is "packed" without spaces in between. Anyway, BMP file format starts with 14 byte file header, followed by 40 bytes of picture info, like size, etc.
                                    Useful BMP file format info on following page: http://www.dragonwins.com/domains/ge...fileformat.htm

                                    Comment


                                    • #19
                                      Looking at the data that Dave C posted..
                                      Code:
                                      After first 16 bytes data looks like a truncated Bitmap file.
                                      
                                      02 01 00 00 00 06 00 00  00 00 00 00 00 00 00 00    Unknown
                                      42 4D                                               BM (&h42 &h4dD)           (BitmapFileHeader)
                                            36 4B 00 00                                   File size: 14 + 40 + 19200 = 19254 (&h4B36 hex little endian)
                                                        00 00  00 00                      Reserved: 0, 0
                                                                     36 00 00 00          Offset to image data: 54 (&h36)
                                                                                 28 00    Size of header: 40 (&h28) (BitmapInfoHeader)
                                      00 00
                                            50 00 00 00 50 00  00 00                      Bitmap Width x Height: 80 80 (&h50 &h50)
                                                                     01 00                Color planes: 1 (&h01)
                                                                           18 00          Bits per Pixel: 24 (3Bytes) (&h18)
                                                                                 00 00    Compression Method: None (&h00)
                                      00 00
                                          00 4B 00 00                                     Raw Image Data Size: 19200
                                                        C4 0E  00 00 C4 0E 00 00          Horizontal & Vert Res. Pixel per metre: 3,780  (&h0EC4) (~96 dpi)
                                                                                 00 00    No. Colors in palette: 0 (Default 2^n)
                                      00 00
                                            00 00 00 00                                   No. Important colors used: 0 (All important / ignored)
                                                        00 00  00 00 00 00 00 00 00 00    Truncated data starts here. (Start of image data)
                                      00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
                                      00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
                                      00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
                                      00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
                                      00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
                                      00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
                                      00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
                                      00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
                                      00 00 00 00 00 00 00 00  00 00 00 00 00 .....
                                      Last edited by Dave Biggs; 11 May 2019, 12:00 PM.
                                      Rgds, Dave

                                      Comment


                                      • #20
                                        Dave,
                                        Code:
                                        Have a string that looks like this"
                                        
                                        "02 01 00 00 00 06 00 00 00 00 00 00 00 00 00 00 42 4D 36 4B
                                        00 00 00 00 00 00 36 00 00 00 28 00 00 00 50 00 00 00 50 00
                                        00 00 01 00 18 00 00 00 00 00 00 4B 00 00 C4 0E 00 00 C4 0E
                                        00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
                                        00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
                                        00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
                                        00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
                                        00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
                                        00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
                                        00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
                                        00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
                                        00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
                                        00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
                                        00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
                                        00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
                                        00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
                                        00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
                                        00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
                                        00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
                                        00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
                                        00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
                                        00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
                                        00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
                                        00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
                                        00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
                                        00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
                                        00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
                                        00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
                                        00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
                                        00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
                                        00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
                                        00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
                                        00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
                                        00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
                                        00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
                                        00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
                                        00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
                                        00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
                                        00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
                                        00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
                                        00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
                                        00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
                                        00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
                                        00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
                                        00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
                                        00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
                                        00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
                                        00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
                                        00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
                                        00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
                                        00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
                                        00 00 00 00"
                                        
                                        Converts to this...
                                        
                                        LOCAL SOMETHING AS STRING
                                        
                                        SOMETHING = CHR$(2,1) + REPEAT$(3, $NUL) + _
                                        CHR$(6) + REPEAT$(10, $NUL) + _
                                        "BM6K" + REPEAT$(6, $NUL) + _ '42h = 66 = "B" | 4Dh = 77 = "M" | 36h = 54 = "6" | 4Bh = 75 = "K"
                                        "6" + REPEAT$(3, $NUL) + _    '36h = 54 = "6"
                                        "(" + REPEAT$(3, $NUL) + _    '28h = 40 = "("
                                        "P" + REPEAT$(3, $NUL) + _    '50h = 80 = "P"
                                        "P" + REPEAT$(3, $NUL) + _
                                        CHR$(1,0) + _
                                        CHR$(24) + REPEAT$(6, $NUL) + _ '18h = 24 = (can)
                                        "K" + REPEAT$(2, $NUL) + _      '4Bh = 75 = "K"  
                                        CHR$(196,14) + REPEAT$(2, $NUL) + _ 'C4h = 196 | 0Eh = 14
                                        CHR$(196,14) + REPEAT$(2, $NUL) + _ 'C4h = 196 | 0Eh = 14
                                        + REPEAT$(100, $NUL) + _
                                        + REPEAT$(100, $NUL) + _
                                        + REPEAT$(100, $NUL) + _
                                        + REPEAT$(100, $NUL) + _
                                        + REPEAT$(100, $NUL) + _
                                        + REPEAT$(100, $NUL) + _
                                        + REPEAT$(100, $NUL) + _
                                        + REPEAT$(100, $NUL) + _
                                        + REPEAT$(100, $NUL) + _
                                        + REPEAT$(72, $NUL)

                                        Comment

                                        Working...
                                        X