Compilation Error -Setting Popupmenu Value

Hi,

 

Working on simple interface that filters a directory list of images bu key words in the filename.  But getting a compilation error that I don't quite get.

This button controls the key word filter. The error is when I try to set the filtered list to another popup menu where the user can pick the individual image. The compiler is flagging an error saying that Imagelist is not a string or string function.  But I have declared it as string.

Function PopUpStepSelction(pa) : PopupMenuControl
	STRUCT WMPopupAction &pa

	switch( pa.eventCode )
		case 2: // mouse up
			Variable popNum = pa.popNum
			String popStr = pa.popStr
			String ImageList
			ImageList = IndexedFile(DataFolder, -1, ".tif")
			variable index,maxindex
			Maxindex=itemsInList(ImageList)-1
			
			For(index =maxindex;index>0;index-=1)
				if(stringmatch(stringFromList(index,ImageList), ("*"+popStr+"*"))==0)
					imagelist = removeListItem(index,ImageList)
				endif
			endfor
			PopUpMenu ImagePick value=ImageList //this is where error is identified
			break
		case -1: // control being killed
			break
	endswitch

	return 0
End

So what completely obvious am I missing?

Andy

Hi,

Simplifying the issue:

 

This compiles:

Function PopUpStepSelction(pa) : PopupMenuControl
	STRUCT WMPopupAction &pa

	switch( pa.eventCode )
		case 2: // mouse up
			Variable popNum = pa.popNum
			String popStr = pa.popStr
			String ImageList
			ImageList = IndexedFile(DataFolder, -1, ".tif")			
//			PopUpMenu ImagePick value=imageList
			PopUpMenu ImagePick value=IndexedFile(DataFolder, -1, ".tif")	
			break
		case -1: // control being killed
			break
	endswitch

	return 0
End

This does not and the only difference is that I assign the result of the indexedfile function to an intermediate string variable.

Function PopUpStepSelction(pa) : PopupMenuControl
	STRUCT WMPopupAction &pa

	switch( pa.eventCode )
		case 2: // mouse up
			Variable popNum = pa.popNum
			String popStr = pa.popStr
			String ImageList
			ImageList = IndexedFile(DataFolder, -1, ".tif")			
			PopUpMenu ImagePick value=imageList
//			PopUpMenu ImagePick value=IndexedFile(DataFolder, -1, ".tif")	
			break
		case -1: // control being killed
			break
	endswitch

	return 0
End

I am officially confused.

Andy

The help for PopUpMenu shows many scenarios for setting the PopUpMenu value, and the version that compiles is the recommended one in your situation.

If you need to use a local string variable as the value, the syntax is rather convoluted (for historical reasons):

String ImageList = "\""+IndexedFile(DataFolder, -1, ".tif")+"\""       
PopUpMenu ImagePick value=#ImageList

Hi Jim,

Thank you for quick reply and while I won't go as far as to say I understand, I am back in business which is the important thing.

Andy