TBApiEnumStringTokens API Call

 

Description

This is a help function to enabling splitting a token into individual tokens. Although it is not directly relevant to the driver API it is useful in the manipulation of such strings which are used by some parts of the API.

A callback function is used - see TBCalib source code for examples of the actual use of this function.

Parameters

Address of callback routine. Storage for returned tokens. Full string and token Separator, e.g. “;

Returns

None.

Notes

None

 

Visual C++ Declaration/example

 

An example can be found in ToolbarCalibrate.cpp which forms part of TBCalib source code:

 

void TBAPI TBApiEnumStringTokens(STRING_TOKENS_CALLBACK aCb, void* aContext, const TCHAR* aString, const TCHAR* aDelimiter);

 

TBApiGetToolbarNames(theCurrentDevice,tbNames,sizeof(tbNames));

CArray<String, const String&> tbNameArray;

TBApiEnumStringTokens(_SplitString, &tbNameArray,tbNames, _T(";"));

void _SplitString(void* aContext, const TCHAR* token)

{

   CArray<String, const String&>* array = (CArray<String, const String&>*) aContext;

            array->Add(token);

}

 

Visual Basic Declaration/example

 

Public Declare Sub TBApiEnumStringTokens Lib "TBapi" Alias “_DLL_TBApiEnumStringTokens@16" _

(ByVal aCB As Long, ByVal aContext As Long, ByVal aString As String, ByVal aDelimiter As String)

 

' Pass a VB string for splitting…

TBApiEnumStringTokens AddressOf CB, 0, "Hello;world,;whatever", ";"

 

' with the callback routine defined as:-

Public Sub CB(ByVal iContext As Long, ByVal token As Long)

    Dim s As String

    s = PtrToVBString(token)        ' see helper declarations in Tbapi.bas

    MsgBox s

End Sub