Hi:
I have a comma separated values’ string where all data is text (letters “A” or “I”) and I’m doing some comparisons if ==A or ==I. This works fine. Now I want to also ask if the data is bigger or between several numbers that I’m adding to the same text file on top. So on top of all my rows of text I really have a row of numbers (really, they are strings that could be read as numbers or converted). How can I do it? For what I see, the code is not doing what I expect. The evaluated string is not converted to a number or I’m doing something wrong.
I have this piece of code
if(t[i,1] == ‘A’) then
inst.material = [253,141,60]
elsif (t[i,1] == ‘I’)
inst.material = “blue”
inst.material.alpha = 0.1
And now this is where I ask for the string (converted to float) is equal or smaller than 2
elsif(t[i,1].to_f <= 2)
inst.material = [254,237,222]
I see that all the evaluations are considered the same because the material is always the same.
The full comparison is his
if(t[i,1] == ‘A’) then
inst.material = [253,141,60]
inst.material.alpha = 0.5
elsif (t[i,1] == ‘I’)
inst.material = “blue”
inst.material.alpha = 0.1
elsif(t[i,1].to_f <= 2)
inst.material = [254,237,222]
elsif (t[i,1].to_f > 2) and (t[i,1].to_f <= 4)
inst.material = [253,190,133]
elsif (t[i,1].to_f > 4) and (t[i,1].to_f <= 6)
inst.material = [253,141,60]
elsif (t[i,1].to_f > 6) and (t[i,1].to_f <= 8)
inst.material = [230,85,13]
else
inst.material = [166,54,3]
end