ResGet()is flawed. It never resets
datavar size, neither does it zero-fill it before using it. As a result, a variable reused by the user for different operations can and will contain leftovers from previous operations, when new contents size is less than previous contents size. Learned this the hard way, after lots of crashes and apparently impossible errors. One line is to be changed in Compiler\Lib\ResGet.ahk as follows:
In previous tests, the same function also did not return any value, result was always blank. I ended up giving up on checking the size value but this is not right.
However, I'm not sure how/if that function ends up in the compiled exe. This brings us to the second issue: the script I'm working on needs both
ResExist(). Unfortunately, none of them can be called dynamically, which is a show stopper because script compatibility with AHK_L cannot be ensured when calling them directly and without calling them the script will be crippled in AHK_H as well as in AHK_L.
What I've tried and didn't work:
re := "ResExist", rg := "ResGet" ; tried setting them Static or Global (outside the function), to no avail
If %re%(A_ScriptFullPath, "SOME_FILE_NAME.AHK", "LIB")
%rg%(data, A_ScriptFullPath, "SOME_FILE_NAME.AHK", "LIB")
script := StrGet(&data, "UTF-8")
FileAppend, %script%, test_filename.ahk, UTF-8
; various operations
Which brings us to the third issue:
FileAppendcan't seem to work as a pair. If I leave the
StrGet()call as is above, the main script will crash. Why? I don't know. The original file that has been embedded in the resources is definitely UTF-8. I can check with Resource Hacker and the file text is displayed correctly there. Main script is also UTF-8 but there is no
If I remove second parameter ("UTF-8") from the call, main script works correctly, file is retrieved and loaded fine in a separate thread, just as it should. But…
FileAppendcommand will save either gibberish or - at best - a correct file with duplicated UTF-8 BOM, that is three extra bytes in the beginning of the file. Granted, that command was put there only for debug purposes after all those failed attempts at extracting files (ahk scripts) from resources. But still, should one need such a combination of commands and functions, this one seems to fail one way or another.
Maybe I lost it, maybe I'm limited, retarded or whatever - I could live with that, but in my humble opinion such simple things should work flawlessly and perfectly intertwined. If logic and intuition can't help, user will be put off.
Now someone pray tell how/if the above issues could be fixed on the user side, apart from the data in ResGet which I already fixed locally.
@ HotkeyIt: please fix at least the XP silent crash issue mentioned in a previous topic, so I could compile and test on this XP machine. Thank you.
P.S. Bonus flaw:
ResGetis missing from the online documentation index, it's only listed in some "Related" lists for other functions.