Hi @BoxSoft
Regarding your comment on today’s webinar about a command to fetch records using just a key label and the corresponding values, I wrote exactly that a few years ago as a part of Table Manager (GitHub).
The implementation is very straightforward and relies only on Clarion’s native reflection:
TableManager.GET PROCEDURE(KEY pKey1,? pKeyVal1,<? pKeyVal2>,<? pKeyVal3>,<? pKeyVal4>,<? pKeyVal5>,<? pKeyVal6>,<? pKeyVal7>,<? pKeyVal8>,<? pKeyVal9>,<? pKeyVal10>)!,BOOL
fileref &FILE
grpref &GROUP
idx LONG
fld ANY
CODE
fileref &= pKey1{PROP:File}
grpref &= fileref{PROP:Record}
IF grpref &= NULL THEN RETURN FALSE.
IF SELF.GetClearsBuffer THEN CLEAR(grpref).
LOOP idx = 1 TO 10
IF OMITTED(2+idx) THEN CYCLE. !1 class, 2 key
IF idx > pKey1{PROP:Components}
!Raise error
BREAK
.
fld &= WHAT(grpref,pKey1{PROP:Field, idx})
IF fld &= NULL
CYCLE
.
EXECUTE idx
fld = pKeyVal1
fld = pKeyVal2
fld = pKeyVal3
fld = pKeyVal4
fld = pKeyVal5
fld = pKeyVal6
fld = pKeyVal7
fld = pKeyVal8
fld = pKeyVal9
fld = pKeyVal10
.
.
GET(fileref,pKey1)
IF ERRORCODE()
RETURN FALSE
.
RETURN TRUE
!Example:
tm TableManager
CODE
IF tm.GET(ORD:KeyCustOrderNumber, 4, 3)
! Some code
.
I’ve been using it in all new code and whenever I refactor old code. It works great and saves a lot of lines.
Unfortunately, we can’t use the keyword GET
because there’s an existing form of Clarion’s command that accepts a key and a pointer value:
GET( key , keypointer )
…
keypointer: A numeric constant, variable, or expression for the value returned by the POINTER(key) procedure.
That’s one reason I implemented this inside a class. Of course, a different keyword like GetKey()
could be used instead.
It would be interesting to see if this GET(key,keypointer)
form can be overridden when implementing a driver using CapeSoft’s new Clarion Driver Kit.