‘The following syntax sets up file specifications.
‘Key 1, by contact number.
giStatus = BTRCALL(
BCREATE, OrdPosBlock, FileDefinitionBuffer, BufLen, _
function CreateCustomerFile(FileName: String): SmallInt;
{The following syntax defines file specifications.}
{Define key specifications, Key 0 by contact number}
{Key 3 by sales representative, by next contact date.}
keyNum); //0 (zero) means Overwrite any existing file
end; {CreateCustomerFile}
BTI_SINT CreateCustomerFile(LPCTSTR szCustomerFileName)
{The following are the Order table variables.}
end; //CustomerRecordType
You can insert a row by calling BINSERT with the row to be inserted in the data buffer. For specific information about this API, refer to the Btrieve API Guide. The following sample code and sample structures illustrate how to perform the Insert operation in Visual Basic, Delphi, and C/C++.
giStatus = BTRCALL(
BINSERT, CustPosBlock, CustRecBuf, _
function InsertCustomerRecord(
var CustPosBlock :
TPositionBlock;
{Calculate the total size of variable-length record}
end; {InsertCustomerRecord}
BTI_SINT InsertCustomerRecord(char CustPosBlock[POS_BLOCK_SIZE],
‘The following are Customer table data structures.
end;
//CustomerRecordType
For more detailed information about this API, refer to the Btrieve API Guide. The following sample code and sample structures illustrate how to perform the Update operation in Visual Basic, Delphi, and C/C++.
‘The following syntax updates a customer record.
giStatus = BTRCALL(
bUpdate, CustPosBlock, CustRecBuf, _
function UpdateCustomerRecord(
var CustPosBlock:
TPositionBlock;
end; {UpdateCustomerRecord}
BTI_SINT UpdateCustomerRecord(char CustPosBlock[POS_BLOCK_SIZE],
end;
//CustomerRecordType
{ Get First physical record from file : }
{Get Second record in file: (no guaranteed order) }
{ Back to the First record : }
end;
//CustomerRecordType
‘The following syntax writes the contact list box string.
'write contact listbox string
‘The following syntax returns the record position.
‘The following syntax configures the pointers to the array of the record ‘positions.
‘The following syntax retrieves the direct record by the Record Position.
‘The following syntax places the address in the data buffer.
‘The following syntax returns the next customer record.
giStatus = BTRCALL(
BGETNEXT, CustPosBlock, CustRecBuf, _
giStatus = BTRCALL(
BGETPOS, CustPosBlock, RecPosition, _
{The following syntax returns the first record from the file using the specified} {sort order.}
CustRec, //Buffer for record to be returned in
{The following syntax returns the second record in a file in the specified sort} {order.}
end;
//CustomerRecordType
lChunkLength
= MaxChunkSize
iNumChunksRead
= iNumChunksRead + 1
ChunkGetBuffer.RecordAddress = GrphPosition
'H40000000 (Next in record bias) causes use of intrarecord currency.
ChunkGetBuffer.AddressMode
= ToType4((&H80000000 + &H40000000))
ChunkGetBuffer.NumberOfChunks = ToType4(lNumberOfChunks)
ChunkGetBuffer.ChunkOffset
= ToType4(lChunkOffset)
ChunkGetBuffer.ChunkAddress
= ToType4(lChunkAddress)
ChunkGetBuffer.ChunkLength
= ToType4(lChunkLength)
‘The previous syntax uses the read buffer. Subsequent get chunks use the entire
CopyMemory ChunkReadBuffer, ChunkGetBuffer, Len (ChunkGetBuffer)
If giStatus = 0 Then
'you should get a 103 if you read past the end of the
If MaxChunkSize <> BufLen Then
sLine = Left(ChunkReadBuffer.ChunkArray, BufLen)
lBytesread = lBytesread + (BufLen)
sLine = ChunkReadBuffer.ChunkArray
Bytesread = lBytesread + MaxChunkSize
Loop While (giStatus = 0)
Set Image1.Picture = LoadPicture(txtOutputImage.Text)
FormCustomerGraphic.MousePointer = 0
NumChunks.Text = iNumChunksRead
NumBytes.Text = lBytesread
LastStatus.Text = giStatus
MsgBox Err.Number & ": " & Err.Description & vbCrLf & "Load from disk and save", vbOKOnly, "Invalid Picture in Graphic file"
MsgBox Err.Number & ": " & Err.Description, vbOKOnly, "Graphic Load Error"
FormCustomerGraphic.MousePointer = 0
MsgBox "Directory for temporary imaging work does not exist. " & vbCrLf & _
Screen.MousePointer = vbDefault
Dim iKeyBufLen As Integer
BufLen = Len(ChunkReadBuffer)
sKeyBuffer = Space$(KEY_BUF_LEN)
giStatus =
BTRCALL(
BGETDIRECT, GrphPosBlock, ChunkReadBuffer, _ BufLen, ByVal
sKeyBuffer, iKeyBufLen, -2)
ContactNumber As typ_byte4
CurrentKeyNumberAs Integer
ContactNumber As typ_byte4
ChunkArray As String * MaxChunkSize
RecordAddressAs typ_byte4
NumberOfChunks As typ_byte4
ChunkAddress As typ_byte4
' Graphic Table Variables
‘The following syntax creates the customer file and configures the file
CustFixedRecSize = Len(CustRecBuf) - Len(CustRecBuf.Notes)
FileDefinitionBuffer.RecLen = CustFixedRecSize
FileDefinitionBuffer.PageSize = 4096
FileDefinitionBuffer.IndxCnt = 4
FileDefinitionBuffer.FileFlags = VARIABLELENGTH
FileDefinitionBuffer.KeyBuf0.KeyPos = 1
FileDefinitionBuffer.KeyBuf0.KeyLen = 4
FileDefinitionBuffer.KeyBuf0.KeyFlags = EXTTYPE + MODIFIABLE
FileDefinitionBuffer.KeyBuf0.KeyType = Chr$(BAUTOINC)
FileDefinitionBuffer.KeyBuf1.KeyPos = 5
FileDefinitionBuffer.KeyBuf1.KeyLen = 30
FileDefinitionBuffer.KeyBuf1.KeyFlags = EXTTYPE + MODIFIABLE + DUP
FileDefinitionBuffer.KeyBuf1.KeyType = Chr$(BSTRING)
FileDefinitionBuffer.KeyBuf2.KeyPos = 35
FileDefinitionBuffer.KeyBuf2.KeyLen = 60
FileDefinitionBuffer.KeyBuf2.KeyFlags = EXTTYPE + MODIFIABLE + DUP
FileDefinitionBuffer.KeyBuf2.KeyType = Chr$(BSTRING)
‘Key 3, by sales representative, by next contact date.
‘
This is a segmented key:
FileDefinitionBuffer.KeyBuf3.KeyPos = 220
FileDefinitionBuffer.KeyBuf3.KeyLen = 3
FileDefinitionBuffer.KeyBuf3.KeyFlags = EXTTYPE + _ MODIFIABLE + DUP + SEGMENT
FileDefinitionBuffer.KeyBuf3.KeyType = Chr$(BSTRING)
FileDefinitionBuffer.KeyBuf4.KeyPos = 223
FileDefinitionBuffer.KeyBuf4.KeyLen = 4
FileDefinitionBuffer.KeyBuf4.KeyFlags = EXTTYPE + MODIFIABLE + DUP
FileDefinitionBuffer.KeyBuf4.KeyType = Chr$(BDATE)
BufLen = Len(FileDefinitionBuffer)
CustFileLocation = CustFileLocation & " "
KeyBufLen = Len(CustFileLocation)
giStatus =
BTRCALL(
BCREATE, CustPosBlock, FileDefinitionBuffer, _
BufLen, ByVal CustFileLocation, KeyBufLen, 0)