When comparing some VO and X# DB functions I noticed these differences when no table is open.
VO
DBStruct() -> empty array
AFields() -> 0
X#
DBStruct() -> no table exception
AFields() -> no table exception
Ok, now the 2 cents question: The snippet is part of the VO-SP3 DBStruct() sources. Which essential piece of code is missing in the IF ! Used() condition branch ? :huh:
FUNCTION DbStruct() AS ARRAY PASCAL
LOCAL aStruct AS ARRAY
LOCAL nFCount AS DWORD
LOCAL nProps AS DWORD
LOCAL i,j AS DWORD
LOCAL aField AS ARRAY
LOCAL xNewVal AS USUAL
aStruct := {}
nFCount := FCount()
IF !Used()
ptrErrInfo := _VODBErrInfoPtr()
ptrErrInfo.dwGenCode := EG_NOTABLE
ptrErrInfo.dwSubCode := EDB_NOTABLE
ptrErrInfo.pszSubSystem := Cast2Psz("DBCMD")
ptrErrInfo.dwSeverity := ES_ERROR
ptrErrInfo.lCanDefault := .T.
ptrErrInfo.symFuncSym := #DBSTRUCT
DefErrorGen(ptrErrInfo)
ELSE
FOR i := 1 UPTO nFCount
aField := {}
...
I am not sure i am seeing something. I would prefer FCount() to be in there, but since this is not throwing an error, it is not doing harm in practice. There's no RETURN in there either, but I think this is as designed, to allow the function (in VO) to return an empty array if something went wrong. Do you mean something about how the error is invoked?