#pragma TextEncoding = "UTF-8" #pragma rtGlobals=3 // Use modern global access method and strict wave access #pragma DefaultTab={3,20,4} // Set default tab width in Igor Pro 9 and later Menu "Macros" "Save Layout Copy",SaveLayoutCopyPanel() End Function SaveLayoutCopyPanel() KillWindow/Z SLC NewPanel/N=SLC/K=1/W=(100,100,300,200) as "Save Layout Copy" PopUpMenu selectLayout win=SLC,pos={25,25},size={100,20},title="Layout:",value=WinList("*",";","WIN:4") Button saveLayout win=SLC,pos={61,50},size={75,20},title="Save",proc=SLCButtonProc Button mergeExperiments win=SLC,pos={50,75},size={100,20},title="Merge PXPs",proc=SLCButtonProc End Function SLCButtonProc(ba) : ButtonControl STRUCT WMButtonAction &ba switch( ba.eventCode ) case 2: // mouse up // click code here strswitch(ba.ctrlName) case "saveLayout": ControlInfo/W=SLC selectLayout String whichLayout = S_Value SaveLayoutCopy(whichLayout) break case "mergeExperiments": DoAlert/T="Merging Experiments" 1,"Are you sure? This will merge all experiments in the selected folder into the current experiment. Save a copy first." If(V_flag == 1) NewPath/O/Z/Q mergePath Else break EndIf PathInfo mergePath If(V_flag) String folder = S_path EndIf Variable error = mergePXPs(folder) If(error) DoAlert 0,"No folder was defined, merge cancelled" EndIf break endswitch case -1: // control being killed break endswitch return 0 End Function SaveLayoutCopy(whichLayout) String whichLayout //Get a list of all the graphs in the current layout page String info = LayoutInfo(whichLayout,"Layout") Variable numObjects = str2num(StringByKey("NUMOBJECTS",info,":",";")) Variable i String graphName = "" //This is the path that the new pxp will be saved in String path = SpecialDirPath("Desktop",0,0,0) + "Layouts" NewPath/O/Z/Q savePath info = "" For(i=0;i