FT_HEX2DEC

FT_HEX2DEC()
 Convert a hex number to decimal

 Syntax

     FT_HEX2DEC( <cHexNum> ) -> nDecNum

 Arguments

    <cHexNum> is a character string representing a hex number.

 Returns

    A decimal number.

 Description

    Converts a hexadecimal number to a BASE 10 decimal number.
    Useful for using FT_INT86().

 Examples

    FT_INT86( HEX2DEC( "21" ), aRegs )

    Converts 21h, the Dos Interrupt, to its decimal equivalent,
    33, for use by FT_INT86().

 Source: HEX2DEC.PRG

 Author: Robert A. DiFalco

 

FT_ESCCODE

FT_ESCCODE()
 Convert Lotus style escape codes

 Syntax

      FT_ESCCODE( <cASCII> )  -> <cPrinterFormat>

 Arguments

     <cASCII> is the ASCII representation of the printer control
                codes in Lotus 123 format (e.g. "27E" for Chr(27)+"E")

                "\nnn" will be converted to Chr(nnn)
                "\\" will be converted to "\"

 Returns

     The binary version of an ASCII coded printer setup string.

 Description

     This function is useful for allowing the user to enter printer
     control codes in Lotus-style ASCII format, and then having
     this function convert that code to the format that the printer
     needs to receive.

 Examples

     cSetup = "15"          // default = Epson compressed print
     UserInput( @cSetup )     // Let user modify setup code
     SET DEVICE TO PRINT      // get ready to print
     ?? FT_ESCCODE( cSetup )  // Output the converted code

 Source: PRTESC.PRG

 Author: Steven Tyrakowski

 

C5DG-9 Terminal Drivers

Clipper 5.x – Drivers Guide

Chapter 9

Alternate Terminal Drivers

Clipper supports a driver architecture that allows Clipper- compiled applications to use alternate terminal drivers. This architecture provides support for nonstandard video hardware and ANSI output devices, allowing your applications to run in a wider variety of environments.

The following terminal drivers are supplied as part of the Clipper Development System and are discussed in this chapter:

. The ANSITERM driver provides ANSI terminal support for systems that require it

. The NOVTERM driver causes Clipper applications to execute faster when run on some nondedicated network server software

. The PCBIOS driver provides direct BIOS calls rather than direct screen writes for systems requiring this form of I/O

In This Chapter

This chapter discusses how Alternate Terminal Drivers fit into the overall Clipper architecture as well as how to install and use each of the supplied terminal drivers. The following major topics are discussed:

. The Alternate Terminal Driver Architecture

. The ANSITERM Alternate Terminal Driver

. The NOVTERM Alternate Terminal Driver

. The PCBIOS Alternate Terminal Driver

The Alternate Terminal Driver Architecture

In Clipper, communication with I/O devices is controlled by a multilayered terminal system. At the lowest level is the terminal driver which controls screen and keyboard activity. It consists of a screen and keyboard driver that communicates directly with the I/O device (operating system or hardware). It is the device specific part of the Clipper terminal system.

There is, then, a higher level system that communicates with terminal drivers. This system is known as the General Terminal (GT) system and provides general services that create Clipper screen and keyboard commands and functions. The following figure demonstrates:

                   +—————————————–+

                   | CA-Clipper screen and keyboard commands |
                   |              and functions              |
                   |-----------------------------------------|
                   |        General Terminal (GT.OBJ)        |
                   ------------------------------------------|
                   |             Terminal Driver             |
                   |-----------------------------------------|
                   |          Screen   |   Keyboard          |
                   +-----------------------------------------+

The default terminal driver, designed for IBM PC and 100% compatibles, is supplied as a library file (TERMINAL.LIB) installed into your \CLIPPER5\LIB directory. This driver links into each program automatically if you specify no alternative terminal driver provided that you do not use the /R option when you compile. An alternate terminal driver is supplied as a separate library (.LIB) file that links into an application program in place of the default terminal driver if you specify it on the link line.

All alternate terminal drivers work through the General Terminal layer as supplied in the file GT.OBJ. The Clipper installation program installs this file in the \CLIPPER5\OBJ subdirectory on the drive that you specify, so you need not install the driver manually.

