Create new data folder full path
Posted October 24th, 2007 by bscramer
This function will create a new data folder for an input string specifying a full path from root or relative to the current data folder. In contrast to the NewDataFolder operation in Igor, this function creates the new data folder as well as any nonexisting data folders in the specified path. The function will optionally set the newly created data folder as the current data folder.
The function is useful for creating data folders to store globals and temporary waves for user functions.
Function NewDataFolderPath(path[,set]) string path variable set variable depth=itemsinlist(path,":"),i string partial=stringfromlist(0,path,":") if(strlen(partial)==0) //path is relative, beginning with a : partial="";i=1 elseif(cmpstr("root",partial)==0) //path is full from root partial="root";i=1 else //path is relative, with no initial : partial="";i=0 endif for(i=i;i<depth;i+=1) partial+=":"+possiblyquotename(cleanupname(StringFromList(i,path,":"),1)) newdatafolder/o $partial endfor if(set) SetDataFolder $partial endif end
