1237 int i, j, nRetResult =
TRUE;
1238 unsigned char *pabyRec;
1239 char szSField[400], szFormat[20];
1244 if (hEntity < 0 || hEntity > psDBF->nRecords)
1247 if (psDBF->bNoHeader)
1253 if (hEntity == psDBF->nRecords)
1259 for (i = 0; i < psDBF->nRecordLength; i++)
1260 psDBF->pszCurrentRecord[i] =
' ';
1262 psDBF->nCurrentRecord = hEntity;
1272 pabyRec = (
unsigned char *)psDBF->pszCurrentRecord;
1274 psDBF->bCurrentRecordModified =
TRUE;
1275 psDBF->bUpdated =
TRUE;
1284 memset((
char *)(pabyRec + psDBF->panFieldOffset[iField]),
1286 psDBF->panFieldSize[iField]);
1293 switch (psDBF->pachFieldType[iField])
1298 if (psDBF->panFieldDecimals[iField] == 0)
1300 int nWidth = psDBF->panFieldSize[iField];
1302 if ((
int)
sizeof(szSField) - 2 < nWidth)
1303 nWidth =
sizeof(szSField) - 2;
1305 sprintf(szFormat,
"%%%dd", nWidth);
1306 sprintf(szSField, szFormat, (
int)*((
double *)pValue));
1307 if ((
int)strlen(szSField) > psDBF->panFieldSize[iField])
1309 szSField[psDBF->panFieldSize[iField]] =
'\0';
1313 (
char *)(pabyRec + psDBF->panFieldOffset[iField]), szSField, psDBF->panFieldSize[iField]);
1317 int nWidth = psDBF->panFieldSize[iField];
1319 if ((
int)
sizeof(szSField) - 2 < nWidth)
1320 nWidth =
sizeof(szSField) - 2;
1322 sprintf(szFormat,
"%%%d.%df", nWidth, psDBF->panFieldDecimals[iField]);
1323 sprintf(szSField, szFormat, *((
double *)pValue));
1324 if ((
int)strlen(szSField) > psDBF->panFieldSize[iField])
1326 szSField[psDBF->panFieldSize[iField]] =
'\0';
1330 (
char *)(pabyRec + psDBF->panFieldOffset[iField]), szSField, psDBF->panFieldSize[iField]);
1335 if (psDBF->panFieldSize[iField] >= 1 && (*(
char *)pValue ==
'F' || *(
char *)pValue ==
'T'))
1336 *(pabyRec + psDBF->panFieldOffset[iField]) = *(
char *)pValue;
1340 if ((
int)strlen((
char *)pValue) > psDBF->panFieldSize[iField])
1342 j = psDBF->panFieldSize[iField];
1347 memset(pabyRec + psDBF->panFieldOffset[iField],
' ', psDBF->panFieldSize[iField]);
1348 j = strlen((
char *)pValue);
1350 memcpy((
char *)(pabyRec + psDBF->panFieldOffset[iField]), (
char *)pValue, j);
static int DBFLoadRecord(DBFHandle psDBF, int iRecord)
if(!DBFLoadRecord(psDBF, hEntity)) return NULL
static void DBFWriteHeader(DBFHandle psDBF)
static char DBFGetNullCharacter(char chType)
static int DBFFlushRecord(DBFHandle psDBF)