Like with Ken, I've found that most mixing of a simple string$ with anything in a boolean-type test will generate an Error 20. What I've done is to essentially transform it all to numeric/boolean testing, like not(nul(X$)), which would work in all boolean cases.
BTW, Ken, "if X$=A$ and 1" is a viable test, as the X$=A$ yields a boolean result.