sx_FieldType

<< Click to Display Table of Contents >>

Navigation:  Apollo API Listing >

sx_FieldType

VB Declaration

Declare Function sx_FieldType Lib "Apollo9.dll"

(ByVal cpFieldName As String)

As String

C Declaration

LONG FAR PASCAL sx_FieldType

(BYTEP cpFieldName);

Description

Reports the type of the named field.

Parameters

cpFieldName: The name of the field.

Return Value

The field type is returned as a string.

Standard DBF types are C (character), I (Long Integer), N (numeric), M (memo), D (date), and L (logical). Extended types are P (picture) and B (blob), and V (VariField ™). The extended types P and B are variations of a memo field and are used for reporting purposes only. They are not valid types for use by sx_CreateField.

VB Example

Sub Form_Load ()

Static FieldTabs(3) As Integer

Dim i As Integer

 

' Fill list box List1 with field info

FieldTabs(1) = 48

FieldTabs(2) = 65

FieldTabs(3) = 84

k& = SendDlgItemMessage(sxdbinfo.hWnd, GetDlgCtrlID(List1.hWnd),

Ä (LB_SETTABSTOPS, 3, FieldTabs(1))

For i = 1 To sx_FieldCount()

ListName$ = sx_FieldName(i)

ListStr$ = ListName$ + Chr(9) + sx_FieldType(ListName$) +

Ä (Chr(9) + Format$(sx_FieldWidth(ListName$), "000") +

Ä (Chr(9) + Format$(sx_FieldDecimals(ListName$),"00")

List1.AddItem ListStr$, (i - 1)

Next i

End Sub

C Example

// fill list box with field data

uiFieldCount = sx_FieldCount();

for (i = 0; i < (SHORT) uiFieldCount; i++)

{

lstrcpy((LPSTR) caFieldName, (LPSTR) sx_FieldName(i + 1));

lstrcpy( (LPSTR) caFieldType,

(LPSTR) sx_FieldType(caFieldName));

itoa(sx_FieldWidth(caFieldName), caFieldLen, 10);

itoa(sx_FieldDecimals(caFieldName), caFieldDec, 10);

 

// non-memos only

if (caFieldType[0] == 'M' || caFieldType[0] == 'P')

continue;

_fmemset(caString, 0, (size_t) sizeof(caString));

lstrcpy(caString, caFieldName);

caString[lstrlen(caString)] = '\t';

lstrcat(caString, caFieldType);

caString[lstrlen(caString)] = '\t';

lstrcat(caString, caFieldLen);

caString[lstrlen(caString)] = '\t';

lstrcat(caString, caFieldDec);

SendDlgItemMessage(hdlg, ID_L1,  

LB_ADDSTRING, NULL, (LPSTR) caString);

}

See Also

sx_CreateField, sx_FieldCount, sx_FieldDecimals, sx_FieldName, sx_FieldOffset, sx_FieldWidth