Chapter 6

Compatibility and Conformance Discussions

Disclaimer:

This is a summary and overview of X2c 'the portable Xbase compiler' version 1.15.

This is not intended to be a specification level document and is neither all inclusive or guaranteed as a product specification. It is subject to change without notice.

In other words, it is our attempt to effectively tell you what X2c has - not a guarantee. In particular the lists of functions are constantly being enhanced (so if you see a missing function, ask).

General X2c Philosophy

X2c is a Xbase language processor. It provides language features as needed by users, many of whom have existing programs written with other Xbase dialects. This requires X2c to process statements and functions of many of the other Xbase dialects.

X2c is compatible with dBASE III Plus (version 1.1), Clipper (summer 87) and Foxbase (2.1). This means that the majority of the features of these products are provided in as close to the same fashion as in the alternate product as possible.

It is not possible to guarantee the exact same functionality because the definition of each feature in each alternate product can only be based on the published documentation for that product, supplemented with generally available publications, bulletin boards discussions and much testing.

Many features and characteristics are not explicitly covered in the standard product documentation and so can only be implemented in the same fashion to the degree that extensive testing has defined the precise operations.

Summary of languages differences between C and Xbase languages in general.

Each section indicates the impact of these differences on the X2c Xbase dialects.

Variables:

ANY-type variables

X2c provides a complex data object that operates according to Xbase variable rules. Specifics of these characteristics is enumerated in subsequent sections.

Static vs Dynamic name scoping:

In Xbase: variables are created 'on the fly' and they exist for a period of time during program execution. PUBLIC and PRIVATE declarations only effect when the variables are removed.

In C: variables are declared in the compiled code and exist for all functions for all time (global), or only within a single function (local).

In X2c: Global variable 'hooks' contain references to the current instance of the Xbase variable. C 'access' functions are used to access all variables so Xbase field, PUBLIC, PRIVATE and PARAMETERS characteristics perform as expected.

Run-time naming and Macros:

Xbase keeps the names of variables at run-time, C does not. In C, once the compiler is done, all variables are referenced only by numeric address. In Xbase, a macro reference to a variable (&X=1) works because of the run-time names.

In X2c: names can be kept for all variables and functions and so full Xbase macros can be executed. Functions are called using a standard calling convention so the expression evaluator can call any user functions.

Dynamic data typing

All variables in Xbase change to the data type of the value they are assigned.

In C, the type of a variable can not change. The only way for the same variable name to have different types is to be in different name scopes of a program, ie, PUBLIC and PRIVATE. Simple arrays can only be of one type. Expressions must be of explicit types.

In X2c: the type of a variable or array element is set when the variable occurs on the left hand side of an assignment. This follows full Xbase rules. Expressions of known type are compiled to that type. Expressions of unknown type are compiled using special function calls operating on ANY-type variable objects.

X2c optimizes numeric expressions in a way that causes the following to require recoding: (date_variable)+/-(numeric_constant). The function DAYADJ(date_variable, [-]numeric_constant) needs to be used.

Parameter passing to PROCEDUREs and FUNCTIONs.

Xbase passes a parameter to a PROCEDURE, (DO..WITH...) by name. If the parameter is changed in the procedure, the new value gets passed back. Scalar parameters to FUNCTIONs are passed by values, arrays are passed by reference and the Clipper '@' operator allows passing scalar parameters by reference.

In C, numeric and logical parameters are passed by value and character, date and array parameters by address. This means only character and array parameters have changes returned to the upper level. Character constants can be changed by lower level operations.

X2c follows Xbase, in all aspects, including the Clipper '@' operator.

Name conflicts

C globals names include function names, global database structures, and PUBLIC variable names. No two can have the same name, (case sensitivitity depending on the linker). Global database structures often are named by the database root name. The database root name is the center part of the filename: in file C:\DATA\BASEPART.DBF the root name is BASEPART.

X2c uses C names that are the same as the corresponding Xbase name, forced to lower case, for all functions and procedures. PUBLIC variables are uniquely named with a preceding 'V'.

