sx_FieldWidth

<< Click to Display Table of Contents >>

Navigation:  Apollo API Listing >

sx_FieldWidth

VB Declaration

Declare Function sx_FieldWidth Lib "Apollo9.dll"

(ByVal cpFieldName As String)

As Integer

C Declaration

USHORT FAR PASCAL sx_FieldWidth

(BYTEP cpFieldName);

Description

Extracts the width of the named field.

Parameters

cpFieldName: The name of the field.

Return Value

The size in bytes of the named field.

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();

 

// set list box items

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')

 {

_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_FieldCount, sx_FieldDecimals, sx_FieldName, sx_FieldNum, sx_FieldOffset, sx_FieldType