Hi there. I need your help guys. I mean you luigi. I have this piece of code to parse file but i need to convert MATNAME long values to plain text and save as *.txt. Output format should look like
if file_type == 25 get SIZE long savepos OFFSET get MATCOUNT long math MATCOUNT - 2 endian big get MDLHDRNAME long for i = 0 < MATCOUNT get MATNAME long next i endian little string NAME p "%s%s/%s/%d/0x%08x.mdlhdr_hdr" FNAME _unpacked Data file_type file_ID log NAME OFFSET SIZE
I tried slog but unsuccessfully. Maybe prinf function? Thanks in advance.
set TAB binary "\x0A" set TMP string "0x" log MEMORY_FILE2 0 0 math MEM = -2
for i = 0 < MATCOUNT getdstring MATNAME 4 #string MATNAME r MATNAME # uncomment to swap endianness string MATNAME 0b MATNAME string BASE p "%s%s" TMP MATNAME putdstring BASE 10 MEM putct TAB string -1 MEM next i
get SIZE asize MEM log "output.txt" 0 SIZE MEM
You can set your own delimiter and prefix, and also change value endianness this way.
savepos TMP math BASE_OFF = FILES math BASE_OFF *= 10 math BASE_OFF += TMP math BASE_OFF x= 8
for i = 0 < FILES
get OFFSET long endian big get file_ID long endian little get file_type byte get bComplex byte string NAME p "%s%s/%s/%d/0x%08x.dat" FNAME _unpacked Data file_type file_ID math OFFSET *= 8 math OFFSET += BASE_OFF savepos TMP goto OFFSET
if file_type == 25 get SIZE long savepos OFFSET get MATCOUNT long math MATCOUNT - 2 set TAB binary "\x0A" set TMP string "0x" log MEMORY_FILE2 0 0 math MEM = -2 endian big get MDLHDRNAME long for i = 0 < MATCOUNT getdstring MATNAME 4 #string MATNAME r MATNAME # uncomment to swap endianness string MATNAME 0b MATNAME string BASE p "%s%s" TMP MATNAME putdstring BASE 10 MEM putct TAB string -1 MEM next i endian little get SIZE asize MEM string NAME p "%s%s/%s/%d/0x%08x.txt" FNAME _unpacked Data file_type file_ID log NAME 0 SIZE MEM endif goto TMP next i
EDiT: Fixed. It was caused by set TMP string "0x" and string BASE p "%s%s" TMP MATNAME. Changed TMP to TMP0. One more time thank you spirit.