LOOKUP() func not working

Kladkul

Member
Hail all,

Need some help figuring out the deal with this LOOKUP() function, I've used it many times before, but just can't for the life of me figure out whats wrong with it. I'm sure it's something simple I just need a fresh set of eyes:
Code:
DEF VAR v-found AS INT. 
DEF VAR v-list AS CHAR. 
 
FIND FIRST table1 NO-LOCK WHERE 
           table1.fld1 = 'cars' AND 
           table1.fld2 = 'gm' NO-ERROR. 
IF AVAIL table1 THEN
    ASSIGN v-list = table1.fld3. /* for this example, a list of gm brands */
 
DISPLAY v-list FORMAT "X(20)".
FIND FIRST table2 NO-LOCK WHERE 
           table2.fld1 = 'john' NO-ERROR. 
IF AVAIL table2 THEN DO: 
    DISPLAY table2.fld2. 
    ASSIGN v-found = LOOKUP(table2.fld2,v-list). /* lets say table2.fld2 = 'chevy' */
    DISPLAY v-fnd. 
END.

LOOKUP() is returning a 0, even though I know for a fact 'chevy' is in the list. The list is also comma delimited.
 

punterweger

New Member
1. Youa are assign v-found, but displaying v-fnd.
2. Take lookup into a procedure editor and do some testing this might help narrow the problem.
 

Kladkul

Member
1 - Changed the variables to be easier to understand those aren't the actual tables.

Found the problem though, I needed a TRIM() around table2.fld2 in the lookup.
 
Top