TimStone wrote:I have a datafile that I use for "parts used on invoices".
For quick filterning, I use SetScope functions. ( top and bottom ). It uses the invoice number as the value for both. Thus when the invoice is open, only those parts used for that specific one will display in the xBrowse control. It all works perfectly.
Now I have a client who wants that same ability, but he wants to have the numbers "searchable" which would be accomplished by placing them in partnumber order.
Does anyone have a suggestion on how to do this without messing up the scope ?
Tim
INCOICE="ABCDEF"
// C:\FWH\SAMPLES\SETSCOPE.PRG
#include "FiveWin.ch"
ANNOUNCE RDDSYS
REQUEST OrdKeyNo, OrdKeyCount, OrdCreate, OrdKeyGoto
REQUEST DBFCDX, DBFFPT
FUNCTION Main()
FIELD AGE
LOCAL cAlias, aGeIni := 20, aGeFin := 30
RDDSETDEFAULT("DBFCDX")
RDDREGISTER( "DBFCDX", 1 ) // RDT_FULL
// The following example illustrates the SET SCOPE command:
CLOSE DATABASE
USE CUSTOMER NEW
INDEX ON AGE TO CUSTOMER
// Only part numbers between 20 and 30 will be used
SET SCOPE TO 20, 30 // AGES: MIN 20 MAX 30
GO TOP
XBROWSE()
SET SCOPE TO
cAlias := ALIAS()
// Using INDEX ON... MEMORY / TEMPORARY
// Only part numbers between 20 and 30 will be used
INDEX ON AGE TAG 02 TO MARCTEMP FOR ( .NOT. EOF() ) .AND. ;
( cAlias )->AGE >= aGeIni .AND. ;
( cAlias )->AGE <= aGeFin MEMORY // TEMPORARY
GO TOP
XBROWSE()
OrdDestroy( "MARCTEMP" )
CLOSE DATABASE
RETURN NIL
/*
// Seealso
// ORDSCOPE(), SET SCOPEBOTTOM, SET SCOPETOP
*/
// FIN / END - kapiabafw@gmail.com
function orderfilter(cAlias,cTag,cStart)
local cOld_alias:=Alias(), NTag:= &cOld_alias->(indexord())
default cStart:=""
select &cAlias
set order to tag &cTag
if !empty(cTag)
set scope to alltrim(cStart)
endif
&cAlias->(dbgotop())
select &cOld_alias
&cOld_alias->(dbsetorder(nTag))
return NIL
netopen("brwsetup","Code","TempXb")
select TempXB
set filter to brwnaam = cData
tempXB->(dbgotop())
hBrw:= FW_RecToHash() // Start using Hash for all replaces below
FUNCTION MARC_SETFILTER( oBrw ) // My filter for Xbrowse heather gets.
LOCAL cFilter := ""
LOCAL n, oCol, uVal, cType, cVal1, cVal2, nGevonden
LOCAL nZoekKnop, cExprt
FOR n := 1 TO Len( oBrw:aCols )
oCol := oBrw:aCols[ n ]
IF ! Empty( uVal := oCol:uBarGetVal )
IF !Empty( cFilter )
cFilter += " .AND. "
ENDIF
cType := ValType( uVal )
if cType = "C"
nGevonden = at("++",uVal) // used because I want to look for 2 items in one get
endif
if cType = "C"
nZoekKnop = at("²",uVal) // used because I set a function key to this to start the search, so no click needed
endif
DO CASE
CASE cType == 'C' .and. nZoekKnop > 0
uVal := Upper( AllTrim( uVal ) )
cVal1 = substr(uVal,1,nZoekknop-2)
cFilter += '"' + cVal1 + '" $ UPPER( ' + oCol:CExpr + " )"
CASE cType == 'C' .and. nGevonden > 0
uVal := Upper( AllTrim( uVal ) )
cVal1 = substr(uVal,1,nGevonden-1)
cVal2 = substr(uVal,nGevonden+2)
cFilter += '"' + cVal1 + '" $ UPPER( ' + oCol:CExpr + " )"
cFilter += " .AND. "
cFilter += '"' + cVal2 + '" $ UPPER( ' + oCol:CExpr + " )"
CASE cType == 'C'
uVal := Upper( AllTrim( uVal ) )
cFilter += '"' + uVal + '" $ UPPER( ' + oCol:CExpr + " )"
CASE cType == 'D'
cFilter += oCol:cExpr + " = " + ( uVal )
OTHERWISE
cFilter += oCol:cExpr + " == " + cValToChar( uVal )
ENDCASE
ENDIF
NEXT
IF Empty( cFilter )
IF ! Empty( dbFilter() )
dbClearFilter()
oBrw:Refresh()
ENDIF
ELSE
IF !( dbFilter() == cFilter )
oClp:SetText(cFilter) // used because I generate filters on the fly with Xbrowse, copy paste into a lookup table for later use
if !empty(alias())
SET FILTER TO &cFilter
oClp:SetText(cFilter)
GO TOP
else
msginfo("Error.... Geen Alias beschikbaar")
endif
oBrw:Refresh()
ENDIF
ENDIF
oBrw:maketotals()
oBrw:SetFocus()
RETURN NIL
function Scope(cParent,cData,cChild,cChildTag,cFoto)
LOCAL cZoekdata
LOCAL aScope1, aScope2
DEFAULT cFoto:=""
cZoekdata = cData
if left(cZoekdata,1) = "#" // breakpoint in order to look for 2 items in one field
cZoekdata:= substr(cZoekdata,2)
else
cZoekdata:= upper( (cParent)->&cData)
endif
if cZoekdata = sys_scope
return NIL
endif
sys_Scope = cZoekdata
(cChild)->(dbsetorder(cChildTag))
(cChild)->(ORDSCOPE(0, "" ) )
(cChild)->(ORDSCOPE(1, "" ) )
(cChild)->( ORDSCOPE(0, cZoekData ) )
(cChild)->(ORDSCOPE(1, cZoekData ) )
(cChild)->(DBGOTOP())
//aScope := FW_DbfToArray( "JAN,FEB,MAR,APR,MAY", { || FIELD->REGION = cRegion } )
//aScope1 := (cChild)->( FW_DbfToArray() )
do case
case upper(cChild) = "NOFOTOART"
nofotoart->(dbsetorder("ID"))
nofotoart->(ORDSCOPE(0, "" ) )
nofotoart->(ORDSCOPE(1, "" ) )
nofotoart->( ORDSCOPE(0, cZoekData ) )
nofotoart->(ORDSCOPE(1, cZoekData ) )
nofotoart->(DBGOTOP())
aScope2 := (cChild)->( FW_DbfToArray() )
ACopy(aScope1,aScope2)
xbrowser(aScope2)
case cFoto = "NOFOTO"
Sys_wnd_foto = getorgfoto(nofoto->orgfoto)
oSys_image:refresh()
endcase
Return NIL
karinha wrote:Marc, I changed everything to INDEX ON...MEMORY/TEMPORARY.
Marc Venken wrote:upper(reflev)+upper(kleur)+upper(size)
upper(reflev+kleur+size)
Enrico Maria Giordano wrote:Marc Venken wrote:upper(reflev)+upper(kleur)+upper(size)
I suggest this optimization:
- Code: Select all Expand view
upper(reflev+kleur+size)
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 40 guests