fbpx
Welcome, Guest
Username: Password: Remember me
Visual Objects

Please use this forum to post questions about Visual Objects and Vulcan.NET
  • Page:
  • 1

TOPIC: VO Question: dbServer FieldGET issue

VO Question: dbServer FieldGET issue 1 week 1 day ago #9247

  Jamal's Avatar Topic Author Jamal Offline Posts: 107
Using VO 2.08 SP4b (2838), I have the following code which sometimes fails to find a field in the dbf file. Thus wPos returns 0.
The same happens in various DBF files in a random fashion and I cannot pinpoint exactly what is causing it. I am passing a SYMBOL for the field name such as oSrv:FieldGet(#MYFIELD). Is IsSymbol() the problem or is it FieldPosSym() ?
Since this is random and I cannot replicate it, I am baffled. Any idea on what is causing this issue or a possible workaround?
METHOD FIELDGET(uField) CLASS _SpeciallDBServer
	LOCAL uRetVal as USUAL
	LOCAL wPos AS DWORD
	LOCAL dwCurrentWorkArea as DWORD    
	LOCAL oError as USUAL
	
	BEGIN SEQUENCE
		VODBSelect( wWorkArea, @dwCurrentWorkArea )      
		
                IF  IsSymbol( uField )
                       wPos := FieldPosSym( uField) 

		ELSEIF IsString( uField ) 
			wPos := FieldPos( AsString(uField) )
			
		ELSEIF IsNumeric( uField )
			wPos := uField
			IF wPos > wFieldCount
				wPos := 0
			ENDIF		
		ENDIF
		
		IF wPos = 0
			InfoBox{,"Utility", "Invalid field: " + AsString(uField) + " in " + AsString(self:name) + _chr(10) + Psz2String(ProcName(2)) + _chr(10) + AsString(ProcLine(2))}:show()    
		ELSE
			(wWorkArea)->VODBFieldGet( wPos, @uRetVal )
		ENDIF    
		
		__DBSSetSelect( dwCurrentWorkArea )  //SE-060527    
		
	RECOVER USING oError
		oErrorInfo := oError
		__DBSSetSelect( dwCurrentWorkArea )  //SE-060527
		uRetVal := nil
	END SEQUENCE
	
	
	RETURN uRetVal     

Please Log in or Create an account to join the conversation.

VO Question: dbServer FieldGET issue 1 week 23 hours ago #9248

  TimothyS's Avatar TimothyS Offline Posts: 30
Suspect the problem could be in the workarea. You might want to do a few checks to see if you have the right workarea.

Please Log in or Create an account to join the conversation.

VO Question: dbServer FieldGET issue 1 week 22 hours ago #9249

  Chris's Avatar Chris Offline Posts: 1163
Or maybe sometimes for some reason the wrong symbol is being passed. I would add some debug code after the "IF IsSymbol( uField )" line that prints the symbol, workarea and return value of wPos. And if wPos == 0, maybe I would also print the names of all the fields just after.
XSharp Development Team
chris(at)xsharp.eu

Please Log in or Create an account to join the conversation.

VO Question: dbServer FieldGET issue 1 week 21 hours ago #9250

  Jamal's Avatar Topic Author Jamal Offline Posts: 107
Hi Timothy & Chris,

The workarea and fieldname are correct based on what is displayed using:
IF wPos = 0
	InfoBox{,"Utility", "Invalid field: " + AsString(uField) + " in " + AsString(self:name) + _chr(10) + Psz2String(ProcName(2)) + _chr(10) + AsString(ProcLine(2))}:show()    
ELSE
	(wWorkArea)->VODBFieldGet( wPos, @uRetVal )
ENDIF 

The self:name (for the dbf name) and uField are displayed correctly via the InfoBox when wPos is zero.

Jamal

Please Log in or Create an account to join the conversation.

Last edit: by Jamal.

VO Question: dbServer FieldGET issue 1 week 17 hours ago #9251

  lumberjack's Avatar lumberjack Offline Posts: 457
Jamal,

Jamal wrote: Using VO 2.08 SP4b (2838), I have the following code which sometimes fails to find a field in the dbf file. Thus wPos returns 0 for the field name such as oSrv:FieldGet(#MYFIELD). Is IsSymbol() the problem or is it FieldPosSym() ?
Since this is random and I cannot replicate it, I am baffled.

METHOD FIELDGET(uField) CLASS _SpeciallDBServer
	LOCAL uRetVal as USUAL
	LOCAL wPos AS DWORD
	LOCAL dwCurrentWorkArea as DWORD    
	LOCAL oError as USUAL
	BEGIN SEQUENCE
		VODBSelect( wWorkArea, @dwCurrentWorkArea )      
                IF  IsSymbol( uField )
                       wPos := FieldPosSym( uField) 
		ELSEIF IsString( uField ) 
			wPos := FieldPos( AsString(uField) )
		ELSEIF IsNumeric( uField )
			wPos := uField
			IF wPos > wFieldCount
				wPos := 0
			ENDIF		
		ENDIF
		IF wPos = 0
			InfoBox{,"Utility", "Invalid field: " + AsString(uField) + " in " + AsString(self:name) + _chr(10) + Psz2String(ProcName(2)) + _chr(10) + AsString(ProcLine(2))}:show()    
		ELSE
			(wWorkArea)->VODBFieldGet( wPos, @uRetVal )
		ENDIF    
		__DBSSetSelect( dwCurrentWorkArea )  //SE-060527    
	END SEQUENCE
	RETURN uRetVal     

Is your _SpeciallDbServer class inheriting from DbServer? It just look strange why you would want to select a different workarea (wWorkArea and dwCurrentWorkArea) seeing that DbServer manages its workarea internally?
______________________
Johan Nel
George, South Africa

Please Log in or Create an account to join the conversation.

VO Question: dbServer FieldGET issue 1 week 17 hours ago #9252

  Jamal's Avatar Topic Author Jamal Offline Posts: 107
Johan,

I am just "improving" the dbServer and overriding the FIELDGET() which does the same thing; nothing strange about that. Please look at the VO RDD CLASS SDK, FIELDGET() method. Without the
VODBSelect( self:wWorkArea, @dwCurrentWorkArea )

the FIELDGET() will fail.

Jamal

Please Log in or Create an account to join the conversation.

VO Question: dbServer FieldGET issue 1 week 15 hours ago #9253

  Karl-Heinz's Avatar Karl-Heinz Offline Posts: 262
Hi Jamal,

when i switched from 2.5b3 to 2.8 i noticed several strange DBF access problems. The solution was to use DbSetRestoreWorkarea( TRUE ) - the default setting of this global setting is FALSE. As you see, within the __DBSSetSelect() func VODBSetSelect() is only called if __glRestoreWorkarea is set to TRUE.

FUNCTION __DBSSetSelect(dwNew AS DWORD) AS DWORD PASCAL
   //SE-060527
   IF __glRestoreWorkarea
      RETURN VODBSetSelect(LONGINT(dwNew))
   ENDIF
   RETURN dwNew

STATIC GLOBAL __glRestoreWorkarea := FALSE AS LOGIC //SE-060527

FUNCTION DbSetRestoreWorkarea(lEnable := NIL AS USUAL) AS LOGIC PASCAL
   //SE-060527
   LOCAL lOldValue AS LOGIC

   lOldValue := __glRestoreWorkarea

   IF IsLogic(lEnable)
      __glRestoreWorkarea := lEnable
   ENDIF

   RETURN lOldValue

DonĀ“t know if it helps in your case, but i would give it a try.

BTW. The DBsetRestoreWorkarea() func is documented in the Whatsnew28.rtf

regards
Karl-Heinz

Please Log in or Create an account to join the conversation.

VO Question: dbServer FieldGET issue 1 week 6 hours ago #9267

  Jamal's Avatar Topic Author Jamal Offline Posts: 107
Hi Karl,

Thanks! It is funny I was looking at DbSetRestoreWorkarea() function yesterday and its source in the X# master lib. However, I am not sure if this will help, since I am setting the workarea before accessing the DBF functions and __DBSSetSelect(..) is coming after. On error, I am going to dump the field list into a log file and see what what is returned.

Jamal

Please Log in or Create an account to join the conversation.

Last edit: by Jamal.

VO Question: dbServer FieldGET issue 1 week 6 hours ago #9268

  Jamal's Avatar Topic Author Jamal Offline Posts: 107
I modified the code to force an alias to be used via (self:wWorkArea)->
wPos := (self:wWorkArea)->FieldPos( AsString(uField)

Will wait to see if any clients have issues or if it solves it.

Jamal

Please Log in or Create an account to join the conversation.

Last edit: by Jamal. Reason: self:wWorkArea used
  • Page:
  • 1