The ANSITERM Alternate Terminal Driver

The ANSITERM terminal driver supports the ANSI screen mode for all screen display from Clipper programs.

This screen mode is installed by specifying ANSI.SYS in the user’s CONFIG.SYS. ANSI.SYS replaces the default DOS CON device driver for video display and keyboard input. Once installed it supports ANSI escape sequences to erase the screen, set the screen mode, and control the cursor in a hardware-independent way. Most modern DOS programs, however, do not use it and write either directly to the video hardware or use BIOS routines for enhanced screen performance.

Use the ANSI screen mode for Clipper programs that run on hardware that does not support either writing to video hardware or BIOS calls for screen display. This is the case when using alternative display hardware to support the blind.

Note: The ANSITERM terminal driver fully supports all screen and keyboard functionality of the default terminal driver. This includes the ability to save and restore screens and support for all keys on the standard 101-key keyboard.

Installing ANSITERM Terminal Files

The ANSITERM terminal driver is supplied as the file ANSITERM.LIB. The Clipper installation program installs this file in the \CLIPPER5\LIB subdirectory on the drive that you specify, so you need not install it manually.

Linking the ANSITERM Terminal Driver

To link the ANSITERM alternate terminal driver into an application program, you must specify both GT.OBJ and ANSITERM.LIB to the linker along with your application object (.OBJ) modules.

1. To link with .RTLink using positional syntax:

C>RTLINK <appObjectList> GT,,, ANSITERM

2. To link with .RTLink using freeformat syntax:

C>RTLINK FI <appObjectList>, GT LIB ANSITERM

3. To link with .RTLink using ANSITERM.PLL and freeformat syntax:

C>RTLINK FI <appObjectList> /PLL:ANSITERM

Note: These link commands assume you have set the LIB, OBJ, and PLL environment variables to the standard locations. They also assume that the Clipper programs were compiled without the /R option.

Important! You cannot link the ANSITERM driver with BASE52.PLL. An application linked with both ANSITERM.LIB and BASE52.PLL may cause the computer to freeze upon execution.

The Runtime Environment

Using ANSITERM.LIB requires that ANSI.SYS be installed on the user’s computer. To accomplish this, include the following statement in the user’s CONFIG.SYS:

DEVICE=ANSI.SYS

Performance Concerns

Because the ANSITERM terminal driver uses buffered screen writes for all screen painting, some operations, especially those that scroll the screen, are slow. These include:

1. All box drawing commands and functions

2. All console commands and functions when scrolling

3. All clear screen commands and functions

4. All restore screen commands and functions

5. Standard out functions (OUTSTD() and OUTERR()) whether the screen is scrolling or not

Note: Overall performance of Clipper programs is slower since the ANSITERM terminal driver must spend more time polling for user events than the standard Clipper terminal driver.

Screen Output from C and Assembly Language

The ANSITERM terminal driver overwrites all output from C and Assembly Language when it refreshes the screen from the screen buffer. As a consequence, you should perform all screen output from Clipper.

The ANSITERM terminal driver also virtualizes the cursor. This means that BIOS functions that report the location of the hardware cursor will not always return the correct value. To obtain the cursor position, use Clipper’s ROW() and COL() functions instead.

Other Incompatibilities

1. ISCOLOR() always returns false (.F.).

2. When you load DBU, the default color mode is monochrome unless you specify DBU with the /C command line option.

3. The first time you invoke the Debugger, the default color mode is also monochrome unless you set the Options:Mono display off.

4. When an application linked with the ANSITERM terminal driver terminates, the last color set in the application becomes the DOS color. This happens since colors set with ANSITERM are global to DOS and Clipper cannot query DOS for the current screen colors as the application loads.

5. Nondisplaying ASCII characters are presented as a space by the ANSITERM terminal driver. These include BELL (CHR(7)), BS (CHR(8)), TAB (CHR(9)), LF (CHR(10)), CR (CHR(13)), and ESC (CHR(27)).

The NOVTERM Alternate Terminal Driver

The NOVTERM terminal driver is a special-purpose driver that circumvents an incompatibility between some nondedicated network server software and Clipper. This incompatibility causes printers connected to the server to slow to an unusable rate.

