Reader's Forum - Mark Hirst Revelation C Interface - Part 1
Reader's Forum The C Interface Part 2 - Mark Hirst (Senior Techie - ICS) Reader's Clinic
@ATTACK - @Modal
QTIPS - Using @Upper.Case and @Lower.Case with Foreign Languages
QTIPS - Local Language Sets
Sorting out Collation Sequences by Mike Pope
Background Processing
Creating Your Own Background Processes
@ATTACK - @Index.Time
How Indexes Are Updated
Reader's Forum - Mark Hirst Revelation C Interface - Part 1
Reader's Forum The C Interface Part 2 - Mark Hirst (Senior Techie - ICS) Reader's Clinic
RTP Series - RTP9
RTP Series - RTP50
VERBatim - V25
@ATTACK - @Files
Utility Diskette # 3 - Part I
Vroom
Vroom - Window Processing
Reader's Forum
VROOM - Doubling MFS Write Speed
Reader's Clinic - Line Length > 256 Characters
QTIPS - String Space
QTIPS - String Space Format Errors
Reader's Forum - Numeric Precision in R/Basic - Hal Wyman
QTIPS - DOS File Names
DOS Interfacing (Part II)
VERBatim - V116
@ATTACK - @Pri.File
@ATTACK - @Rollout.File
File Variables
How Indexes Are Updated
Index Record Layouts
QTIPS - File Variable of File In SELECT Statement
QTIPS - Amending non-Attached Files
LINEAR HASH FILE STRUCTURES - Part 1
Index Flush
QTIPS - File Handle Structure
@ATTACK - @Reduction.Done
RTP Series - RTP5
VERBatim - V22
Play it Again, Cam
Reader's Forum - Mark Hirst Revelation C Interface - Part 1
Reader's Forum - Numeric Precision in R/Basic - Hal Wyman
QTIPS - Use of Mouse
Reader's Forum The C Interface Part 2 - Mark Hirst (Senior Techie - ICS) Reader's Clinic
Utility Diskette # 4
Version 3 Technical Highlights - Customising NewApplication Creation
RTP Series - RTP5
VERBatim - V22
QTIPS - Handy Compiler Options
VERBatim - V119
VERBatim - V125
VERBatim - V118
Advanced Revelation Assembler Interface Module - Yves Pattyn, Technical Manager, Distribase, France
Compiling 64K on a Shoestring by Blaise Wrenn (LexStat Systems Ltd)
QTIPS - Improving the LH_VERIFY Window
Vroom
RTP Series - RTP5
VERBatim - V15
Play it Again, Cam
QTIPS - BASIC Options
Utility Diskette # 4
Reader's Clinic - Functions and Subroutines
Reader's Letters - Jim Owen
Playing with Scan Codes
Argument passing - Subroutines and Functions - Mike Pope
Reader's Clinic - Screen Width
Screen Grabber
Reader's Clinic - Slow Multivalued Screen Display
Utility Diskette # 4
Merge Processor
QTIPS - Using INIT.VIEW with Printers
@ATTACK - @PDisk.On
Referential Integrity
Reader's Clinic - Related Windows
Prompt Help
VERBatim - V6
QTIPS - BASIC Options
The End of the Line - Mike Pope and Hal Wyman
Creating Your Own Background Processes
@ATTACK - @Last.Select.Process
Reader's Forum
QTIPS - Menu Item Pre-Processing
Playing with Scan Codes
QTIPS - Compiling Protection Code
QTIPS - Invalid Code and Command
QTIPS - Code/Command Help
Compiling 64K on a Shoestring by Blaise Wrenn (LexStat Systems Ltd)
QTIPS - Using @Upper.Case and @Lower.Case with Foreign Languages
@ATTACK - @Lower.Case
@ATTACK - @Upper.Case
Sorting out Collation Sequences by Mike Pope
RTP Series - RTP27
QTIPS - Printing Large Variables from the Debugger
VERBatim - V87
V119 - Part I
QTIPS - @Date.Format
@ATTACK - @Date.Format
QTIPS - Short Cut Implicit Formatting
Utility Diskette # 4
Redefining Keys
RTP Series - RTP53B
Prompt Help
VERBatim - V124
Popups
@ATTACK - @Environ.Set
@ATTACK - @Edit.Keys
@ATTACK - @Int.Const
@ATTACK - @HW
@ATTACK - @Modal
@ATTACK - @Move.Keys
@ATTACK - @Priority.Int
@ATTACK - @Macro.Mode
Utility Diskette # 3 - Part I
Utility Diskette # 3 - Part II
Utility Diskette # 4
Utility Diskette # 3 - Part I
Utility Diskette # 3 - Part II
Utility Diskette # 4

RevMedia FKB

