Hi, this is probably a naive question, but I can't find the solution. A simple example is the easiest way to present the issue. IDL> v1=[1,2,3,4,5] IDL> v2=[10,20,30,40,50] IDL> match=where(v1 eq 2) IDL> help, v2[match] <Expression> INT = Array[1] IDL> match2=v2[where(v1 eq 2)] IDL> help, match2[0] <Expression> INT = 20 The problem is that v2[match] is, as expected, an array with only one item. However, this may cause different issues if used as it were a scalar (some of the issues are not very clear to me, to be honest, but some procedures fail to work, expecting a scalar, and others have different behaviours). The only solution I found is by using match2[0], as in the example, which is indeed a scalar. However, this does not seem to me an elegant solution, and it has the drawback that, if I have other arrays where I could use the same index resulting in match, in this way I should repeat for each of it the 'where' statement, instead of using always the first result. Is there an easier and more direct way to have immediately one scalar instead of a one-item array? Thanks, Stefano
|