* New: function FW_DBFLOOKUP( uVal, [cOrder], bcRetExprn ) --> uResult
uVal : Value / Expression to be lookedup ( seek or locate )
cOrder : OrderName for seek. Or field name for locate. Omit if uVal
is an expression
bcRetExpr: codeblock/string: Expression to evaluate
Examples:
CUSTOMER->( FW_DBFLOOKUP( 108, "ID", "AGE" ) ) --> nAge of ID 108
CUSTOMER->( FW_DBFLOOKUP( 99, "ID", "FIELD->SALARY += 100" ) ) -->
Salary field is incremented and written to table and returns the value
ITEMS->( FW_DBLOOKUP( 101, "ITEMCODE", { || FIELD->QTY -= nOldQty } )
ITEMS->( FW_DBLOOKUP( 103, "ITEMCODE", { || FIELD->QRY += nNewQty } )
STATES->( FW_DBLOOKUP( 10, 0, "FIELD->NAME" ) ) // at recno 10
Original recno() and order are restored and any previous locks are
left intact before returning.
Reurn value NIL indicates failure
source: \fwh\function\dbffuns2.prg
ITEMS->( FW_DBLOOKUP( 101, "ITEMCODE", { || FIELD->QTY -= nOldQty } )
ITEMS->( FW_DBLOOKUP( 103, "ITEMCODE", { || FIELD->QRY += nNewQty } )
This function handles also everything not ?? (no need to extra open the dbf in a new alias)
This sample in use with a bchange function call from Xbrowse should work not ? (will test it later)
ITEMS->( FW_DBLOOKUP( obrw:code:value, "ITEMCODE", { || FIELD->GROEP = oBrw:groep:value } ) )
I suppose that we can also change more than one item with this code ? { || FIELD->GROEP = oBrw:groep:value, FIELD->DATE = date() } or maybe better call a function and change the data insite the function ?
This function supposes that the file is already open... Can we also let it open the dbf when it is not yet open before calling the function ?