How do I import a binary file with hex values

1 favourites
  • 9 posts
From the Asset Store
Convert multiple Excel files into JSON files and import them into construct3.
  • I need to import a binary file with hex values so I can

    parse through each byte.

    I am able to import the binary file fairly easy, but I am not

    sure how to edit it as hexadecimal values?

  • If it's a binary file you probably have to convert it to text first I'd think.

    construct.net/en/make-games/manuals/construct-3/plugin-reference/binary-data

    And after editing, you'll have to convert it back into binary.

  • Thank you for the help..

    I can see that I am importing the binary data file, but I am not sure how to convert that hexadecimal values that I can parse?

  • I have the feeling that just with construct events you might not have much luck. You can load the binary data and then convert it into either text or base64. Are you trying to make a hexeditor or something? What exactly are you trying to achieve?

    I'm also not very familiar with hexadecimal values in general. Maybe this helps you? byby.dev/js-hex-to-decimal

  • Hello,

    I need to import a binary file and then parse the data to interpret it.

    These binary files already exist and I was hoping to make my project

    to be able to load in these binary files, and interpret the data.

    So, far, I can load the binary files in, however, I have been unable to

    view the data as hexadecimal values. I already know how to interpret the

    binary data, if I can just view it as hexadecimal values.

  • Roughly you’d load the file into the binaryData object instead of text. Then you can access individual bytes. You’d have to convert the byte value to hex to display as text. Then after changing the hex text you’d have to convert back.

    So something like this.

    Start of layout
    — Ajax: set response to binary BinaryData
    — Ajax: request url “” as “data”
    
    Ajax: on “data” loaded
    Repeat BinaryData.ByteLength times
    — text: append function.byte2hex(BinaryData.GetInt8(loopindex))
    
    On function: updateBinaryFromText
    — repeat len(text.text)/2 times
    — binaryData: set int8 at loopindex to function.hex2byte(mid(text.text, loopindex*2,2))
    
    
    On function: byte2hex
    Parameter byte
    — set return mid(“0123456789ABCDEF”, int(byte/16),1)&mid(“0123456789ABCDEF”, byte%16,1)
    
    On function: hex2byte
    Parameter hex
    — set return to find(“0123456789ABCDEF”, left(hex,1))*16+ find(“0123456789ABCDEF”, right(hex,1))
  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Hello,

    Thank you for the assistance..

    I implemented the first part of your suggestion and I am now seeing integer values for the binary data.

    This is the beginning sequence if the binary file I am trying to load using a standard

    binary file viewer.

    The first byte is "E4"

    E4 01 0C E0 70 80 80 10 80 02 0B 01 01 02 04

    The integer values I am displaying are not decoded correctly,

    The first integer value should be 228.

    Here is the listing of the binary data inside the binary file

    E4 01 0C E0 70 80 80 10 80 02 0B 01 01 02 04

    E4 02 00 01 09 00 02 4D 00 16

    E2 01 32 66

    E2 01 32 2C 1B 4D 1B 12 1B 3A 69 43 3A 4D 1C 2D 5A 00

    E4 02 01 02 00 01 00 00

    E4 02 02 02 00 02 00 00

    E4 02 03 02 00 03 00 00

    E4 02 04 09 0B 04 02 5A 00 02 66 00

    E4 02 05 00 00 05 00 00

    E4 02 06 01 01 06 0C 14 11 66

    E3 14

    E3 11

    E2 01 32 5A 00 03 11 0C 00

    E4 02 07 00 00 07 00 00

    E4 02 08 01 01 08 03

    E0 6B 00 07 66

    E2 01 4F 35 5A 00

    E4 02 09 01 01 09 03

    E0 75 00 0B 14

    E2 01 32 79

    E2 01 32

    E3 14 00

    E4 02 0A 00 00 0A 00 00

    E4 02 0B 01 01 0B 03

    E0 74 00 07 66

    E2 01 4F 31 5A 00

    E4 02 0C 00 00 0C 00 00

    E4 02 0D 01 01 0D 03

    E0 72 00 0B 14

    E2 01 32 7B

    E2 01 32

    E3 14 00

    E4 02 0E 00 00 0E 00 00

    E4 02 0F 00 00 0F 00 00

    E4 02 10 00 09 10 02 32 00 00

    E4 02 11 00 00 11 00 00

    E4 02 12 09 01 12 03 21 5A 00 02 22 00

    E4 02 13 09 01 13 49 2E 36

    E0 1F

    E0

    E3 1F

    E2 01 32 5A

    E2 01 7D

    E2 01 7D

    E2 01 7D

    E2 01 7D

    E2 01 7D

    E2 01 7D 12 1B 4B 1C 3A

    E3 12 29 12 1B

    E3 12 43 31 34 4B 24 1B 29 24 31 29 24 3A 4D 1C 15 3C 24 2C 1C 2D 5A

    E2 01 7D

    E2 01 7D

    E2 01 7D 5A 00 02 49 00

    E4 02 14 00 01 14 03 22 5A 00 00

    E4 02 15 00 01 15 06 16 26 36 16 5A 00 00

    E4 02 16 00 01 16 03 49 5A 00 00

    E4 02 17 00 01 17 13 2C 1B 4D 1B 12 1B

    E3 12 12 31

    E3 12 12 1B

    E3 12 16 5A 00 00

    E5

  • I can’t debug it. So if it’s the same file I’m guessing it should give the same result as the hex editor. If it’s completely different then it seems like a different file or something is completely off.

  • Should be the same with the same file. But I don’t know what the editor is doing. Anyways, keep at it. Maybe you’ll spot the difference. I’m not at a computer so I won’t be able to help.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)