Page 1 of 1

Record objects

Posted: Thu Dec 03, 2015 12:23 am
by bwolfsohn
Roger,

I'm doing some work with record object...

after doing
dc_dbrecord():new()
dbgoto(0)
dc_dbscatter()

there are some fields that have a valtype "U"

shouldn't all fields have the proper datatype from the database ?

I'm using an older version of dc_dbscatter() since we had some trouble with the dc_db* functions back in september.

Code: Select all

*********************
function dc_dbscatter( oRecord )
*********************
LOCAL i, aStruct, xData

aStruct := dbStruct()

FOR i := 1 TO Len(aStruct)
  xData := FieldGet(i)
  IF IsMemberVar(oRecord,aStruct[i,1])
    oRecord:&(aStruct[i,1]) := xData
	else
		//dcbdebug i,aStruct[i,1]
	endif
NEXT

RETURN oRecord
but, even the 261 version

Code: Select all

FUNCTION DC_DbScatter( oRecord, cRecNoFieldName, cDeletedFieldName )

LOCAL i, aStruct, xData, cFieldName

DEFAULT cRecNoFieldName := 'RECORD_NUMBER', ;
        cDeletedFieldName := 'RECORD_DELETED'

aStruct := dbStruct()

FOR i := 1 TO Len(aStruct)
  cFieldName := aStruct[i,1]
  xData := FieldGet(i)
  IF IsMemberVar(oRecord,cFieldName)
    xData := FieldGet(i)
    oRecord:&(aStruct[i,1]) := xData
  ENDIF
NEXT

IF IsMemberVar(oRecord,'RECORD_NUMBER')
  oRecord:record_number := RecNo()
ENDIF

IF IsMemberVar(oRecord,'RECORD_DELETED')
  oRecord:record_deleted := Deleted()
ENDIF

RETURN oRecord
seems like it's leaving "U"'s for some fields..

I'm enclosing the file that this applies to.. i did not enclose the index

as usual, i'm sure i'm missing something..

Re: Record objects

Posted: Thu Dec 03, 2015 3:45 am
by Tom
DC_DbRecordClassName() is a get-set-function that creates a class name with the first call of DC_DbScatter(). If the database changes, you may call this function with another name, like
DC_DbRecordClassName({||'DB_MyNextTable'}) or the alias or table name. This will prevent DC_DbScatter() from using the same structure as with the table before.

Re: Record objects

Posted: Thu Dec 03, 2015 6:51 am
by rdonnay
I'm using an older version of dc_dbscatter() since we had some trouble with the dc_db* functions back in september.
I want to work with you on this.
Apparently, the new methods added to the class are causing problems for you.
Is this because you are transferring record objects via Xb2.Net?
There is probably an issue with Var2Bin() and Bin2Var() due to these methods.
You need to have the same version of eXpress++ and Xbase++ on both the send and receive sides.
DC_DbRecordClassName()
Tom may be on the right track here but you haven't given enough info.
I need source code and your database.

Re: Record objects

Posted: Thu Dec 03, 2015 7:37 am
by bwolfsohn
the original problem had to do w/ xb2net.

this problem is strictly desktop, has nothing to do with bin2var/var2bin.

It's just a simple record object, but i was presuming that all fields after dc_dbscatter() would be properly defined

i gave you the database. it's in the zip...

when i open that, and then use:

dc_dbrecord():new()
dbgoto(0)
dc_dbscatter()

I end up with "U" valtypes.

Re: Record objects

Posted: Thu Dec 03, 2015 8:46 am
by rdonnay
I don't see a problem with the record object.

Al the fields have a proper value. Only __NoIvar is a U and all methods.

Re: Record objects

Posted: Thu Dec 03, 2015 8:50 am
by bwolfsohn
ok... let's go over it on teamviewer in a few minutes..

Re: Record objects

Posted: Thu Dec 03, 2015 12:05 pm
by bwolfsohn
ooooooook... problems solved... stupid programmer tricks 101...

lessons learned:

1. ALWAYS alias your dc_db* routines.

2. a second set of eyes will find a problem in short order that you've been searching for for hours..

Re: Record objects

Posted: Thu Dec 03, 2015 12:10 pm
by Cliff Wiernik
Those 2nd set of eyes should always be available for low cost purchases. I have experienced the same many times.

Sometimes some dreaming inbetween also helps.

Cliff

Re: Record objects

Posted: Thu Dec 03, 2015 12:58 pm
by bwolfsohn
cliff, take a look at the scrolling dialog roger did... it's a big improvement...

still a ways to go though...

Re: Record objects

Posted: Thu Dec 03, 2015 3:33 pm
by Cliff Wiernik
Was planning. Just been tied up.