if(XType!='S' || XType!='G')
will always evaluate true. (if XType
is 'G'
then XType!='S'
will be true; anything else will mean that XType!='G'
will be true. Logical OR ||
will evaluate true if at least one of its inputs is true so your condition will always be true.)
Try using logical AND &&
instead. This only evaluates true if both inputs are true.
if(XType!='S' && XType!='G')