asar
asar copied to clipboard
convert decimal variable to hex
I have many folders, numbered 1,2,3,7,8,9,A,C,11,12 (hexadecimal numbers). I made a loop in asar to check each folder contents* one by one. The index value in loop is decimal so i cannot check the hexadecimal lettered folders, It would help something !letter #= hex(!index).
Long story short, i want to know which folders exist and which are not (for example 4,5,6 are missing)
- using getfilestatus() to a fixed file existing in each folder
I guess this is sort of similar to what was proposed in https://github.com/RPGHacker/asar/issues/183 - some way to convert numbers to hex literals.
Definitely worth doing in some form. Still not sure what the best approach is. Ideally, I'd like something that's flexible enough to also support other types of formatting in the future, but without polluting syntax in a way that could confuse Asar too much.
Honestly, I'd kinda like for Asar to support some kind of format strings. Maybe also as a future replacement for our current print mechanism?
imo the most sane approach would be to make math support strings properly, then we can make the print-specific hex/dec/bin functions available in regular math too, and you could do !thing #= hex(whatever) (which is actually the exact syntax gizaha suggested)
I found a workaround: I include a big file i create with autohotkey. The file contents are: !dec2hex_0 = 0 !dec2hex_1 = 1 !dec2hex_2 = 2 !dec2hex_3 = 3 !dec2hex_4 = 4 !dec2hex_5 = 5 !dec2hex_6 = 6 !dec2hex_7 = 7 !dec2hex_8 = 8 !dec2hex_9 = 9 !dec2hex_10 = A !dec2hex_11 = B !dec2hex_12 = C !dec2hex_13 = D !dec2hex_14 = E !dec2hex_15 = F !dec2hex_16 = 10 !dec2hex_17 = 11 !dec2hex_18 = 12
etc
so in asar when i want to convert i use !hex_converted := !{dec2hex_!{decimal}}
implemented this, !thing #= hex(!number) should work in asar 2.0