Conditional assignment in text wave

Hello,

I'd like to create a "labels" text wave to use in my experiment. Manually, I'd enter the contents of the labels wave like this:
labels[0] = "img01_H"
labels[1] = "img01_V"
labels[2] = "img02_H"
labels[3] = "img02_V"

I though I could speed things up using conditional assignments, as shown below:
Make/T/N=20 labels
labels = (mod(p,2)==0)? "img0"+num2str(floor(p/2)+1)+"H" : "img0"+num2str(floor(p/2)+1)+"V"

But this throws back the syntax error:

got "mod" instead of string variable or string function name

I guess conditional wave assignments do not work in Igor Pro 6.38?
From the IP Command Help file:
? : is the conditional operator, which is a shorthand form of an if-else-endif statement. It is of the form:
<expression> ? <TRUE> : <FALSE>  
When expression is nonzero, it evaluates the TRUE part, otherwise it evaluates the FALSE part.
The ":" character in the conditional operator must always be separated with spaces from the two adjacent operands.

The operands must be numeric; for strings, you must use the SelectString function.
I'm not sure I understand.

The argument in the conditional statement is mod(p,2). It is a numeric argument operating on the wave p index. I guess you mean all operands must be strings in the conditional assignment?

In any case, SelectString does the trick:

labels = SelectString(mod(p,2)==0,"img0"+num2str(floor(p/2)+1)+"_V","img0"+num2str(floor(p/2)+1)+"_H")


Thank you!
kpantzas wrote:
I'm not sure I understand.

The argument in the conditional statement is mod(p,2). It is a numeric argument operating on the wave p index. I guess you mean all operands must be strings in the conditional assignment?

All the arguments for the conditional operator must be numeric. The conditional, the true part and the false part must all be numeric. So the only way to achieve what you want is via SelectString.

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com