******************************************************************** * Description.......: BTCC_group.BTC_WherExp: method to obtain the search expression for this criterion * Calling Samples...: * Parameter List....: mapto_arg * Created by........: MDA * Modified by.......: Nadya Nosonovsky 01/24/2000 05:04:37 PM ******************************************************************** * 8/4/99: Adapted from preliminary logic for handling the Counties listbox. * 8/5/99: support optional exclusion lists. * 9/8/99: revised for support of query types. * 9/9/99: introduce optional argument to this method, in order to handle cascading logic * as well as the final result criterion. * 12/10/99 NN changed this method to use optimization * This function returns a single piece of the search criteria, or empty string if nothing selected. lparameters mapto_arg && takes 1 optional argument * mapto_arg: optional alias.fieldname mapping to use in resulting expression. * If omitted or empty, the mapping is determined by the array * property, btcmaparray, for the current query type. local lcCrit, lcRetValue, lnSel, i, lnCodes, mapto with this mapto=iif(empty(m.mapto_arg), .btcmaparray[thisform.btcqtmappingnum], m.mapto_arg) if empty(mapto) && empty for this Query Type lcRetValue='' endif lcCrit = .BTC_ItemList() && get the list of selected items if empty(lcCrit) && no explicit selection was made lcRetValue='' && null criterion result endif if vartype(lcRetValue)='L' && Return value was not assigned yet if !empty(.CursorName) and pemstatus(this, 'btcselarray',5) && Need to insert records into cursor lnSel=select() && save current area select (.CursorName) zap && clear previous result lnCodes=alen(.btcselarray) && Number of selected items for i=1 to lnCodes insert into (.CursorName) (code) ; values (.btcselarray[i]) && Populate cursor next select (lnSel) && restore previous selection endif if empty(lnCodes) lnCodes=occurs(',',lcCrit)+1 && Number of commas within crit endif do case case lnCodes=1 && only one value lcRetValue= mapto+iif(.ExcludeFlag,'<>','=')+lcCrit case lnCodes<=24 && INLIST function is limited by 24 codes * return INLIST() criterion for field value in an enumerated list lcRetValue= iif(.ExcludeFlag,'!','')+'INLIST(' + mapto + ',' + lcCrit + ')' otherwise * Temproraly solution - breaks on the several INLISTs lcCrit='' lcRetValue='' for i=1 to lnCodes lcCrit=lcCrit+'"'+.btcselarray[i]+'"'+iif(mod(i,24)=0 or i=lnCodes,'',',') if mod(i,24)=0 if i>24 lcRetValue=lcRetValue+iif(.ExcludeFlag,' and !',' or ')+; 'INLIST(' + mapto + ',' + lcCrit + ')' else lcRetValue=lcRetValue+iif(.ExcludeFlag,'!','')+; 'INLIST(' + mapto + ',' + lcCrit + ')' endif lcCrit='' && Start a new loop endif next if !empty(lcCrit) && Remainder lcRetValue=lcRetValue+iif(.ExcludeFlag,' and !',' or ')+; 'INLIST(' + mapto + ',' + lcCrit + ')' endif lcRetValue='('+lcRetValue+')' && Surrounded by () endcase endif endwith return lcRetValueIt works fine...