[ACTION_]DEFINE_ASSOCIATIVE_ARRAY still isn't documented, and isn't even listed under "undocumented features." I don't know how long you're going to let this and other "more exaustive" (sp.) documentation slide, but I clipped some examples out of working code.
Buried in the WeiDU change history is a reference to me providing usage for COMPRESS/DECOMPRESS functions. Well here they are too, excerpted from BAM Batcher.
I'm not much for long-winded tutorials, so the commented code is intended to speak for itself, if you're considering using such commands to begin with.
This includes samples of the following commands:
ACTION_FOR_EACH (some folks still don't get this one)
ACTION_DEFINE_ASSOCIATIVE_ARRAY
ACTION_PHP_EACH
COMPRESS_REPLACE_FILE
DECOMPRESS_REPLACE_FILE
I'll leave stuff like GET_OFFSET_ARRAY for the rest of you to explain, since I don't get what it does (and still don't after reading the latest post).
//For each dialogue, change GivePartyGold() to GiveGoldForce() actions
ACTION_FOR_EACH dialog IN ~arkion~ ~ardrou~ ~berrun~ ~brevli~ ~brielb~ ~forthe~ ~gurke~ BEGIN
ACTION_IF FILE_EXISTS_IN_GAME ~%dialog%.dlg~ BEGIN
COPY_EXISTING ~%dialog%.dlg~ ~override~
PATCH_IF SOURCE_SIZE > 0x34 BEGIN
DECOMPILE_DLG_TO_D
REPLACE_TEXTUALLY CASE_INSENSITIVE EXACT_MATCH ~GivePartyGold~ ~GiveGoldForce~
COMPILE_D_TO_DLG
END
BUT_ONLY
END
END
//Defines an array associating creatures with a new amount of gold
ACTION_DEFINE_ASSOCIATIVE_ARRAY newgold BEGIN
~arkion~ => 100
~ardrou~ => 10
~berrun~ => 58
~brevli~ => 5
~brielb~ => 200
~gurke~ => 20
~oublek~ => 1000
~perdue%~ => 75
~pheirk%~ => 38
~scar~ => 1026
~sonner~ => 150
~wenric~ => 170
~jarlaxle~ => 25
~ppsime~ => 50
~yschearl~ => 150
END
//Writes the new amount of gold for each creature above if it exists
ACTION_PHP_EACH newgold AS crename => gold BEGIN
ACTION_IF FILE_EXISTS_IN_GAME ~%crename%.cre~ BEGIN
COPY_EXISTING ~%crename%.cre~ ~override~
PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
WRITE_LONG 0x1c gold
END
BUT_ONLY
END
END
//Compress a BAM
COPY ~bambatch/bam~ ~bambatch/bam~
READ_ASCII 0x0 sg (4) //Signature
PATCH_IF (~%sg%~ STRING_EQUAL_CASE ~BAM ~ = 1) BEGIN
dl = SOURCE_SIZE //Data length
COMPRESS_REPLACE_FILE 0 dl 9
INSERT_BYTES 0x0 0xc
WRITE_ASCII 0x0 ~BAMCV1 ~
WRITE_LONG 0x8 dl
END ELSE BEGIN
PATCH_PRINT ~%SOURCE_FILE% is not an uncompressed BAM.~
END
BUT_ONLY
//Decompress a BAM
COPY ~bambatch/bam~ ~bambatch/bam~
READ_ASCII 0x0 sg (4) //Signature
PATCH_IF (~%sg%~ STRING_EQUAL_CASE ~BAMC~ = 1) BEGIN
READ_LONG 0x8 dl //Uncompressed data length
DECOMPRESS_REPLACE_FILE 0xc (SOURCE_SIZE - 0xc) dl
END ELSE BEGIN
PATCH_PRINT ~%SOURCE_FILE% is not a compressed BAM.~
END
BUT_ONLY