// ZtwMenu2txt.vdm // Convert ZTW.ZAM, *.ZAM file for convenient editing // Subsequent runs toggle <=> original format // Ian Binnie 2006-11-13 "empty" lines in scripts // Ian Binnie 2006-01-08 Config changes LOCAL // Ian Binnie 2005-09-26 Improved header handling // Ian Binnie 2005-08-08 // Ian Binnie 2004-08-04 // // NOTE this only converts user part // i.e. that following "^b ZTreeMenu (tm) ... ^b" (the first 32 bytes in the file) // DO NOT change anything on, or above this line. // Make a backup before editing! // // Nulls are converted to newlines for convenient editing // // Changes // Now handles collapsed menu items // Now handles Level 0 // Now handles "empty" lines in scripts // Expands level as text "Leveln" // Strips trailing white space // Checks for string "ZTreeMenu (tm)" before toggling // // Format for each entry is:- // Empty line // Leveln [@] (where n is indent level, 1,2...) (@ indicates collapsed menu) // Menu Item Title // Script line(s) // Config(F_OVER_MODE, 0, LOCAL) Config(F_F_TYPE, 0, LOCAL) Config(F_CUST_EOL, 37, LOCAL) Config(D_DSP_WRAP, 0, LOCAL) // Needed to capture end of long lines Begin_Of_File() if(Match("|H02 ZTreeMenu (tm)",NOERR)) { Return() // Not ZTree Application Menu } Goto_Pos(32) // End of Header Set_Marker(1,Cur_Pos) //break_out(extra) if(!Match("|H00|HFF|H00")) // Unconverted Level 0 entry { Replace("|H00|HFF|H00","|nLevel0") // Level 0 Replace("|000|HFE","|N",ALL|NOERR) // 2006-11-13 replace empty line by 2 newlines Goto_Pos(Marker(1)) Replace("|000","|N",ALL|NOERR) // replace nulls by newlines Goto_Pos(Marker(1)) while(!At_EOF) { if(Match("|HFF",NOERR)==0) { #40 = cur_char(1) // level #41 = cur_char(2) // compressed level? Del_Char(2) Ins_Text("Level") Ins_Char(#40+'0') if(#41=='@') // compressed level? { Char(1) Ins_Newline(1) } } Line(1) } Goto_Pos(Marker(1)) Line(0) } else // convert back { if(!Match("|n")) { Goto_Pos(Marker(1)) Replace("|w|>","",NOERR+ALL) // trailing whitespace Goto_Pos(Marker(1)) while(!At_EOF) { if(Match("Level",NOERR)==0) { #40 = cur_char(5) // level #41 = cur_char(6) // compressed level? Del_Line(1) Ins_Char(0xFF) Ins_Char(#40-'0') if(#41=='@') { Ins_Char('@') } else { Ins_Char(0x00) } } Line(1) } repeat(ALL) { Goto_Pos(Marker(1)) Replace("|N|N","|000|254|N",ALL|ERRBREAK) // 2006-11-13 replace 2 newlines by empty line } Goto_Pos(Marker(1)) Replace("|N","|000",ALL|NOERR) } Config(F_OVER_MODE, 2, LOCAL) Config(F_F_TYPE, 4, LOCAL) Config(F_CUST_EOL, 0, LOCAL) Goto_Pos(Marker(1)) } Return