Help referencing strconstant
sjr51
I'm trying to reference a strconstant and can't get it to work. I must be missing something simple. Outside of my function I have:
StrConstant SRON_1 = "0x4477aa;"
StrConstant SRON_2 = "0x4477aa; 0xcc6677;"
StrConstant SRON_3 = "0x4477aa; 0xddcc77; 0xcc6677;"
StrConstant SRON_4 = "0x4477aa; 0x117733; 0xddcc77; 0xcc6677;"
//snip
StrConstant SRON_2 = "0x4477aa; 0xcc6677;"
StrConstant SRON_3 = "0x4477aa; 0xddcc77; 0xcc6677;"
StrConstant SRON_4 = "0x4477aa; 0x117733; 0xddcc77; 0xcc6677;"
//snip
and so on.
In my function I want to pick one of these palette lists to use and then go on to pick and calculate a colour.
//snip
String palettepick= "SRON_" + num2str(cond)
SVAR pal= palettepick
//then in a loop lower down
color=str2num(StringFromList(i-1,pal))
String palettepick= "SRON_" + num2str(cond)
SVAR pal= palettepick
//then in a loop lower down
color=str2num(StringFromList(i-1,pal))
I then calculate the 16 bit RGB from the hex color. The code all runs except that it just takes the last StrConstant in the list, i.e. even though cond=2 it will take SRON_12. So the
SVAR pal= palettepick
seems to not work the way I think it should. I've searched the help etc. and couldn't find a solution. Is it possible to determine this programmatically or do StrConstants have to be addressed by the user?
Something like this will work...
StrConstant sC2 = "constant_2"
StrConstant sC3 = "constant_3"
Function TestConstant(vIndex)
Variable vIndex
String sCon
if( vIndex == 1 )
sCon = sC1
elseif( vIndex == 2)
sCon = sC2
elseif( vIndex == 3)
sCon = sC3
endif
print sCon
End
August 20, 2015 at 06:09 am - Permalink
August 20, 2015 at 06:23 am - Permalink