Paste/store binary data inside UE script

Paste/store binary data inside UE script

1
NewbieNewbie
1

    Mar 12, 2013#1

    Hello

    I am attempting to insert unconventional characters (essentially binary) into my UltraEdit file/script. Theres a good reason for this and I am hoping I can insert binary text into the UltraEdit editor.

    I am attempting to place a bitmaps binary data inside my UltraEdit script. The end goal is to package image data inside a script(in my case 4d Macro Script).

    So for example:

    Code: Select all

    {
    	Text IMAGE_NAME = "Delete Model.bmp";
    	Text IMAGE_DATA = "BM6      6   (                  t  t            ÿ¯½ðØéìØéìØéìØéìØéìØéìØéìØéìØéìØéìØéìØé쯽ð  ÿÊÚí  ÿ¯½ðØéìØéìØéìØéìØéìØéìØéìØéìØéìØé쯽ð  ÿÊÚíØéìÊÚí  ÿ¯½ðØéìØéìØéìØéìë×Åë×ÅØéìØé쯽ð  ÿÊÚíØéìØéìØéìÊÚí  ÿ¯½ðØéìØéìë×Å  €º¡‹ë×ů½ð  ÿÊÚíØéìØéìØéìØéìØéìÊÚí  ÿ¿¯Ð  €  ÿàÆ®  ÿ  ˜  ÿÜÊÉØéìØéìØéìØéìØéìØéìë×Å  ˆ  ÿ¹¦ÅäÌ·àÆ®´Ÿ¼  ÿ  ÿ  €¹„ÈêîØéìØé컾¹  €  ÿë×ÅÖ¿¼  ÿ·£À{œ  ÿи±âÆ«àɵ  ÿ  €ØéìØéì¹­ úóðøôïøôïë×Ū   ÿ  ÿ€ml­•€ãÈ­âDzóêáØéìØéìØéìúõòøôïøôﵧš‰tbœ¯  ÿ  ÿ®˜²À®œ‰tb®Ÿ“ØéìØéìØéìØéìØé쵧š‰tbÝƯ®˜²  ÿɯ¦É¯¦  ÿ®˜²Ö» À®œ‰tb¶·²ØéìØéì‰tbÍÀ¶ñáÒ¹©É  ÿÊ°§Ö» Ö» É¯¦  ÿ®˜²òßÐåÖÃØéìØéìØéìíòðûøôÉÅó";
    }
    
    Integer register_image(Text imageName, Text imageData)
    {
    	// Check if image is already present in Images folder: if not create it
    	
    	Text imagesFolder = get_main_image_folder();
    	if (File_exists(imagesFolder + imageName))
    		return 0;
    		
    	return file_write(imagesFolder + imageName, imageData);
    }
    
    void main()
    {
    	register_image(IMAGE_NAME, IMAGE_DATA);
    }
    Currently when I copy and paste binary into the UE Editor it changes the data slightly (I loose null chars). I understand how text files work and encoding but I am hoping there is some way to paste/store binary data inside the UE Editor?

    Is it possible? Any ideas how I could achieve this?

    6,602547
    Grand MasterGrand Master
    6,602547

      Mar 12, 2013#2

      Here is the template you need for creating a binary file with an UltraEdit script.

      Code: Select all

      // Create a new file.
      UltraEdit.newFile();
      UltraEdit.insertMode();
      // Insert a single space character as it is not possible
      // to switch to hex edit mode on an empty file.
      UltraEdit.activeDocument.write(" ");
      UltraEdit.activeDocument.top();
      // Switch to hex edit mode and delete the inserted space.
      UltraEdit.activeDocument.hexOn();
      UltraEdit.activeDocument.hexDelete(1);
      // Now binary data can be written into the file by writing the
      // hexadecimal values as ASCII string either in the form "000829030A3F"
      // or better readable with a space between the hexadeximal values.
      UltraEdit.activeDocument.write("00 08 29 03 0A 3F");
      // Refresh the hex edit display.
      UltraEdit.activeDocument.top();
      // Save and close the file.
      UltraEdit.saveAs("imagesFolder + imageName");
      UltraEdit.closeFile("imagesFolder + imageName",2);
      Open the bitmap file in UltraEdit. It is opened automatically in hex edit mode. Press Ctrl+A and use Edit - HEX Functions - Hex Copy Selected View. Paste the copied data into a new text file and remove with column editing mode the address data and the ASCII/ANSI representation of the binary bytes to get the hexadecimal ASCII strings needed for the write command(s) in the script.