On 9/14/2012 11:47 AM, Chris Hird wrote:
... The _SET_NULL_MAP_FIELD() macro takes 3 parameters, first
the _RFILE ptr, then a type...
Chris, for update, you need the _SET_UPDATE_NULL_MAP_FIELD macro. The
one you mentioned works with the output null map.
I think those macros are meant to be used with a typedef created by
pragma mapinc with the nullflds option. The _type would be the typedef
name, and the _field would the field name. It looks like the macros only
support clearing the whole null map with _CLEAR_UPDATE_NULL_MAP, and
then setting individual fields to '1' with _SET_UPDATE_NULL_MAP_FIELD.
Here's a test program I found in my library that updates file
BMORRIS/JUNKF. It looks like the field names in my junk file were all
10A, and the first and third were defined ALWNULL. The program is
blindly updating all the fields, and setting the third field NULL3 to be
null.
main()
{
#pragma mapinc("nulls", "BMORRIS/JUNKF(REC)","nullflds")
#pragma mapinc("data", "BMORRIS/JUNKF(REC)","both")
#include "nulls"
#include "data"
BMORRIS_JUNKF_REC_both_t data;
_RFILE *rf;
rf = _Ropen("BMORRIS/JUNKF", "rr+ nullcap=Y");
_Rreadn (rf, &data, sizeof(data), __DFT);
_CLEAR_UPDATE_NULL_MAP(rf, BMORRIS_JUNKF_REC_nmap_t);
memcpy(&data, "null1 notnull2 null3 notnull4 ", 40);
_SET_UPDATE_NULL_MAP_FIELD(rf, BMORRIS_JUNKF_REC_nmap_t, NULL3);
_Rupdate (rf, &data, sizeof(data));
_Rclose (rf);
}
As an Amazon Associate we earn from qualifying purchases.