The standard X2c file manager does not use database structures and so produces no conflicts on database root names.

All C functions and libraries share the same 'name space', so no two can have the same name. This includes all user global names, X2c library names and C system library names.

Determining System function names:

The list of library names, X2c and system, can be found through out the related manuals, but not usually in one place. The best reference is the summary sections of the C library manual and in the .MAP file created by X2c via the C linker for a program. The MAP file will only have functions used for a program. As a start, use the MAP file created for the MAIL program. Linux has a 'nm' program that will list globals in a module.

Keyword conflicts:

C does not allow use of keywords as variable names. Examples are 'double' and 'sizeof'.

X2c limits use of variables whose names match Xbase type names, including the 4 character abbreviation rules. This specifically applies to declaration statements: DECLARE, DIMENSION, PUBLIC, PRIVATE and VAR. For example, CHAR, CHARA, and CHARAC all conflict with CHARACTER. The keywords are: ANY, CHARACTER, DATE, LOGICAL, MEMO, NUMERIC.

The specific list of C keywords for a C system is contained in the related language manual. The following list is the C keyword list from the ANSI C specification (sect 3.1.1):

auto double int struct

break else long switch

case enum register typedef

char extern return union

const float short unsigned

continue for signed void

default goto sizeof volatile

do if static while

Macro Support

String replacement:

In X2c macros in strings and for string or filename replacement are handled automatically.

Variable name references:

X2c supports variable name references fully, for all variables so enabled. The default is 'all variables enabled'.

Expressions:

X2c automatically calls the expression evaluator when macros are used.

Keywords:

For X2c macros are not allowed in keywords, except for SET statements where ON/OFF and color settings are handled automatically. The limits approximate Clipper's handling of these statements.

System Limitations

Numeric display formatting is similar to other Xbase dialects for fields, less predictable for expressions. The TRANSFORM() function should be used where formatting is critical.

DISPLAY/? automatic formatting limited.

Dialect Specific Differences:

Fox Difference Summary:

Functions not supported by X2c:

Some SYS() functions as listed below.

FOR clause of INDEX ON statement

Clipper Difference Summary

As compared with Summer 87 release.

Built-in functions:

All functions are supported, including user functions for DBEDIT(), MEMOEDIT() and ACHOICE(). dBx has differences or limits in usage, eg. PCOUNT() can only be used in functions or procedures with VAR FUNCTION statements declaring PCOUNT() enabled and called using name() format. X2c enables PCOUNT() for all user functions.

HELP

The F1 help function (from SET key 28 TO ) calls a function help() with no parameters. Resetting SET KEY redefines this.

PCOUNT()

C does not support a standard method of passing a variable number of parameters. In X2c, PCOUNT() is supported the same as optional parameters are: by filling all missing parameters with a dummy value. This is transparent to the X2c user.

Size of programs:

X2c requires the kernals of all libraries (these four and any logic) to be always loaded. Specific functions are loaded as needed.

SORT order for pre-sorted data

X2c does not preserve any pre-sort condition. INDEX ON places all records with the same key in the index in record number order.

Using Clipper OBJ or third party add-on libraries:

Regardless that they are created using the MicroSoft C compiler, the Clipper libraries or other addon libraries are NOT standard C functions. They can not be linked directly into a C program. It is necessary to change their calling sequencing to remove references to the Clipper extend system.

Parenthesis forms: (filename), SET (exprL)

This is supported by both X2c and dBx.

Other Dialects

This includes all other Xbase-line language products

including QuickSilver, dbMAN, dbFAST, dBASE IV, FoxPro and Clipper 5.0.

No unique statements or functions are supported.

The following additional functions are available:

Run-time evaluator

Allows RESULT = &xEXPR

where xEXPR is a string containing an expression of type 'x'

For expressions Logical, Char, Date, and Numeric

levexpr, cevexpr, devexpr, nevexpr

Function are included for handling functions of unknown type.

Language Summary:

This summary highlights X2c supports all unless otherwise noted.

