Background:
I'm writing a function (for a testing/debugging tool, not a mod) that takes a large file, reads it a byte at a time, formats that byte, then SPRINTs the formatted string to the end of a string to be PRINTed or otherwise saved to a log file for later examination.
The code looks something like this (but looped for every byte in the file):
READ_BYTE 0x0 mybyte
SPRINT mybyte ~ %mybyte%~
INNER_PATCH_SAVE mybyte~%mybyte%~ BEGIN // Format the current byte to be exactly 3 characters, padded with spaces
DELETE_BYTES 0 (BUFFER_LENGTH - 3)
END
SPRINT info ~%info%%mybyte% ~ // String containing every byte in the file, converted to an integer (0-255) and formatted with spaces
This is a simplified version and while what I have written works, it takes 40 minutes (reported by ACTION_TIME, thanks Wisp!) to process a ~1MB file which is absurdly ridiculous.
What I'd like to do:
I've got a couple thoughts on how to make this faster (but I'm certainly open to suggestions!). The primary one being instead of having to format all 1,000,000 bytes of the file one at a time, I'd like to format all 256 possible integers, store them in an array, and use the array as a lookup table so that SPRINT mybyte~ %mybyte%~
INNER_PATCH_SAVE mybyte~%mybyte%~ BEGIN // Format the current byte to be exactly 3 characters, padded with spaces
DELETE_BYTES 0 (BUFFER_LENGTH - 3)
END
doesn't have to be executed for every single byte in the file.
My problem is that the array syntax WeiDU uses is vastly different than any array/object syntax I'm used to, and even after reading the documentation and included array construct "tutorial" I don't understand how to dynamically assign key, value pairs (or retrieve them). Any help or suggestions would be appreciated.
-Sam.