// PROJLOG.VDM - Opens a project's log file for editing in a pop-up window. // (Log file is in the Projects Directory) // // Based on code of the Mynotes.vdm originally by D.R. Evans // Mutated into Projlog.vdm by Scott Lambert July 2011 // // // Description: A quick way to enter/edit/save project notes for later // reference. Typically pops up with a single hot-key. // // When macro is called, if project log file is not open, it opens it. // if file is open, but not in current buffer, it switches to it. // if log file is in current buffer, it save it and exit file. // // Resources: Numeric regs 30-33 are saved when file is opened and restored // when file is closed. Must not be altered while file is open. // // // If project log file is not open, save state and open file in pop-up window. // If project log is already open, close it and return to original buffer. // Num_Push(30,33) #30 = Buf_Num #31 = Win_Num Buf_Switch(Buf_Free) ins_text(proj_current) goto_pos(0) replace(".prj",".log",noerr) if(return_value==0) { Buf_Quit(ok) // quit notes buffer Buf_Switch(#30) //Restore original buffer & window Win_Switch(#31) Num_Pop(30,33) //Restore original Num-Regs Return } #33=reg_free reg_copy_block(#33,0,eol_pos) buf_empty(ok) #104=file_exist("|@(#33)") if(#104==0) { file_save_as("|@(#33)") buf_empty(ok) } if ((#104=File_Check("|@(#33)"))==-1) { File_Open("|@(#33)") #32 = Screen_Lines - Win_Reserved_Bottom - Win_Reserved_Top -4 if (#32 < 4) { #32 = 4 } Win_Create(Win_Free,3,4,#32,Screen_Cols-6) Win_Switch(Win_Num,ATTACH) if (OS_Type==1) { Win_Color(96) } else { Win_Color(15) } Margin_Right(70) } else { if (#104 != Buf_Num) { //If not switched to project's log file... Buf_Switch(#104) } else { Buf_Switch(#104) file_save(nomsg) // save notes file Buf_Quit(ok) // quit notes buffer Buf_Switch(#30) //Restore original buffer & window Win_Switch(#31) Num_Pop(30,33) //Restore original Num-Regs } } Return