
Popup Menu of Root DataFolders

jjweimer
// This example shows a panel popup menu to list data folders from the root level // It excludes the Packages folder from the list // The New selection allows you to create a new data folder from the root level // NOTE: this does NOT set the location to the folder ... see the comments for details Function MakePanel() // make a sample panel // ... (use your own values here) NewPanel/W=(10,10,50,50) // .. // strings for popup menu string theTopFldr = StringFromList(0,ListofRootDataFolders()) string fldrList = "ListofRootDataFolders()" // popup menu location, size, and title (change these as you desire) PopupMenu FolderList,pos={5,13},size={84,20},title="root:" // popup menu mode, popvalue, value, and procedure // do not change these PopupMenu FolderList, mode=1, popvalue=theTopFldr PopupMenu FolderList, value=#fldrList, proc=ChangeFolder // .. return 0 end // function to return list of root data folders Function/S ListofRootDataFolders() string LoFldrs="New;\M1-;", theOne variable ic = 0 do theOne = GetIndexedObjName("root:",4,ic) if (strlen(theOne)==0) break endif LoFldrs += theOne + ";" ic += 1 while(1) LoFldrs = RemoveFromList("Packages",LoFldrs) if (strlen(LoFldrs)==0) LoFldrs = "-- none --" endif return LoFldrs end // function to change the data folder Function ChangeFolder(pa) : PopupMenuControl STRUCT WMPopupAction &pa string theFldr = "" switch( pa.eventCode ) case 2: // mouse up switch(pa.popNum) case 1: // selection is "New" prompt theFldr, "New folder name?" DoPrompt "New Folder", theFldr if (V_flag==1) break endif if (strlen(theFldr)==0) break endif // create the new folder (but do not go there) NewDatafolder/O $theFldr PopupMenu FolderList, mode=(ItemsInList(ListofRootDatafolders())) break // put your other cases here for different folders // case .... endswitch ControlUpdate FolderList // put code here to do something when a folder is selected // .... // .... break endswitch return 0 end

Forum

Support

Gallery
Igor Pro 9
Learn More
Igor XOP Toolkit
Learn More
Igor NIDAQ Tools MX
Learn More