lparameter lcValue && character value to check local lcOldExact lcOldExact=set('exact') && Save current settings set exact on && To perform exact match if !empty(this.CursorName) and !empty(lcValue) and type('lcValue')='C' if seek(lcValue,this.CursorName, 'Code') && Check if it's duplicate =messagebox('There is a duplicate! '+lcValue+ ; ' will not be added!',48,'Warning') <strong>return .f.</strong> endif endif set exact &lcOldExact && Restore old settings return .t.Here's your same code with my way of doing it;
LPARAMETERS lcValue && character value to check LOCAL llReturn llReturn = .T. IF !EMPTY(this.CursorName) and !EMPTY(lcValue) and VarType(lcValue)='C' IF SEEK(PADR(lcValue,LEN(FieldName)),this.CursorName, 'Code') =MessageBox('There is a duplicate! '+lcValue+ ; ' will not be added!',48,'Warning') llReturn = .F. ENDIF ENDIF RETURN llReturnIn this example I have made two changes, one is not chaging SET EXACT at all, but controlling the comparison by padding the lcValue string (this is exactly the same as setting exact on and not padding). The second change is to use a return variable so that there is ONLY ONE return command in the function.