I’m maintaining a legacy P1.5 app. It works fine, and this question relates to code logic and why code that looks correct isn’t functioning as excepted.
My user selects a font from a drop-down list, and the font on-screen changes. I want to change line spacing with that selection by passing a value to a lineSpace
variable when the drop-down value is chosen. This last part is not working.
I’m using a GP4 drop-down combo control, and it works fine for my user to select a font. I can pass the text property to my code to load a font. However, when I check the value of that same selected text, it’s not triggering my IF
statement when true, rather it’s returning false
and defaulting to the ELSE
fallout value. The string I’m checking for is the same as the string value returned by the control, yet when checking if they match, I still get a false(?)
Here’s the code:
void combo1_Click1(GCombo combo) { //_CODE_:combo1:640786:
println("combo1 - GCombo event occured. Font changed to " + combo1.selectedText() );
u = loadFont(combo1.selectedText() +".vlw");
if(combo1.selectedText() == "Times"){
lineSpace = timesLineSpace;
println("Times");
}else if(combo1.selectedText() == "Arial"){
lineSpace = arialLineSpace;
println("Arial");
}else if(combo1.selectedText() == "Square"){
lineSpace = squareLineSpace;
println("Square");
}else if(combo1.selectedText() == "Script"){
lineSpace = scriptLineSpace;
println("Script");
}else if(combo1.selectedText() == "Filled"){
lineSpace = filledLineSpace;
println("Filled");
}else{
lineSpace = customLineSpace;
println("Else");
}
}
So when the user selects “Script” the combo1.selectedText()
value is “Script”, but combo1.selectedText() == "Script"
returns false
I can println
the selected value, so I know it’s getting through (also know this because the font changes), but the IF
statement logic always returns false
and resorts to the final ELSE
value.
Any thoughts, suggestions or help are greatly appreciated.