Frequently Asked Questions

<< Click to Display Table of Contents >>

Navigation:  Apollo API (Apollo Engine) >

Frequently Asked Questions

This section contains some of the most commonly asked questions. You should look here before contacting technical support to see if your question has been addressed here already.

Q: What files do I need to distribute with my applications?

See: Deployment

Q: How do I create a new table in code?

Use sx_CreateNew, sx_CreateField, and sx_CreateExec functions.

VB Example:

If Not sx_CreateNew( "c:\apollo\9.9\data\testnew.dbf", SDEFOX, 5 ) Then

MsgBox "Create failed"  

Exit Sub

End If

sx_CreateField( "NAME", "C", 25, 0 ) ' CHARACTER

sx_CreateField( "WAGE", "N", 6, 2 ) ' NUMERIC, w/DEC value

sx_CreateField( "TAXED", "L", 1, 0 ) ' LOGICAL

sx_CreateField( "HIRED", "D", 8, 0 ) ' DATE

sx_CreateField( "NoteS", "M", 10, 0 ) ' MEMO/NoteS

If sx_CreateExec Then

 MsgBox "Create succeeded"  

Else

 MsgBox "Create failed"  

End If

 

C Example:

sx_CreateNew((BYTEP) "names.dbf", (BYTEP) "name", SDENTX, 5);

sx_CreateField((BYTEP) "name", (BYTEP) "C", 30, 0);

sx_CreateField((BYTEP) "address", (BYTEP) "C", 30, 0);

sx_CreateField((BYTEP) "phone", (BYTEP) "C", 10, 0);

sx_CreateField((BYTEP) "business", (BYTEP) "C", 20, 0);

sx_CreateField((BYTEP) "createdate", (BYTEP) "D", 8, 0);

sx_CreateExec();

 

New records are added with sx_Append or sx_AppendBlank and field values are stored with sx_Replace. New indexes are created with the sx_Index and/or sx_IndexTagfunctions.

Q: Can I use Xbase commands and functions in my code?

Not directly. Xbase commands and functions, such as INDEX ON, PACK, UPPER(), DTOS(), and so forth, can only be used from sx_Index, sx_IndexTag, sx_Query, sx_QueryTest, and sx_Eval* functions (such as sx_EvalString).

For example, the following is valid Xbase code:

INDEX ON DTOS(HIREDATE) TO HIRED UNIQUE DESCENDING FOR !DELETED()

 

sVal = UPPER(LASTNAME+FIRSTNAME)

This code is not valid inside Visaul Basic, C or Delphi. However, you can use Xbase-like syntax via the sx_Evalxxx functions as follows:

 

VB Example:

sx_Index( "HIRED", "DTOS(HIREDATE)", IDX_UNIQUE, True, "!DELETED()" )

 

sVal = sx_EvalString( "UPPER(LASTNAME+FIRSTNAME)" )

 

C Example:

sx_Index( "HIRED", "DTOS(HIREDATE)", IDX_UNIQUE, True, "!DELETED()" );

lstrcpy( (LPSTR) sVal, (LPSTR) sx_EvalString( "UPPER(LASTNAME+FIRSTNAME)" ));

 

See Also: xBase Functions Supported

Q: How do I search for a key in an index that was created on two fields?

You need to construct the sx_Seek expression so that it is equal to the exact key value that was stored in the index file, except for any trailing spaces. Say for example that your index expression was:

 

"UPPER(LAST+FIRST )"

where LAST and FIRST are both 20 characters wide. That means the data in the index actuall looks like this:

 

"SMITH JOHN"

So, if you wanted to call sx_Seek for 'John Smith', your sx_Seek value would have to reflect the stored format. In this example, the last name value ("SMITH") has to be upper-cased and must be padded with 20 spaces spaces t reflect the field width before appending the first name value ("JOHN").

Here is a simple function that you can use in your application to pad search strings to the desired length.

VB Syntax:

Function Pad (ByVal cTmp As String, ByVal nLen As Integer) As String

Pad = Mid$( cTmp & Space$(nLength), 1, nLen )

End Function

Visual Basic's UCase$ function can be used to convert the search values to upper case before passing it to the sx_Seek function. Alternatively, you can force the user's input to upper case.

Below is a VB sample call to sx_Seek using the Pad() function above. This assumes that the user had input the FIRST name value in one edit box (Edit1) and the LAST name value in a second edit box (Edit2). The variable sSeekVal in this example was declared as a String type.

 

' Concatenate the two search values, padding as required

sSeekVal = Pad( Edit2.Text, 20 ) + Edit1.Text

 

' Upper case search string, if not handled in TEdit masks

sSeekVal = UCase$( sSeekVal )

 

' Issue the sx_Seek call

If sx_Seek( sSeekVal ) Then

MsgBox "Found!"  

Else

MsgBox "Not found!"  

End If

 

Q: How do I convert existing Access data to formats that Apollo can use?

The easiest way is to export the existing table to a FoxPro file. This would be immidiately usable by Apollo FoxPro driver (SDEFOX). If no MEMO fields exist in the table, this same file could also be used with the Clipper and HiPer-SIx drivers.

Q: Does Apollo support FoxPro 'G' (General) Fields?

Apollo provides limited support for FoxPro type 'G' (General) fields. FoxPro General fields contain references to OLE linked or embedded objects that reside in a standard .FPT memo file. Apollo supports their creation with sx_CreateField, and an Apollo application will work if a 'G' field is present in the table, however, neither saving nor loading OLE objects from 'G' fields is supported. Basically, Apollo will recognize the ‘G’ field type so tables may be opened.