sx_SetTranslate

<< Click to Display Table of Contents >>

Navigation:  Apollo API Listing >

sx_SetTranslate

VB Declaration

Declare Sub sx_SetTranslate Lib "Apollo9.dll"

(ByVal uiOnOff As Integer)

C Declaration

VOID FAR PASCAL sx_SetTranslate

(USHORT uiOnOff);

Description

Automatically translates record buffers stored in the OEM character set to Windows ANSI.

 

European tables make heavy use of the upper end of the character set (values 128 to 255) to display characters with diacritical marks. If the table was created with a DOS program, these characters are not the same as their ANSI counterparts. The result is so much gibberish being displayed on the Windows screen.

OEM tables will automatically be translated to ANSI if sx_SetTranslate is set to True. The table records and indexes will, however, be maintained in the OEM character set if sx_SetTranslate remains True. This makes it possible to use an OEM table created under DOS with both DOS and Windows programs simultaneously.

Parameters

uiOnOff: If True, the record buffer is translated from the OEM character set to ANSI after being read. If still True at run time, it is translated back again before writing.

As long as the setting is True, all key changes to indexes are translated to the OEM set before insertion. Search keys are also translated into OEM before the search is undertaken.

The setting applies to the current table only.

Permanent Translation

To physically translate an OEM table to ANSI (if it will no longer be used in a DOS environment), use sx_GetRecord and sx_PutRecord in a read loop and toggle sx_SetTranslate on and off (True before the read, and False before the write). Ensure that the setting is False before closing as well. See the examples below.

 

Special Case when using DESCEND()

If you need to support legacy DOS application and also use the xBase DESCEND() function in the index key, you need to take special care to manage the translate state. For example, when calling sx_Seek, sx_Index, or sx_IndexTag you should first call sx_SetTranslate (FALSE) and afterwards call sx_SetTranslate (TRUE).

VB Examples

' Translate entire table to ANSI

iPartsDbf = sx_Use("c:\vb\parts.dbf", "parts", READWRITE, SDEFOX)

' production cdx index is opened automatically

 

RecBuffer = String$(sx_RecSize() + 1, 0)

Do While Not sx_Eof()

sx_SetTranslate True

Call sx_GetRecord(ByVal RecBuffer)

sx_SetTranslate False

Call sx_PutRecord(ByVal RecBuffer)

sx_Skip 1

Loop

sx_Close

 

…or…

 

' Both dBase and Clipper UPPER() and LOWER() case conversion functions

' limit the characters eligible for case conversion. With UPPER(), only

' characters a-z are converted to upper case. With LOWER(), only

' characters A-Z are converted. Characters with diacritical marks ARE NOT

' CONVERTED when this switch is TRUE if sx_SetTranslate is also set to TRUE.

' To limit case conversion using this switch, set sx_SetTranslate to TRUE

' and set the sx_SysProp value on as well.

 

sx_SetTranslate( True )

lRetVal = sx_SysProp( SDE_SP_SETLIMITCASECONV, 1 )

 

C Examples

// Translate entire table to ANSI

iPartsDbf = sx_Use("c:\\vb\\parts.dbf", "parts", READWRITE, SDEFOX);

// production CDX index is opened automatically

cpRecBuffer = sx_MemAlloc((LONG) sx_RecSize() + 1);

while (!sx_Eof())

{

sx_SetTranslate(TRUE);

sx_GetRecord(cpRecBuffer);

sx_SetTranslate(FALSE);

sx_PutRecord(cpRecBuffer);

sx_Skip(1L);

}

sx_Close();

sx_MemDealloc(cpRecBuffer);

 

…or…

 

// Both dBase and Clipper UPPER() and LOWER() case conversion functions

// limit the characters eligible for case conversion. With UPPER(), only

// characters a-z are converted to upper case. With LOWER(), only

// characters A-Z are converted. Characters with diacritical marks ARE NOT

// CONVERTED when this switch is TRUE if sx_SetTranslate is also set to TRUE.

// To limit case conversion using this switch, set sx_SetTranslate to TRUE

// and set the sx_SysProp value on as well.

 

sx_SetTranslate( TRUE );

sx_SysProp( SDE_SP_SETLIMITCASECONV, (VOIDP)1 );