Clipper applications and nondedicated servers compete for resources. Clipper applications make use of the time between keystrokes to perform various system tasks. This greatly improves the application’s overall performance by limiting its idle time. Certain nondedicated servers only attempt to print within an application’s idle time. Since a Clipper application is seldom idle, this greatly slows printing.

Important! The NOVTERM terminal driver corrects the incompatibility by preventing the Clipper application from using idle time. Because this can severely hamper performance, you should only use the NOVTERM terminal driver when necessary, and then you should link it only into those applications that are physically running the nondedicated server.

Note: The NOVTERM terminal driver fully supports all screen and keyboard functionality of the default terminal driver. This includes the ability to save and restore screens and support for all keys on the standard 101-key keyboard.

Installing NOVTERM Terminal Files

The NOVTERM terminal driver is supplied as the file NOVTERM.LIB. The Clipper installation program installs the driver file in the \CLIPPER5\LIB subdirectory on the drive that you specify, so you need not install it manually.

Linking the NOVTERM Terminal Driver

To link the NOVTERM alternate terminal driver into an application, you must specify both GT.OBJ and NOVTERM.LIB to the linker with your application object (.OBJ) modules.

1. To link with .RTLink using positional syntax:

C>RTLINK <appObjectList> GT,,, NOVTERM

2. To link with .RTLink using freeformat syntax:

C>RTLINK FI <appObjectList>, GT LIB NOVTERM

3. To link with .RTLink using NOVTERM.PLL and freeformat syntax:

C>RTLINK FI <appObjectList> /PLL:NOVTERM

Note: These link commands assume you have set the LIB, OBJ, and PLL environment variables to the standard locations. They also assume that the Clipper programs were compiled without the /R option.

Important! You cannot link the NOVTERM driver with BASE52.PLL. An application linked with both NOVTERM.LIB and BASE52.PLL may cause the computer to freeze upon execution.

Performance Concerns

Overall performance of Clipper programs is slower since the NOVTERM terminal driver must spend more time polling for user events than the standard Clipper terminal driver and since the program will not use its idle time for other tasks.

Screen Output from C and Assembly Language

The NOVTERM terminal driver overwrites all output from C and Assembly Language when it refreshes the screen from the screen buffer. Therefore, you should perform all screen output from Clipper.

The NOVTERM terminal driver also virtualizes the cursor. This means that BIOS functions that report the location of the hardware cursor will not always return the correct value. To obtain the cursor position, use Clipper’s ROW() and COL() functions.

The PCBIOS Alternate Terminal Driver

The PCBIOS terminal driver uses BIOS calls instead of direct screen writes. It is designedd for applications that trap BIOS calls to redirect output over telecommunication lines or to convert output to a form compatible with two-byte character sets.

Note: The PCBIOS terminal driver fully supports all screen and keyboard functionality of the default terminal driver. This includes the ability to save and restore screens and support for all keys on the standard 101-key keyboard.

Installing PCBIOS Terminal Files

The PCBIOS terminal driver is supplied as the file, PCBIOS.LIB. The Clipper installation program installs the driver file in the \CLIPPER5\LIB subdirectory on the drive that you specify, so you need not install it manually.

Linking the PCBIOS Terminal Driver

To link the PCBIOS alternate terminal driver into an application program, you must specify both GT.OBJ and PCBIOS.LIB to the linker in addition to your application object (.OBJ) modules.

1. To link with .RTLink using positional syntax:

   C>RTLINK <appObjectList> GT,,, PCBIOS;

2. To link with .RTLink using freeformat syntax:

   C>RTLINK FI <appObjectList>, GT LIB PCBIOS

3. To link with .RTLink using PCBIOS.PLL and freeformat syntax:

   C>RTLINK FI <appObjectList> /PLL:PCBIOS

Note: These link commands assume you have set the LIB, OBJ, and PLL environment variables to the standard locations. They also assume that the Clipper programs were compiled without the /R option.

Important! You cannot link the PCBIOS driver with BASE52.PLL. An application linked with both PCBIOS.LIB and BASE52.PLL may cause the user’s computer to freeze when the user executes it.

Performance Concerns