DocumentV3I5A4
TitleReader's Forum - Mark Hirst Revelation C Interface - Part 1
KeywordsC
RBASIC
INTERFACE
FOD
ROM
BIOS
DOS
TextIntroduction
The C Interface is a software package FROM Revelation Technologies to allow
Revelation and Advanced Revelation to call C language routines The C
interface gives Revelation and Advanced Revelation (hence forth referred to
collectively as Rev) the ability to control devices to manipulate aspects
of the underlying HARDWARE or to use ROM BIOS and DOS services Links to C
also gives a developer an opportunity to use some of the C libraries
available particularly those that can access files for the creation of
Environmental BONDS C gives speed advantages particularly in complex
numerical calculations The C interface should not be an excuse to begin
re writing your applications wholesale in C In a number of instances
particularly string handling Rev is faster and all file I/O to Rev files
must be done via CALLS to R/Basic The additional work and effort required
means that you would only use C where R/Basic is unable to serve

This series of articles assumes that you are experienced WITH R/Basic and
have a working knowledge of C Some understanding of the 80x86 processors
and some familiarity WITH DOS and the ROM BIOS is ALSO useful

Requirements
In order to create C routines suitable for inclusion into Rev the following
are required in addition to your existing Rev system:

* C Interface version 2 0

* Microsoft C version 5 x or Manx Aztec C86

The Microsoft C compiler version is important The CURRENT version is 6 x
The LIBRARY structures in 6 x have apparently changed making this version
incompatible I have been able to use 6 x WITH no apparent ill effects but
the requirements are stated so stick to them! In general the compiler
requirement is a compiler that can produce COM files Use of other
compilers requires the creation of an assembler module FROM source provided
on the disk

The Microsoft compiler is preferable and was used for the examples shown in
this series

Development
We will begin by looking straight away at a simple EXAMPLE which will
illustrate the basic steps involved Later we will examine the steps in more
detail and some of the design restrictions and rules that must be observed

The following EXAMPLE taken FROM the C interface guide illustrates a simple
program which uses the rev_print_string function (taken FROM the C interface
function library) to send a string to the screen or printer The header file
#include revintrf h is used to insert a file that declares functions and
variables related to the C function LIBRARY #INCLUDE is similar to an
R/Basic $INSERT STATEMENT whilst #define MSC is used to control a
pre compilation process that conditionally includes source code according to
which compiler you are USING in this case Microsoft C

#define MSC
#include "revintrf h"
main() {
rev_print_string(" ") ;
rev_print_string("Hello World ") ;
}

The program is compiled by invoking the compiler CL as follows:

cl c EXAMPLE c

The c option causes compilation to OBJECT code only

The resulting OBJECT file is then linked to STARTUP OBJ and REVMSC LIB as
follows:

LINK STARTUP EXAMPLE EXAMPLE example/MAP REVMSC/NOE

The linking process resolves references in your C code to external functions
by combining your program OBJECT code WITH libraries of standard functions
The /NOE option prevents extended LIBRARY searches which cause symbol
multiply DEFINED errors whilst linking

The resulting EXE file is then converted into binary format (which do not
relocate in memory) USING the utility EXE2BIN EXE which is included with
DOS

exe2bin EXAMPLE exe

The program EXAMPLE bin is now ready to be loaded into Rev This is done
using an R/Basic utility provided on the C interface diskette This program
will load and store the program into a Rev file The program is then
catalogued and is ready for testing

Writing the C Code
The first thing that might strike a C programmer about the code is the use
of the function call rev_print_string rather than the more familiar printf
which is equivalent to the R/Basic PRINT The function is one of a list of
functions provided for the C programmer to link WITH R/Basic The include
file REVINTRF H contains declarations of these functions They include
functions to receive and return VARIABLES to manipulate files common
variable links and output C programs can call R/Basic functions call DOS
and BIOS services and can invoke Rev file operations such as create OPEN
read WRITE and so on The functions are fully documented and in later
sections of this series we will see some in ACTION particularly in passing
variables to and FROM the C program

The C code that you intend to adapt or write must ALSO conform to two
important rules:

* Only the SMALL model can be used that is the code and DATA must
be fit into 64K COMPACT or LARGE models will cause fixup errors
in the EXE2BIN stage making the function unusable Far pointers
can be declared to point to VARIABLES in Rev string SPACE and
special versions of some standard C string functions are provided
on the diskette

* MEMORY allocation USING standard C memory routines such as malloc
alloc etc must be avoided DYNAMIC memory can be allocated in Rev
string space but keeping track of it AFTER the
"garbage collection" means that you need to ask Rev where it is
before use

These rules are important for pre written function libraries which allocate
buffers and may ALSO violate the SMALL model rule Unless the source is
available these libraries may cause PROBLEMS that would be difficult to pin
down

The NEXT section of this series will use a more complex program to
demonstrate a practical EXAMPLE of a C language module and demonstrate the
use of the C function LIBRARY to MOVE VARIABLES to and FROM the C and
R/Basic environments

Mark Hirst is the ICS Advantage Support MANAGER at ICS He is ALSO the
author of the various graphical utilities found on the last diskette


(Volume 3 Issue 5 Pages 8 10)
[revmedia/copyrigh.htm]

Page last modified: 31/01/03