// // PARCHECK.VDM Christian Ziemski 21.09.2004 // // // Checks/compares the parameters and their values in two files // and makes them visible and easily editable. // // // The default format of: // // # comment line // parameter_name = value // // is editable below (the comment sign and the equal sign.) // // // Requires exactly *two* buffers opened: The two to compare. // If the windows are not tiled that will be done automatically. // // Tip: Assign it to a key! // //---------------------------------------------------------------------- if (Buf_Total != 2) { Dialog_Input_1(106,"`PARCHECK - Error!`, `This macro requires exactly *two* buffers opened.`", WORKAREA+CENTER,0,0) return } if (Win_Overlap!=4) { Win_Tile(0) // if not tiled and completely visible: force vertical tile } Reg_Set(103, "#") // Line-Comment Reg_Set(104, "=") // Parameter sign (or what it's name is: parameter_name = value) // disable cursor line highlighting in both buffers Buf_Switch(Buf_Next, NOEVENT) Config( D_H_CR_LINE, "Highlight cursor line (1=Full, 2=Partial)", 0 , LOCAL) Update Buf_Switch(Buf_Next, NOEVENT) Config( D_H_CR_LINE, "Highlight cursor line (1=Full, 2=Partial)", 0 , LOCAL) Update Save_Pos() BoL if (Match("|@(103)")==0) { // if comment line: do nothing Restore_Pos() return } Search_Block("|@(104)", Cur_Pos, EoL_Pos, NOERR) // '=' if (Error_Match) { Restore_Pos() Dialog_Input_1(106,"`PARCHECK - Error!`, `This seems to be no valid parameter line.`", WORKAREA+CENTER,0,0) return } Save_Pos() #103=Win_Vert Char(Chars_Matched) Match("|W", NOERR+ADVANCE) Reg_Copy_Block(106, Cur_Pos, EoL_Pos) // parameter_value Restore_Pos() Search("|!|W", REVERSE+ADVANCE+NOERR) // ignore whitespace between parameter_name and "=" Reg_Copy_Block(105, BoL_Pos, Cur_Pos) // parameter_name Restore_Pos() Buf_Switch(Buf_Next, NOEVENT) Win_Switch(Win_Next) #106=Cur_Pos #107=Win_Vert BoF #104=0 repeat(ALL) { Search("|@(105)|[|W]|@(104)", NOERR) // parameter_name with '=' Update if (Error_Match) { if (#104==0) { // even not found as comment line BoF Search("|@(105)", NOERR) // parameter_name without '=' Update if (Error_Match) { Goto_Pos(#106) SVL(#107) Update Dialog_Input_1(106,"`PARCHECK`, `>>> |@(105) <<< *not* found in the other buffer.`", WORKAREA+CENTER,0,0) } else { Dialog_Input_1(106,"`PARCHECK`, `>>> |@(105) <<< only partially found ...`", WORKAREA+CENTER,0,0) } } else { Goto_Pos(#104) EoL Config( CO_W_LINE, "Color for cursor line (override)", 64 , LOCAL) // red Config( D_H_CR_LINE, "Highlight cursor line (1=Full, 2=Partial)", 2 , LOCAL) Update Dialog_Input_1(106,"`PARCHECK`, `>>> |@(105) <<< only found as *comment* in the other buffer.`", WORKAREA+CENTER,0,0) } break } else { #105=1 Set_Visual_Line(#103) Update BoL if (Match("|@(103)")==0) { // if comment line #105=0 #104=Cur_Pos Line(1, NOERR) continue } Search("|@(104)", NOERR+ADVANCE) // '=' Match("|W", NOERR+ADVANCE) if(Reg_Size(106)==0) { #105=0 } else { if (Match("|@(106)")!=0) { // if not matching values #105=0 } } EoL if (#105) { Config( CO_W_LINE, "Color for cursor line (override)", 32 , LOCAL) // green } else { Config( CO_W_LINE, "Color for cursor line (override)", 64 , LOCAL) // red } Config( D_H_CR_LINE, "Highlight cursor line (1=Full, 2=Partial)", 2 , LOCAL) Update break } } Buf_Switch(Buf_Next, NOEVENT) Config( D_H_CR_LINE, "Highlight cursor line (1=Full, 2=Partial)", 0 , LOCAL) Update