Retrieving the datafolder of an image

I'd like to get the datafolder of an image displayed on a graph. I've tried using the instructions below, but it's not working.
Have I misunderstood the use of GetWavesDataFolder?

string str1=StringFromList(n1-1,ImageNameList("", ";" ))
SetDataFolder GetWavesDataFolder($str1,1)


Thank you in advance,
ImageNameList() returns a list of names of image displays in a graph, not a list of wave names (although the names are usually related). You need an extra step: extracting the wave from the image name.
string str1=StringFromList(n1-1,ImageNameList("", ";" ))
Wave w = ImageNameToWaveRef("", str1)
SetDataFolder GetWavesDataFolder(w,1)


John Weeks
WaveMetrics, Inc.
support@wavemetrics.com