xsharp.eu • a veeerrrry old VO DBStruct() thing ...
Page 1 of 1

a veeerrrry old VO DBStruct() thing ...

Posted: Wed Mar 11, 2020 1:00 pm
by Karl-Heinz
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:

Code: Select all

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 := {}

...
;-)

regards
Karl-Heinz

a veeerrrry old VO DBStruct() thing ...

Posted: Wed Mar 11, 2020 5:19 pm
by Chris
Hi Karl-Heinz,

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?

a veeerrrry old VO DBStruct() thing ...

Posted: Wed Mar 11, 2020 8:13 pm
by Karl-Heinz
Hi Chris,

Yeah, it´s about the exception that´s prepared, but never thrown. Take a look at what DefErrorGen() returns and you know what´s missing.

regards
Karl-Heinz

a veeerrrry old VO DBStruct() thing ...

Posted: Wed Mar 11, 2020 10:39 pm
by Chris
Hi Karl-Heinz,

Ahh right!!! It was to obvious to notice it! :)
Error constructed but never thrown..Guess the code should had been

BREAK DefErrorGen(ptrErrInfo)

so, do you agree that the behavior of X# is the correct (intended) one, so it should probably stay as it is now?

a veeerrrry old VO DBStruct() thing ...

Posted: Thu Mar 12, 2020 7:25 am
by Karl-Heinz
Hi Chris,

Yes, because there´s is at least a VO plan to throw a exception :-)

regards
Karl-Heinz