This problem with evaluating strings containing "=" intrigued me so I did some testing. // Test 1
if( %A==0/0 ) type string;
else type number;
// Test 2
if( %A!=0/0 ) type number;
else type string;
// Test 3
if( %A!="=" ) type not "=";
else type "=";
// Test 4
if( %A=="--" ) type "--";
else type not "--";
// Test 5
if( "%A"=="--" ) type "--";
else type not "--";
The results for various strings containing "=" are given in the table below.| %A | Test 1 | Test 2 | Test 3 | Test 4 | Test 5 |
= | string | number | = | -- | not -- |
a=b | number | string | not = | not -- | not -- |
=b | number | string | not = | not -- | not -- |
a= | string | string | not = | -- | not -- |
If we want all strings containing "=" to evaluate as strings rather than numbers or missing values (--) then we can use tests 2, 3 and 5 as follows. (I'm assuming that we're testing the contents of cells in column B of the active worksheet.) %A=col(B)[n]$;
%S=string;
if( "%A"=="--" ) %S=missing value;
if( %A!=0/0 && %A!="=" ) %S=number;
type Row $(n) contains a %S.;
I didn't include a test for blank cells (%A="") because they will be filled with "--" when the worksheet window refreshes.
Mike Buess
Origin WebRing Member
P.S. I should have pointed out that Tests 1 and 2 contain the fuzzy logic with regard to "=". When %A="=" both (%A==0/0) and (%A!=0/0) are true. When %A="a=b" or "=b" both are false. Only when %A="a=" is one true and the other false, in which case both tests give the correct answer.
Edited by - Mike Buess on 08/31/2001 09:33:20
Edited by - Mike Buess on 08/31/2001 09:37:45
Edited by - Mike Buess on 08/31/2001 11:19:13