Folder Selector
purozongo
#pragma rtGlobals=1 // Use modern global access method.
// Window Recreation
Window Folder_Selector() : Panel
Makelist()
PauseUpdate; Silent 1 // building window...
NewPanel /W=(434,276,689,553) as "Folder Selector"
SetDrawLayer UserBack
DrawText 19,34,"Double click on the folder to set as active"
ListBox list0,pos={19,52},size={75,132},proc=ListBox_G,frame=0
ListBox list0,listWave=root:lista,mode= 2,selRow= 0
EndMacro
// List Box Control
Function ListBox_G(ctrlName,row,col,event) : ListBoxControl
String ctrlName
Variable row
Variable col
Variable event //1=mouse down, 2=up, 3=dbl click, 4=cell select with mouse or keys
//5=cell select with shift key, 6=begin edit, 7=end
WAVE lista=root:lista
if (event == 3)
String/G nombre //name of the current Folder
string cmd
sprintf cmd," nombre = root:lista[%g]", row
execute cmd
if (cmpstr (nombre,"root:") == 0)
setdatafolder root:
else
nombre = "root:"+ nombre
setdatafolder $nombre
endif
print nombre
setdatafolder $nombre
endif
return 0
End
// Folders List Function
Function Makelist()
string objName
variable n,i
i=0
n = CountObjects(":",4)
Make/O /T /N=(n+1) lista
lista[0] = "root:"
do
objName = GetIndexedObjName(":", 4, i)
if (strlen(objName) == 0)
break
endif
lista[i+1]=objName
i=i+1
print i
while(1)
end
// Window Recreation
Window Folder_Selector() : Panel
Makelist()
PauseUpdate; Silent 1 // building window...
NewPanel /W=(434,276,689,553) as "Folder Selector"
SetDrawLayer UserBack
DrawText 19,34,"Double click on the folder to set as active"
ListBox list0,pos={19,52},size={75,132},proc=ListBox_G,frame=0
ListBox list0,listWave=root:lista,mode= 2,selRow= 0
EndMacro
// List Box Control
Function ListBox_G(ctrlName,row,col,event) : ListBoxControl
String ctrlName
Variable row
Variable col
Variable event //1=mouse down, 2=up, 3=dbl click, 4=cell select with mouse or keys
//5=cell select with shift key, 6=begin edit, 7=end
WAVE lista=root:lista
if (event == 3)
String/G nombre //name of the current Folder
string cmd
sprintf cmd," nombre = root:lista[%g]", row
execute cmd
if (cmpstr (nombre,"root:") == 0)
setdatafolder root:
else
nombre = "root:"+ nombre
setdatafolder $nombre
endif
print nombre
setdatafolder $nombre
endif
return 0
End
// Folders List Function
Function Makelist()
string objName
variable n,i
i=0
n = CountObjects(":",4)
Make/O /T /N=(n+1) lista
lista[0] = "root:"
do
objName = GetIndexedObjName(":", 4, i)
if (strlen(objName) == 0)
break
endif
lista[i+1]=objName
i=i+1
print i
while(1)
end
Forum
Support
Gallery
Igor Pro 9
Learn More
Igor XOP Toolkit
Learn More
Igor NIDAQ Tools MX
Learn More
if (event == 3)
String/G nombre //name of the current Folder
string cmd
sprintf cmd," nombre = root:lista[%g]", row
execute cmd
if (cmpstr (nombre,"root:") == 0)
setdatafolder root:
else
nombre = "root:"+ "'"+nombre+"'"
setdatafolder $nombre
endif
setdatafolder $nombre
endif
works better whit liberal names.
May 26, 2008 at 10:31 am - Permalink
string cmd
sprintf cmd," nombre = root:lista[%g]", row
execute cmd
Why do you need the global variable and execute? Can't you do it this way:
nombre = lista[row]
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
May 27, 2008 at 04:04 pm - Permalink