Is it possible to encode images, dlls & any sort of files & reproduce them?

 

Suppose I'm trying to create a script that will  have all the resources,external  dependencies saved in it.

So far i know about base64'ing  simple strings.

But what if i want to encode a whole jpg/dll file, for example?

If possible, the next question is : "how to reproduce those files for use in scripts"?

 
Tusher Ahmed:

Suppose I'm trying to create a script that will  have all the resources,external  dependencies saved in it.

So far i know about base64'ing  simple strings.

But what if i want to encode a whole jpg/dll file, for example?

fxsaber wrote a cool library that converts "any type" into bytes.

https://www.mql5.com/ru/code/16280

He pointed this out to me when I was trying to return non-double data from remote testing agents.

If possible, the next question is : "how to reproduce those files for use in scripts"?

For images, I would look to CCanvas.

For DLLs or scripts or anything you want to execute . . . I don't think there is any eval() functionality in MQL.

 
Anthony Garot:

fxsaber wrote a cool library that converts "any type" into bytes.

https://www.mql5.com/ru/code/16280

He pointed this out to me when I was trying to return non-double data from remote testing agents.

For images, I would look to CCanvas.

For DLLs or scripts or anything you want to execute . . . I don't think there is any eval() functionality in MQL.

Thanks for finding! I'll take a look at the library, but for now i'm  looking for a simple way.

Please see this example :
I could successfully read a .png file & write as another bin file. This reproduces the exact png file.

int OnInit()
  {
//--- indicator buffers mapping
int handle=FileOpen("logo.png",FILE_BIN|FILE_READ|FILE_WRITE);
int handle2=FileOpen("logoCopy.png",FILE_BIN|FILE_READ|FILE_WRITE);

char binArray[];
FileReadArray(handle,binArray,0,WHOLE_ARRAY);

FileWriteArray(handle2,binArray,0,WHOLE_ARRAY);

FileClose(handle);FileClose(handle2);


//---

This led me to thinking that i can possibly keep/save any file in the script as a predefined array.

Is there anyway to keep the png file in my script, as predefined array?? (a huge array of binary/uchars maybe?? how can such be achieved??)