Tech Tip!

Dear e-Xtra:

The Tech Tip from www.pick911.com you reprinted in your October 1st e-Xtra newsletter is flawed. This is the tip as written:

POS = INDEX(STRING,VALUE,1)
POS = DCOUNT(STRING[1,POS],CHAR(253))

STRING - the string we are going to search in (ex: attribute)
VALUE - the value we are looking for
POS - multivalue position

This, however, can fail if the multi-valued list is not in sequence. For example, consider the string

X10]X2]X1

where "]" represents the Value Mark, or CHAR(253).

If we are looking for the value "X1", the technique given in the tip evaluates as:

POS = INDEX("X10]X2]X1","X1",1) --> sets POS to 1, the first occurance
of "X1" POS = DCOUNT("X10]X2]X1"[1,1],CHAR(253))

POS will return a 1, not the 3 we were expecting. A better way of doing this would be:

POS = 0
LOCATE(VALUE, STRING; POS) THEN ... ELSE ...

This is an example of false economy of non-precious cycles. Techniques such as the one from www.pick911.com were common back in the 70s. Everyone tried to save every CPU cycle possible. In today's environment, program correctness is more important tha a few cycles on a fast, cheap, CPU.

At least that is the opinion we teach in our classes.

Sincerely,

Clifton Oliver
Clifton Oliver & Associates
 

menu
menu