// // CUSTOMIZE.VDM Ch.Ziemski 24.10.2002 // 17.11.2002 // // // For a Demo look at CUSTDEMO.VDM // // // in: $103 label to execute here // #104 # of calling macro // $104 TReg with list of controls if( ! Is_Win32_Version){ Get_Key("Sorry, but this macro only runs with the Win32-version of VEDIT!") return(-1) } if(Reg_Size(103) == 0){ // if no label: return with error return(-1) } if((Reg_Compare(103, "READCONFIG") != 0) && (Reg_Compare(103, "SAVECONFIG") != 0) && (Reg_Compare(103, "DIALOG") != 0) && (Reg_Compare(103, "DIALOG+SAVE") != 0)){ return(-1) // if no correct label: return with error } Goto @(103) // goto the label given as parameter // -------------------------------------------------------------------- :READCONFIG: // // #101 buf for macro // #102 buf for list // #103 current buf num // #104 flag for loaded file // #105 type of var // #106 reg# of var //Reg_Empty(103) // prepare for commands #103=Buf_Num Buf_Switch(#101=Buf_Free(EXTRA)) if(#101 == -1){ Dialog_Input_1(103,"`ERROR`, `No more buffers!`", APP+CENTER,0,0) return(1) } Reg_Ins(#104) // insert running macro #102=Buf_Switch(Buf_Free(EXTRA)) Reg_Ins(104) // the control list Replace("|<|[|W]|N","", BEGIN+ALL+NOERR) // remove empty lines Replace("|<|[|W]","", BEGIN+ALL+NOERR) // remove leading whitespace BoF while(! At_EoF){ if(Cur_Char != 35 && Cur_Char != 36){ Line(1, NOERR+ERRBREAK) continue } #105 = Cur_Char // type of register Char(1) #106=Num_Eval(SUPPRESS+ADVANCE) // number of register Reg_Copy_Block(104, Cur_Pos, Cur_Pos + 1) // get divider Char(1) // get name of variable Match("|*|@(104)") #104=Chars_Matched Reg_Copy_Block(106, Cur_Pos, Cur_Pos + #104 -1) if(Reg_Size(106)==0){ Line(1, NOERR+ERRBREAK) continue } // search variable in macro Buf_Switch(#101) Reg_Empty(105) if (Search("| return Buf_Quit(OK) Buf_Switch(#103) return(1) } // Try to find the source file of this running macro so we can save the // user's selection back into it. Reg_Empty(105) if (File_Exist('"|@(106)"')) { Reg_Set(105, CUR_DIR) } else { if (File_Exist('"|(USERMACRO)/|@(106)"')) { Reg_Set(105, USERMACRO) } else { if (File_Exist('"|(MACRO)/|@(106)"')) { Reg_Set(105, MACRO) } } } if(Reg_Size(105) > 0){ // if macro source file found Reg_Set(105, "\", APPEND) // complete the path with filename Reg_Set(105, @106, APPEND) if((#104=File_Check('"|@(105)"')) != -1){ // if is already open in a buffer show warning message #119=Dialog_Input_1(106,"`Attention!`, `.gThe new configuration is active for this macro call but wasn't saved because the source file`, `of the running macro (|@(106)) seems to be already loaded.`, ` `, `Should the loaded macro been modified to reflect the changes?`, `\(Note: You have to save the file manually then to make the changes active for the next macro calls!)`, `[&Yes]`, `[&No]`",APP+CENTER,0,0) if(#119 != 1){ Buf_Quit(OK) Buf_Switch(#103) return(1) } Buf_Switch(#104) // switch to the already loaded macro file Save_Pos() }else{ // else switch to the temp. buffer with the macro text Buf_Switch(#101) Buf_Empty(OK) File_Open(@105, FORCE) // and load the macro file there } #102=Buf_Switch(Buf_Free(EXTRA)) Reg_Ins(104) // load the control list Replace("|<|[|W]|N","", BEGIN+ALL+NOERR) // remove empty lines Replace("|<|[|W]","", BEGIN+ALL+NOERR) // remove leading whitespace BoF while(! At_EoF){ // work through the list if(Cur_Char != 35 && Cur_Char != 36){ Line(1, NOERR+ERRBREAK) continue } #105 = Cur_Char // type of register Char(1) #106=Num_Eval(SUPPRESS+ADVANCE) // number of register Reg_Copy_Block(119, Cur_Pos, Cur_Pos + 1) // get divider //NEW // get name of variable Char(1) Match("|*|@(119)") //NEW Reg_Copy_Block(106, Cur_Pos, Cur_Pos + Chars_Matched -1) //NEW //OLD Reg_Copy_Block(106, Cur_Pos, EoL_Pos) if(Reg_Size(106)==0){ Line(1, NOERR+ERRBREAK) continue } // search variable in macro if(#104 == -1){ // if macro was loaded into temp. buffer Buf_Switch(#101) }else{ Buf_Switch(#104) // if macro file was already loaded } if (Search("|