FoxPro - What is incorrect about this SCAN FOR loop?

Viewed 39

I get an error: 'command contains unrecognized phrase/keyword' when I try to run a Scan For loop that looks like:

SCAN FOR table2_data.item_id = table1_data.item_id AND table2_data.status LIKE '%loaded%'

Any thoughts on why this is incorrect?

For some reason it works with:

SCAN FOR table2_data.item_id = table1_data.item_id AND table2_data.status = ALLTRIM('loaded') 

Can I not use LIKE in a SCAN FOR loop?

2 Answers

Try this:

SCAN FOR table2_data.item_id = table1_data.item_id AND LIKE('*loaded*',table2_data.status)

I don't remember using LIKE() function; I used to use the "$" operator which works like like!

Your second code is the way to go, except for a small correction:

SCAN FOR table2_data.item_id = table1_data.item_id AND alltrim(table2_data.status) = 'loaded'

You can also take casing into account and write that as:

SCAN FOR table2_data.item_id = table1_data.item_id AND lower(alltrim(table2_data.status)) = 'loaded'
Related