Functions that vary for non-PC platforms are not highlighted; in general, any disk information function may return different format information, per the target operating system. This effects functions and statements like SET PATH TO, CURDIR(), ADIR(), DISKSPACE(), etc.

Data elements:

Memos: Memos and strings are interchangeable in Clipper style,.

Parameters: X2c function parameters are all passed by name while procedure parameters are passed by reference. This is determined by the type of call: function() vs DO procedure.

Syntax Elements:

Scope clauses: REST, ALL, NEXT n, FOR exprL, WHILE exprL

Statements:

Not Supported:

X2c does not support these, unless noted,

Interactive development operations:

HISTORY controls,

CREATE: QUERY, LABEL, REPORT, SCREEN, VIEW,

MODIFY: COMMAND, FILE, LABEL, QUERY, REPORT,

SCREEN, STRUCTURE, VIEW,

SETs: interactive, SAFETY, SCOREBOARD, STEP, VIEW

Full screen Interactive data entry:

APPEND, ASSIST, BROWSE, CHANGE, EDIT, INSERT

(supported BROWSE and EDIT with limitation in options.)

Debugging:

CANCEL, HELP, RESUME, SUSPEND

Data export/import:

EXPORT TO, IMPORT FROM,

WKS, DIF, SYLK options of APPEND FROM and COPY TO

Supported Differently:

?/??: X2c does not format memory variable numerics with the identical number of digits, depending on C environments.

ACCEPT: X2c ACCEPT does not support SET KEY and related operations

CALL: Each system calls a different format 'binary' routine

X2c calls a standard C routine, hence BIN load files must be re-created as standard C called routines.

INDEX ON: does not support Fox 'FOR' clause.

INPUT: INPUT does not support SET KEY and related operations and does not allow expressions.

LOAD: X2c allows the statement but requires no action on LOAD.

SET DECIMALS: use PICTURE and TRANSFORM on ? output

X2c uses the DECIMALS setting in ? output.

SET FORMAT: only supports single screen FORMAT files,

the FMT file is called as if a DO statement

SET TALK: limited TALK displays

Supported:

?/??, @ BOX,

@ Screen: SAY, GET, VALID, PICTURE, RANGE, FUNCTION, CLEAR,

@ PROMPT/MESSAGE, @ TO,

ACCEPT,

APPEND BLANK, APPEND FROM, AVERAGE,

BEGIN SEQUENCE, BREAK, END, CALL, CASE,

CLEAR: ALL, FIELDS, GETS, MEMORY, PROGRAM, TYPEAHEAD

CLOSE: ALL, ALTERNATE, DATABASES, FORMAT, INDEX,

PROCEDURE, COMMIT, CONTINUE,

COPY FILE, COPY STRUCTURE, COPY TO, COPY STRUCTURE EXTENDED, COUNT, CREATE: empty database, CREATE FROM, DECLARE, DELETE, DELETE FILE, DIMENSION, DIR, DIRECTORY, DISPLAY: data, FILES, DISPLAY, MEMORY, STATUS, STRUCTURE DO CASE, DO WHILE, DO [WITH], EJECT, ELSEIF, ERASE, EXIT, EXTERNAL, FIND, FLUSH, FOR, FUNCTION, GATHER, GO/GOTO, IF, INDEX ON, INPUT, INSERT, JOIN, KEYBOARD,

LIST: data, FILES, MEMORY, STATUS, STRUCTURE,

LABEL, LOAD, LOCATE, LOOP, MENU TO, MENU BAR, NEXT, NOTE, ON ERROR, ON ESCAPE, ON KEY, ON KEY =, PACK, PARAMETERS, PRIVATE, PRIVATE ALL, PROCEDURE, PUBLIC, QUIT, READ, READ SAVE, READ MENU, RECALL, REINDEX, RELEASE namelist, RELEASE ALL, RENAME, REPLACE, REPORT, RESTORE FROM, RESTORE SCREEN, RESUME, RETRY, RETURN, RETURN value, RETURN TO MASTER, RUN/!, SAVE SCREEN, SAVE TO, SCATTER, SCROLL, SEEK, SELECT, SELECT 0,

