// // CHECKVERS.VDM Christian Ziemski 09.07.2004 // // // This macro can be used in other macros to check whether the currently // running VEDIT matches the given version requirements. // // Since many macros (especially while using features of a new VEDIT version // that may not be widely spread, aka beta version) need such a check it may be // helpful to have a macro for that to avoid reinventing the wheel every time. // // // Examples: // // -- Reg_Set(103, "6.12") Call_File(Reg_Free, "CHECKVERS.VDM") // checks for at least version 6.12 // // // -- Reg_Set(103, "6131") Call_File(Reg_Free, "CHECKVERS.VDM") // checks for at least version 6.13.1 // // // -- Reg_Set(103, "6.12 2004-07-01") Call_File(Reg_Free, "CHECKVERS.VDM") // or // -- Reg_Set(103, "612 20040701") Call_File(Reg_Free, "CHECKVERS.VDM") // check for at least version 6.12 with release date 2004-07-01 or later // // // If the requirement isn't matched it displays an error dialog like: // // "This macro requires a newer version of VEDIT than you are currently using!" // "Current version: 6122 2004-05-24" // "Required: 6.13.1" // // and sets Return_Value > 0. // // On success the Return_Value is set to 0. // // So for example you can use a // // -- if (Return_Value > 0) { // -- // do some cleaning up // -- return // -- } // // just after the above call to quit the macro in question. // //----------------------------------------------------------------------------- // // Note: This macro uses some new features of VEDIT 6.13 // (Version_Num(EXTRA) and Version_Date) // // But I implemented some code to let it work with VEDIT < 6.13 too. // Due to this compatibility code the macro is now much bigger than // technically necessary. // //----------------------------------------------------------------------------- if (OS_Type != 1) { Message("Sorry, but this macro currently requires VEDIT for Windows!") return(9, DELETE) } Reg_Push(104,106) Num_Push(103,106) #103=Buf_Num Buf_Switch(Buf_Free) Reg_Ins(103) #104=0 // error flag Replace("|<|W", "", BEGIN+NOERR) // remove leading whitespace Replace("|W", "|H09", BEGIN+NOERR) // change whitespace to TAB for later displaying Reg_Copy_Block(103, 0, File_Size) // remember the current data for later Replace("|!|{|D,|W}", "", BEGIN+ALL+NOERR) // remove all characters that are not digits or whitespace BoF if (Match("|[|W]|>")==0) { Dialog_Input_1(105,"`Version check failed!`, `There were no valid requirements given!`, `[OK]`", SCREEN+CENTER,0,0) Buf_Quit(OK) Buf_Switch(#103) Num_Pop(103,106) Reg_Pop(104,106) return(2, DELETE) } Match("|D", ALL+ADVANCE+NOERR) // jump just after first block of digits if (Version_Num<613) { #121=Buf_Num Buf_Switch(Buf_Free) Out_Ins() Version // VEDIT (32-Bit) Ver. 6.13.1 07/07/04 \n Out_Ins(CLEAR) Search("VER.|W", BEGIN+ADVANCE) Del_Line(0) Search("|W") Replace_Block(".","", 0, Cur_Pos, BEGIN+ALL) BoF #106=Num_Eval() Search("|W") Reg_Copy_Block(104, 0, Cur_Pos, DELETE) // version_num as string Replace("|W", "") Replace("/","", ALL) if (Match("0")==0) { Ins_Text("20") } else { Ins_Text("19") } Reg_Copy_Block(106, Cur_Pos-2, Cur_Pos+2) BoF Reg_Copy_Block(106, 0, 4, APPEND) Buf_Quit(OK) Buf_Switch(#121) } else { Out_Reg(104) Num_Type(Version_Num(EXTRA), LEFT+NOCR) Out_Reg(CLEAR) } Ins_Char('0', COUNT, Max(Reg_Size(104)-Cur_Col+1,0)) // length of version_num (only digits) BoF #105=Num_Eval(ADVANCE) // version if (Version_Num<613) { if (#105 > #106) { #104=1 } } else { if (#105 > Version_Num(EXTRA)) { #104=1 } } Match("|W", ADVANCE+NOERR) // more requirements? if (! At_EoL) { #106=Num_Eval(ADVANCE) // required version date if (Version_Num<613) { Del_Block(0, File_Size) Reg_Ins(106, BEGIN) #105=Num_Eval() if (#106 > #105) { #104+=2 } Reg_Copy_Block(106, 0, File_Size) } else { if (#106 > Version_Date) { #104+=2 } } } // prepare current version info for displaying Del_Block(0, File_Size) Ins_Text(" ") if (Version_Num<613) { Reg_Ins(104) Ins_Text("\t") Reg_Ins(106) } else { Num_Ins(Version_Num(EXTRA), LEFT+NOCR) Ins_Text("\t") Num_Ins(Version_Date, LEFT+NOCR) } Char(-2) Ins_Text("-") Char(-3) Ins_Text("-") Reg_Copy_Block(104, 0, File_Size) Buf_Quit(OK) Buf_Switch(#103) if (#104) { if (#104==1) { Reg_Set(106, "This macro requires a newer version of VEDIT than you are currently using!") } else { if (#104==2) { Reg_Set(106, "This macro requires a VEDIT of newer date (possibly beta) than you are currently using!") } else { Reg_Set(106, "This macro requires a newer VEDIT version / of newer date (possibly beta) than you are currently using!") }} Dialog_Input_1(105,"`Version check failed!`, `|@(106)`, `Current version: \t|@(104) Required:\t |@(103)`, `[OK]`", SCREEN+CENTER,0,0) } #121=#104 Num_Pop(103,106) Reg_Pop(104,106) Return(#121, DELETE)