<< Click to Display Table of Contents >> Navigation: Apollo API Listing > sx_AppendBlankEx |
Declare Function sx_AppendBlankEx Lib "Apollo9.dll" As Integer
SHORT FAR PASCAL sx_AppendBlankEx (VOID);
Appends a new blank record to the current database. This procedure or sx_Append must be called whenever a new record is to be added to the database. A blank record added via sx_AppendBlankEx is automatically locked.
The standard sx_Append and sx_AppendBlank procedures do not return a value to the applications programmer. In fact, if a lock contention occurs with the non-extended procedures, the user must wait for the lock to be released before the record is appended. This extended function will return an error code if ANY error is encountered, so that the application programmer may deal with it.
-1 |
Record successfully appended |
1 |
Table lock failure (record not written) |
2 |
File seek error (record not written) |
3 |
File write error (record not written) |
4 |
Key insertion failure (record written/index corrupted) |
5 |
Table is read only (record not written) |
6 |
Current work area invalid (record not written) |
VB Example
Dim iRet As Integer
' if adding, append a blank
If EditMode = 2 Then
iRet = sx_AppendBlankEx
If iRet = 1 Then MsgBox "Table lock failure!"
If iRet = 2 Then MsgBox "File seek error"
If iRet = 3 Then MsgBox "File write error"
If iRet = 4 Then MsgBox "Key insertion failure"
If iRet = 5 Then MsgBox "Table is read only"
If iRet = 6 Then MsgBox "Current work area invalid"
If iRet > -1 Then Exit Sub
End If
If sx_Rlock(sx_RecNo()) Then
sx_Replace "customer", R_CHAR, ByVal RTrim$((tCust.Text))
sx_Replace "last", R_CHAR, ByVal RTrim$((tLast.Text))
sx_Replace "notes", R_MEMO, ByVal RTrim$((tMemo.Text))
sx_Commit
sx_Unlock sx_RecNo()
End If
C Example
void CNamesForm::OnButtonAdd()
{
SHORT iRet;
// re-enable database linkage
m_date->SetNumProperty("Unlink", FALSE);
// set switch on, append blank, and then edit
bAddMode = TRUE;
iRet = sx_AppendBlank(); // leaves rec locked
switch( iRet )
{
case -1:
AfxMessageBox((LPCSTR) "Success!");
OnButtonEdit();
break;
case 1:
AfxMessageBox((LPCSTR) "Table lock failure!" );
break;
case 2:
AfxMessageBox((LPCSTR) "File seek error" );
break;
case 3:
AfxMessageBox((LPCSTR) "File write error" );
break;
case 4:
AfxMessageBox((LPCSTR) "Key insertion failure" );
break;
case 5:
AfxMessageBox((LPCSTR) "Table is read only" );
break; case 6:
AfxMessageBox((LPCSTR) "Current work area invalid" );
}
}
sx_AppendBlank, sx_Append, sx_AppendEx, sx_Commit, sx_PutRecord, sx_Replace