SET:

ALTERNATE ON/OFF/TO, BELL, CARRY, CENTURY, CLEAR,

COLOR ON/OFF/TO, CONFIRM, CONSOLE, CURSOR, DATE,

DEBUG, DECIMALS, DEFAULT, DELETED,

DELIMITERS ON/OFF/TO, DEVICE, ECHO, ESCAPE, EXACT,

EXCLUSIVE, FIELDS, FILTER, FIXED, FORMAT, FUNCTION,

HEADING, HELP, INDEX, INTENSITY, KEY,

MARGIN, MEMOWIDTH, MENU,

MESSAGE TO [CENTER/CENTRE], ODOMETER,

ORDER, PATH, PRINTER OFF/ON/TO,

PROCEDURE,

RELATION: single, comma multiple, ADDITIVE,

SAFETY, SOFTSEEK, TYPEAHEAD, UNIQUE, WRAP

SKIP, SORT, STORE/=, SUM,

TEXT [TO PRINT/FILE]/ENDTEXT, TOTAL, TYPE [TO PRINT/FILE],

UNLOCK, UPDATE, USE, WAIT, ZAP

Functions

The format (... [ws]) indicates that dialect supports the optional work space selection parameter

Supported differently:

ADIR - Follows system dependent wildcard rules.

ALTD - No builtin debuger.

BIN2I, BIN2L, BIN2W - X2c handles this by using the memo datatype.

NETERR - Either Clipper or dBASE locking can be enabled.

NETNAME - Network or Multi-user System dependent

PCOUNT - dBx limits to functions or procedures declared to support PROCLINE - Only if OPTION TRACE ON

SYS - Only these selected sub-functions supported:

0,2,9,12,13,14,15,16,17,100,101,102,103,2002,20 03

List being constantly upgraded, check for specific ones.

TONE - Depends on C compiler and hardware environment.

TYPE - X2c handles as per expected. Clipper 'UE'/'UI' may not supported exactly the same.

Supported:

$, ABS, ACOPY, ADEL, AFIELDS, AFILL, AINS, ALIAS, ALLTRIM, ASC, ASCAN, ASORT, AT, BOF, CDOW, CHR, CMONTH, COL, CTOD, CURDIR, DATE, DAY, DBF, DBFILTER, DBRELATION, DBRSELECT, DELETED, DESCEND, DISKSPACE, DOSERROR, DOW, DTOC, DTOS, EMPTY, EOF, ERROR, ERRORLEVEL, EXP, FCLOSE, FCOUNT, FCREATE, FERROR, FIELD, FILE, FKLABEL, FKMAX, FLOCK, FOPEN, FOUND, FREAD, FREADSTR, FSEEK, FWRITE, GETE, GETENV, HARDCR, HEADER, I2BIN, IF, IIF, INDEXEXT, INDEXKEY, INDEXORD, INKEY, INT, ISALPHA, ISCOLOR, ISLOWER, ISPRINTER, ISUPPER, L2BIN, LASTKEY, LASTREC, LEFT, LEN, LOCK, LOG, LOWER, LTRIM, LUPDATE, MAX, MEMOEDIT, MEMOLINE, MEMOREAD, MEMORY, MEMOTRAN, MEMOWRIT, MESSAGE, MIN, MLCOUNT, MLPOS, MOD, MONTH, NDX, NEXTKEY, OS, PCOL, PCOUNT, PROCNAME, PROW, RAT, READINSERT, READKEY, READNEXT, READVAR, RECCOUNT, RECNO, RECSIZE, REPLICATE, RESTSCREEN, RIGHT, RLOCK, ROUND, ROW, RTRIM, SAVESCREEN, SCROLL, SECONDS, SELECT, SETCANCEL, SETCOLOR, SETPRC, SOUNDEX, SPACE, SQRT, STR, STRTRAN, STUFF, SUBSTR, TIME, TONE, TRANSFORM, TRIM, UPDATED, UPPER, USED, VAL, VERSION, WORD, YEAR