Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search and replace comment field...

Status
Not open for further replies.

cacho1973

Programmer
Oct 30, 2012
7
NL
Hello everyone!

I have a VFP table with certain values. I need to replace, using a certain criteria, those values with 0.

Example, if the field "type" is REPA, the "thickness" should be 0, but if the "comment" field start or contains the word "half" should not be modified... (e.g "half glass", "half concrete", etc.)

My problem is I do not know how to look for the "half" in the comment

I tried the following but it is not working for all records, only for those with comment="half"

REPLACE ALL thickness WITH 0 FOR INLIST(type,'REPA','WINDOW','DOOR') while (comment<>"Half")

Thank you all for the usual support!

 
comment<>"Half" is true for all comments except "Half", also for "half glass", "half concrete" etc., as the start with a small h. You should rather check for NOT ("half" $ comment).

WHILE is only valid, if you want to start with a record, that has such a non-half comment and continue with further records while they also have a comment not contqaining "half". I rather would AND this condition with the other condition.

Your main problem is the case sensitivity. Solve that with UPPER() or LOWER()

REPLACE ALL thickness WITH 0 FOR INLIST(UPPER(type),'REPA','WINDOW','DOOR') AND NOT ("half" $ LOWER(comment))

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top