HP Forums
HP 50g Compare Strings? - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: General Forum (/forum-4.html)
+--- Thread: HP 50g Compare Strings? (/thread-2054.html)



HP 50g Compare Strings? - toml_12953 - 09-01-2014 12:03 PM

How do you compare the contents of a variable to a string in algebraic notation on an HP 50g? I've tried both the following ('a' contains either "Y" or "N")

Code:

IF ' 'a' == "Y" ' THEN
IF 'a == "Y" ' THEN

Of course neither one works. So how do you do it?

TIA

Tom L


RE: HP 50g Compare Strings? - Joe Horn - 09-01-2014 12:09 PM

(09-01-2014 12:03 PM)toml_12953 Wrote:  How do you compare the contents of a variable to a string in algebraic notation on an HP 50g? I've tried both the following ('a' contains either "Y" or "N")

Code:

IF ' 'a' == "Y" ' THEN
IF 'a == "Y" ' THEN

Of course neither one works. So how do you do it?

Suggestion: Don't use an algebraic. Just use IF a "Y" SAME THEN.


RE: HP 50g Compare Strings? - toml_12953 - 09-01-2014 01:25 PM

(09-01-2014 12:09 PM)Joe Horn Wrote:  
(09-01-2014 12:03 PM)toml_12953 Wrote:  How do you compare the contents of a variable to a string in algebraic notation on an HP 50g? I've tried both the following ('a' contains either "Y" or "N")

Code:

IF ' 'a' == "Y" ' THEN
IF 'a == "Y" ' THEN

Of course neither one works. So how do you do it?

Suggestion: Don't use an algebraic. Just use IF a "Y" SAME THEN.
That works, thanks! You should be canonized, but I can't find my cannon at the moment. ;^)


RE: HP 50g Compare Strings? - Joe Horn - 09-01-2014 10:24 PM

(09-01-2014 01:25 PM)toml_12953 Wrote:  That works, thanks! You should be canonized, but I can't find my cannon at the moment. ;^)

No need; I'm already a canon regular. Big Grin


RE: HP 50g Compare Strings? - rprosperi - 09-02-2014 03:07 AM

(09-01-2014 10:24 PM)Joe Horn Wrote:  
(09-01-2014 01:25 PM)toml_12953 Wrote:  That works, thanks! You should be canonized, but I can't find my cannon at the moment. ;^)

No need; I'm already a canon regular. Big Grin

An absolutely perfect setup like that does not come along every day Wink


RE: HP 50g Compare Strings? - toml_12953 - 09-04-2014 06:35 AM

(09-01-2014 10:24 PM)Joe Horn Wrote:  
(09-01-2014 01:25 PM)toml_12953 Wrote:  That works, thanks! You should be canonized, but I can't find my cannon at the moment. ;^)

No need; I'm already a canon regular. Big Grin

You win! Big Grin BTW, I figured out how to do what I originally wanted to do. To test for a string in algebraic notation, enclose the test in reverse quotes (the character just before the lowercase a in the CHAR screen.)

This works:

Code:
IF `a=="N"` THEN