a veeerrrry old VO DBStruct() thing ...

Public support forum for peer to peer support with related to the Visual Objects and Vulcan.NET products
Post Reply
Karl-Heinz
Posts: 774
Joined: Wed May 17, 2017 8:50 am
Location: Germany

a veeerrrry old VO DBStruct() thing ...

Post 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
User avatar
Chris
Posts: 4584
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

a veeerrrry old VO DBStruct() thing ...

Post 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?
Chris Pyrgas

XSharp Development Team test
chris(at)xsharp.eu
Karl-Heinz
Posts: 774
Joined: Wed May 17, 2017 8:50 am
Location: Germany

a veeerrrry old VO DBStruct() thing ...

Post 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
User avatar
Chris
Posts: 4584
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

a veeerrrry old VO DBStruct() thing ...

Post 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?
Chris Pyrgas

XSharp Development Team test
chris(at)xsharp.eu
Karl-Heinz
Posts: 774
Joined: Wed May 17, 2017 8:50 am
Location: Germany

a veeerrrry old VO DBStruct() thing ...

Post by Karl-Heinz »

Hi Chris,

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

regards
Karl-Heinz
Post Reply