Strings to multiple files

Strings to multiple files

2

    Mar 08, 2006#1

    Hi, This might be a rather simple problem, but I am working on this huge binary data that contains nothing but scrambled, random data, except for a large number of "RIFF"-expressions. Something like this:

    Code: Select all

    ...sdfsdfsdfhksjdfhkjshdfkjshkjknsnmnmbfmsndbfRIFFsdfsdfsdfhksjdf
    hkjshdfkjshkjknsnmnmbfmsndbfsdfsdfsdfhksjdfhkjshdfkjs
    hkjknsnmnmbfmsndbf
    sdfsdfsdfhksjdfhkjshdfkjshkjknsnmnmbfms
    ndbf
    sdfsdfsdfhksjdfhkjshdfkjshkjknsnmnmbfmsn
    dbfRIFFsdfsdfsdfhksjdfhkjshdfkjshkjknsnmnmbfmsndbf
    sdfsdfsdfhksjdfhkjshdfkjshkjknsnmnmbfmsndbfsdfsdfsdfhksjdfhkjshdfkjshkjknsnmnmbfmsndbfsdfsdfsdfhksjdfhkjshdfkjshkjknsnmnmbfmsndbf
    sdfsdfsdfhksjdfhkjshdfkjshkjknsnmnmbfmsndbfsdfsdfsdfhksjdfhkjshdfkjshkjknsnmnmbfmsndbf
    sdfsdfsdfhksjdfhkjshdfkjshkjknsnmnmbfmsndbfRIFF...
    Now, all this data I would like to split into multiple files, each for one RIFF-string until the beginning of the next one:

    ...mbfmsndbfRIFFsdfsdfsdfhksjdf
    hkjshdfkjshkjknsnmnmbfmsndbfsdfsdfsdfhksjdfhkjshdfkjs
    hkjknsnmnmbfmsndbf
    sdfsdfsdfhksjdfhkjshdfkjshkjknsnmnmbfms
    ndbf
    sdfsdfsdfhksjdfhkjshdfkjshkjknsnmnmbfmsn
    dbf
    RIFFsdfsdfsdfhksj...

    Each string should be saved as incremental numbered "#.at3"-files.

    And I should probably mention that some of thse strings go as large as several MB, maybe that's the reason why I had problems creating my own macro if it.

    Thanks.

    6,686585
    Grand MasterGrand Master
    6,686585

      Mar 09, 2006#2

      Should I really help someone which forum name is Doktor Boshaft? Sorry, if your name is really Boshaft.

      Your problem is very similar to that one at forum topic counter ?. You need the macro CountUp from this topic, too.

      Your main macro is also similar. Below is the code for your main macro.

      Note:
      Trim trailing spaces before copying the 2 macros to the macro editor dialog because HTML adds a space at every line end which is bad for
      ".at3
      RIFF"
      where there should be no space after .at3.

      And don't forget to enable the macro property Continue if a Find with Replace not found for your main macro.

      Try to understand how your main macro works. I think, it's not too difficult.

      Your main macro:

      InsertMode
      ColumnModeOff
      HexOff
      NewFile
      Clipboard 9
      "0"
      StartSelect
      Key LEFT ARROW
      Cut
      EndSelect
      CloseFile NoSave
      Top
      Loop
      Find MatchCase "RIFF"
      IfNotFound
      ExitLoop
      EndIf
      EndSelect
      Key LEFT ARROW
      Key RIGHT ARROW
      StartSelect
      Find MatchCase Select "RIFF"
      IfSel
      Key LEFT ARROW
      Key LEFT ARROW
      Key LEFT ARROW
      Key LEFT ARROW
      Clipboard 8
      Copy
      EndSelect
      Key RIGHT ARROW
      Key LEFT ARROW
      NewFile
      Paste
      Top
      ".at3
      RIFF"
      Top
      Clipboard 9
      PlayMacro 1 "CountUp"
      Key END
      SelectToTop
      Clipboard 8
      Cut
      Key DEL
      SaveAs "^c"
      CloseFile
      Else
      ExitLoop
      EndIf
      EndLoop
      Clipboard 8
      ClearClipboard
      Clipboard 9
      ClearClipboard
      Clipboard 0

      By the way: Is RIFF for Raster Image File Format? Hopefully your big file with multiple RIFF images does not contain 00 bytes because the macro works only in ASCII mode and not in HEX mode. If it contains 00 bytes, try to open the file in ASCII mode with checked option Allow editing of text files with HEX 00's without converting them to spaces at Configuration - Editor - Advanced. Well, I think, it's also possible to write a macro which does the splitting in HEX mode.
      Best regards from an UC/UE/UES for Windows user from Austria

      2

        Mar 10, 2006#3

        Heh, don't worry about the name. It may sound devious, but I'm a nice guy (or am I?).

        Anyway, thanks. That halfway solved my problem, namely how to proceed with the macro. However, my big file indeed contains HEX 00-bytes, which adds to my problem.
        No matter how many times I switch Allow editing of text files with HEX 00's on or off, or directly load the file instead of drag-dropping it, sometimes I'm able to manually copy any code from the big file including the 00-bytes from ASCII mode into another file, sometimes it replaces them with spaces or simply ignores what follows. The macro won't work with it either.

        I'm sorta clueless here, any idea how to proceed or what settings I need to take precaution for?

        Edit: Never mind, I found the solution by modifying the new file with

        Code: Select all

        NewFile
        " "
        SelectAll
        HexOn
        Paste 
        HexOff
        Thanks again though.

        6,686585
        Grand MasterGrand Master
        6,686585

          Mar 11, 2006#4

          Aaahhh, switching to hex mode in the new file before pasting to avoid the conversion of the null bytes to spaces - very good idea. Even a macro profi can still learn something. Great, because I must not develop the splitting macro now for work completely in hex mode.
          Best regards from an UC/UE/UES for Windows user from Austria