Quick graph transfer between experiment sessions
Thu, 04/22/2021 - 07:34 pm
This is a complete and more robust rewrite of the Transfer Graphs project by user wings (see https://www.wavemetrics.com/project/TransferGrpahs ), which does not seem to get updated anymore. The idea is to "save" the top graph and recreate it in another Igor session with just two quick menu calls. The source experiment must have been saved in its current state for this to work. Note that something similar could also be achieved by saving a graph copy and merging the graph experiment file into another session.
Other notes and caveats:
- Details are saved inside the clipboard. Any previous clipboard information is lost.
- The source experiment gets 'modified' by the creation of a temporary wave (W_WaveList). Don't be surprised when Igor asks you to save the experiment even though you only have copied a graph.
- A lot of code is spent on catching errors from loading the data. This could get much shorter when / if LoadData supports the /Z flag.
"Save Top Graph",/Q, SaveTopGraph()
"Load Saved Graph",/Q, LoadSavedGraph()
String expName = IgorInfo(12)
Abort "You need to save the experiment before using this functionality."
String saveRec = "TransferGraph@"+S_Path+expName+"@"+WinName(0,1)+"@"
GetWindow kwTopWin, wavelist
for (i=0; i<DimSize(wList,0); i++)
saveRec += wList[i]+";"
saveRec += "@"+ReplaceString("root:",WinRecreation("",0),":")
String loadRec = GetScrapText()
Abort "You need to first save a graph."
String filePath = StringFromList(1,loadRec,"@")
String grName = StringFromList(2,loadRec,"@")
String wList = StringFromList(3,loadRec,"@")
String grRec = StringFromList(4,loadRec,"@")
DFREF saveDFR = GetDataFolderDFR()
DFREF base = root:$grName
Variable i, j
for (i=0; i<ItemsInList(wList); i++)
String curr = ReplaceString("'",StringFromList(i,wList),"")
String path = ParseFilePath(1, curr, ":", 1, 0)
for (j = 0; j < ItemsInList(path,":"); j++)
Variable DebugOn = V_debugOnError, err = 0
LoadData/Q/O/S=path/J=ParseFilePath(0, curr, ":", 1, 0)+";" filePath; AbortOnRTE
err = GetRTError(1)
Print "Could not load the data for the graph. Maybe the source experiment was not saved in its current state. Error: " + GetErrMessage(err, 3)
for (i=2; i<ItemsInList(grRec,"\r")-1; i++)
String cmd = StringFromList(i,grRec,"\r")
Igor Pro 8
Igor XOP Toolkit
Igor NIDAQ Tools MX