Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sys(2017) isn't including calculated fields in the checksum!?

Status
Not open for further replies.

Chris Miller

Programmer
Oct 28, 2020
4,815
DE
This shows the checksum doesn't care for calculated fields (in this case 'fieldsum')

Code:
Create Cursor test (field1 C(1), field2 c(1))
Insert Into test Values ('a','b')
Set Fields Global
Set Fields To
? Set("Fields",1)
? Sys(2017,'',0,1)
Set Fields To field1
? Set("Fields",1)
? Sys(2017,'',0,1)
Set Fields to fieldsum = field1+field2
? Set("Fields",1)
? Sys(2017,'',0,1)
Set Fields To field2
? Set("Fields",1)
? Sys(2017,'',0,1)

The checksum shuold differ when the calculated field is added, but it stays the same. Adding field2 proves the SET FIELD setting has an effect, but it look as if calculated fields are disregarded.

VFP help said:
If you specified a setting for SET FIELDS, the checksum is calculated based on the current list specified by SET FIELDS [highlight #FCE94F]which could include calculated fields[/highlight][highlight #FCE94F][/highlight].

Calculated fields are temporary fields that exist in the current cursor based on an expression but are not defined in the actual table structure. For example, the field LOCATION is a calculated field:

Code:
Use Customer
SET FIELDS TO LOCATION = ALLTRIM(city) + ',' + state

And they forget to tell that calculated fields need SET FIELDS GLOBAL, but even this doesn't help. I tried many variations, also with Flags set to 3, but either I do something completely wrong or the documentation makes a promise Sys(2017) doesn't keep. Can anybody teach me how this works or confirm it's a bug?

Chriss
 
Should I explain the problem a bit more?

An obvious solution would be to simply put together a cursor with what I'd like SYS(2017) to see instead of using SET FIELDS or even put aside CRC32 calculations and feed the data into HMAC or other much more appropriate hash functions.

But the notice from Tod McKenna in gives me hope that it's actually possible and not a bug of the documentation and for what I want to test a simple fast checksum is sufficient.

Chriss
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top