Login
`
Templates, Tools and Utilities
|
||
Icetips Article
Back to article list
Search Articles
Add Comment
Printer friendly
Direct link
Par2: Locator on a queue 2001-04-27 -- Robert Pupazzoni it's not necessary to loop thru the entire
queue searching for a partial match...
If a queue GET() fails to locate an exact match, you simply ADD() a "dummy"
record to the queue, primed with the appropriate search fields, then
immediately DELETE() it. The POSITION() function will then return the index
where the record *would have been found* (had it actually been there).
I have successfully used this technique to implement entry and incremental
locators on queue-based browses. Here is an actual code snippet which
implements an entry search on a queue-based browse with multiple sort
orders:
!-------------------------------------------------------------------------
EntrySearch ROUTINE
!-------------------------------------------------------------------------
! First, try to find exact match
sLocator = UPPER(sLocator)
CASE CHOICE(?sSortOrder)
OF 1
qList.INH:Invoice_No = sLocator
GET(qList, -qList.INH:Invoice_No)
OF 2
qList.INH:Inv_Date = DEFORMAT(sLocator, @d2)
GET(qList, -qList.INH:Inv_Date)
OF 3
qList.INH:BL_Number = sLocator
GET(qList, -qList.INH:BL_Number)
END
! Clarion docs incorrectly claim POINTER() is set to closest match on
failed
! lookup. Let's workaround by adding and immediately deleting a dummy
entry
IF ERRORCODE()
! Could not find exact match, add a "dummy" record, primed with the
search parameter
CASE CHOICE(?sSortOrder)
OF 1
qList.INH:Invoice_No = CLIP(qList.INH:Invoice_No) & ALL('<255>')
ADD(qList, -qList.INH:Invoice_No)
OF 2
qList.INH:Inv_Date += 1
ADD(qList, -qList.INH:Inv_Date)
OF 3
qList.INH:BL_Number = CLIP(qList.INH:BL_Number) & ALL('<255>')
ADD(qList, -qList.INH:BL_Number)
END
! Delete the "dummy" record
DELETE(qList)
END
! Now that POINTER() is set correctly, move the hilite bar to closest
matching location
SELECT(?List, POINTER(qList))
Today is November 21, 2024, 8:05 am This article has been viewed 35249 times.
|
|