TBApiConvertHexString API Call

 

Description

It is often necessary for an application to send commands to a controller via UPDD. Typically a hex value will be involved. This routine converts a hex string in ASCII format to its hexadecimal equivalent.

Parameters

Hex string and length. The resultant value is stored in the supplied buffer.

Returns

0 = fail, 1 = OK.

Notes

This routine only exists in TBapi.DLL (i.e. not UPDD itself) and is supplied for convenience only.

 

Visual C++ Declaration/example

 

BOOL TBApiConvertHexString(char *s, int iLength);

 

char      buf[10];

 

strcpy(buf, “1AF8”);

If (!TBApiConvertHexString( buf, strlen(buf)) )

AfxMessageBox( “Bad Hex data”);

else

            TBApiSendData(m_iDeviceId, buf, strlen(buf) / 2, 50 );

 

Visual Basic Declaration/example

 

Public Declare Function TBApiConvertHexString Lib "TBapi" Alias “_DLL_TBApiConvertHexString@8" (ByVal ptrData As String, ByVal aLength As Long) As Boolean

 

Dim result As Boolean

Dim aString As String

 

aString = “1AF8”

Result = TBApiConvertHexString(aString, Len(aString))

If result = false then

MsgBox “Bad hex data”

else

            TBApiSendData(DeviceId, aString, Len(aString) \ 2, 50 )    ‘ note: integer division

End If