Because the PCBIOS terminal driver uses buffered screen writes for all screen painting, some operations, especially those that scroll the screen, are slow. These include:

1. All box drawing commands and functions

2. All console commands and functions when scrolling

3. All clear screen commands and functions

4. All restore screen commands and functions

5. Standard out functions (OUTSTD() and OUTERR()) whether the screen is scrolling or not

Screen Output from C and Assembly Language

The PCBIOS terminal driver also overwrites all output from C and Assembly Language when it refreshes the screen from the screen buffer. Therefore, you should perform all screen output from Clipper.

The PCBIOS terminal driver also virtualizes the cursor. This means that BIOS functions that report the location of the hardware cursor do not always return the correct value. To obtain the cursor position, use Clipper’s ROW() and COL() functions.

Summary

This chapter has introduced you to the Alternate Terminal Driver concept, giving you specific information on the architecture used to implement them in Clipper. Each of the alternate terminal drivers supplied with Clipper was discussed, including how to link and use it into your application and the implications of doing so.

Array Terms

Array :

A data structure that contains an ordered series of values called elements. The elements of an array are referred to by ordinal number; the first element is number 1, the second is number 2, etc. A numeric expression used to specify an element of an array is referred to as a subscript or index. In Clipper language, the elements of an array may be values of any type, including references to other arrays.

See Also : Array Reference, Nested Array, Subarray, Subscript

Array Functions :

Those functions that specifically perform their tasks on arrays.

See Also : Array, Element, Function, Subscript

Array Iterator :

A function that traverses an array, performing an operation on each element.

See Also : Array

Array Reference :

A special data value that allows access to an array. In Clipper language, program variables and array elements cannot directly contain arrays; they may, however, contain array references. A variable that contains a reference to a particular array is said to refer to that array, and the array’s elements may be accessed by applying a subscript to the variable. If the value of a variable containing an array reference is assigned to a second variable, the second variable will contain a copy of the array reference; both variables then refer to the same array, and the array’s elements may be accessed by applying a subscript to either variable.

See Also: Array, Nested Array, Subarray, Subscript

Constant Array :

See : Literal Array

Dimension :

The maximum number of subscripts required to specify an array element. For example, a two-dimensional array must have two subscripts, a three-dimensional array must have three subscripts and so on.

See Also: Subscript

Element :

A component unit of an array, usually referred to by a numeric subscript or index.

See Also: Array, Subscript

Literal Array :

In Clipper language, an array specified by enclosing a series of expressions in curly ({}) braces. A literal array is an expression that evaluates to an array reference.

See Also: Array, Array Reference

Multidimensional Array :

In Clipper language, an array whose elements consist entirely of references to other arrays (called subarrays). The elements of the subarrays may, in turn, contain references to other arrays. Arrays organized in this fashion are said to be nested. Each level of nesting may be viewed as a dimension of the main array, and the elements of the subarrays may be accessed by applying multiple subscripts to the main array.

See Also: Array, Array Reference, Nested Array, Subscript

Nested Array :

In Clipper language, two arrays are said to be nested if one of them contains a reference to the other. When an array contains a reference to a second array, the second array is sometimes called a subarray of the first array

See Also: Array, Array Reference, Multidimensional Array

Reference :

A special value that refers indirectly to a variable or array. If one variable contains a reference to a second variable (achieved by passing the second variable by reference in a function or procedure call), operations on the first variable (including assignment) are passed through to the second variable. If a variable contains a reference to an array, the elements of the array can be accessed by applying a subscript to the variable.

See Also: Array Reference, Parameter

Single-dimensional Array :

In Clipper language, an array whose elements do not contain references to other arrays.

See Also:Array, Multidimensional Array, Nested Array, Subarray, Subscript

Sort Order :

Describes the various ways database files and arrays are ordered.

. Ascending

Causes the order of data in a sort to be from lowest value to highest value.

. Descending

Causes the order of data in a sort to be from highest value to lowest value.

. Chronological

Causes data in a sort to be ordered based on a date value, from earliest to most recent.

. ASCII

Causes data in a sort to be ordered according to the ASCII Code values of the data to be sorted.

. Dictionary

