I would love to help but you have provided very little for me to go on.
RE: your boolean, if you recall the previous state and compare to the current using an exclusive OR operation, It should return a true when the previous and current values are different.
On the string thing, you could compare the read string with a constant and get a true when they match.
The above are simply lame ideas that may be of use. If you could go into greater detail, I may be of greater assistance.
Ben