The data in a sort is ordered in the way it would appear if the items sorted were entries in a dictionary of the English language.

. Collating Sequence

Data in a sort will be placed in sequence following the order of characters in the Extended Character Set.

. Natural

The order in which data was entered into the database.

Subarray :

In Clipper language, an array that is referred to by an element of another array.

See Also:Array, Multidimensional Array, Nested Array, Subscript

Subscript :

A numeric value used to designate a particular element of an array. Applying a subscript to an array is called subscripting the array. In Clipper programs, subscripting is specified by enclosing a numeric expression in square   ([ ]) brackets after the name of a program variable. The variable is then said to be subscripted.

See Also: Array, Array Reference, Nested Array, Subarray

Two-dimensional Array :

An array that has two dimensions. In Clipper language, an array whose elements contain references to other arrays, all of which have the same length and do not refer to other arrays.

See Also: Array, Array Reference, Nested Array, Subscript

General Terms

ASCII :

An acronym for the American Standard Code for Information Interchange, the agreed upon standard for representing characters (alphabetic, symbolic, etc.) in the memory of the computer.

Binary :

The numerical base upon which computer programs are modeled. Also referred to as base 2, it is a mathematical way of representing the electrical circuitry upon which computers operate. A 0 represents an off state, and a 1 indicates an on state. A combination of eight ons and offs are used to express bytes of program or data in memory.

See Also: Byte

Buffer :

A temporary data storage location in memory. As an example, a disk input-output buffer is an area of memory that stores data read from the disk to temporary locations while processing it.

Byte :

Eight bits of data, the smallest unit of information stored in the computer’s memory. As an example, one byte is required to represent one ASCII character.

Character :

A letter, digit, punctuation mark, or special symbol stored and processed by the computer.

See Also: ASCII String

Delimiter :

A character or other symbol that marks a boundary.

Destination :

The work area, file, or device to which data is sent.

Device :

Either an actual physical component of the computer system such as printer or a DOS handle that refers to it (e.g., PRN:), or a logical device that behaves and is addressed the same way as a physical device (e.g., a print spooler).

Disk :

A magnetic storage medium designed for long-term storage. Disks come in two varieties: hard disks (fast but fixed) or floppy disks (slow but removable). A disk can be partitioned into multiple volumes, each containing a tree-structured directory system that holds files accessible by programs.

See Also: Directory, File, Volume

Dynamic :

Used generically to refer to data or algorithms that change with time. Often used specifically to describe algorithms that automatically adjust to prevailing conditions.

Formfeed :

A special character (CHR(12)) that by convention causes most printers to move the printhead to the top of the next page.

See Also: Hard Carriage Return Linefeed

Hard Carriage Return :

An explicit carriage return character at the end of a line in a text file, as opposed to a soft carriage return that might be inserted into text by a program designed to handle word wrapping. A hard carriage return character is generated by the expression (CHR(13)) where a soft carriage return character is generated with the expression (CHR(141)).

Hexadecimal :

A representation of a value in base 16 rather than decimal which is base 10. Hexadecimal values are easily converted to and from binary (base 2) which is the form of data the computer actually uses. Hexadecimal values are represented by digits zero through nine and A through F for values between 10 and 15.

Extended Character Set :

The character set built into the ROM of the PC. This character set is a superset of ASCII, containing additional special characters (such as a line drawing character set) that may be used to enhance your program screens.

Linefeed :

A special character (CHR(10)) that by convention causes the cursor or printhead to move to the next line or to terminate a line in a text file. It is usually used in combination with a hard carriage return.

See Also: Formfeed, Hard Carriage Return

Port :

A designation for the hardware that allows the processor to communicate with peripheral devices.

Query :

A query is also a general term used when you want to interrogate a setting or an exported instance variable for its current value.

Queue :

A data structure of variable length where elements are added to one end and retrieved from the other. A queue is often described as first in, first out.

See Also: Print Spooler, Stack

Soft Carriage Return :

A carriage return that is introduced into text usually in order to implement some sort of wrap operation, as opposed to a Hard Carriage Return that was specifically entered into the text when it was created.

Stack :

A data structure of variable length whose elements are added and retrieved from the same end. A stack is often described as first in, last out.

See Also: Queue