[Developer-Addons] ClipX Review
Neil Freeman developer-addons@matrixlist.com
Sat Jun 8 08:36:31 2002
Want to use your CA-Clipper expertise and reuse the logic, that took you so
long to learn, in one of the newer areas of computing? Then the web is
probably the place for you and with the help of ClipX CGI library, you
should be able to get there quickly and painlessly.
ClipX is a CA-Clipper library written in C which allows you to write CGI
(Common Gateway Interface) programs for the web. This lets you to handle
all the background functions like database password authentication,
database inventory control and transaction storage and retrieval and the
creation of HTML code "on the fly" to display any results or request any
additional required information. And all of this using regular CA-Clipper
commands and databases called by a web pages. Anyone with a web browser,
and authorization, can then use your application on the internet or an
intranet.
For this review, I used ClipX Version 1.2. The product itself is installed
simply and can be uninstalled just as easily. It contains a library, an
object file, help in the forms of a Norton Guide and HTML format along with
some samples to help get you on your way. There are no additional headers
that need to be inserted into your programs.
The requirements for using ClipX are a CGI 1.1 Web server, CA-Clipper 5.2x,
a CA-Clipper linker, and ClipX itself.
Among others, the advantages of using ClipX for your "Web" applications
include the ability to use CA-Clipper as your web language as well as the
capacity for testing your program at the DOS prompt before it gets to the
web site. The possibilities of using CA-Clipper on the web are endless. You
could, for example, create a survey form and then store the data in a dbf
for later analysis. How about an order form or an online service sign up
system as possibilities. On line tech support with the knowledgebase stored
in, and retrieved from, dbfs and web pages that dynamically display the
requested information. And all this is possible using CA-Clipper and the
ClipX library.
The one thing you will need to ask prior to purchasing is whether the
platform you want to use is compatible with ClipX. Microsoft's IIS, for
example, is not compatible and some other web servers are, or are not,
usable based on the Windows version on which they are being run. There is
an eval version that will let you test ClipX before you buy the product and
with all the web servers and versions of Windows available, it is a wise
idea to test ClipX first on your target system to make sure of compliance.
The tech support both online on the company's web site and through email is
very good. Don't hesitate to contact them regarding the use of their
product either before or after purchasing ClipX.
To help you understand a little bit more of how the ClipX library works, I
have included the sample program which comes with the package. Notice that
this is "just plain" CA-Clipper with new function calls that allow you to
expand your programming to the web. Here is the example:
// Program : cxStates.Prg
//--------------------------------------------------------------
function main()
//--------------------------------------------------------------
// Open STDIN/STDOUT communications with the Web Server
if ( !ClipxOpen() )
quit
endif
// Content-Type Header
header()
// Output to begin tags in one call
htmlBodyBeg("Page Title can go here as a parameter...")
// Simple example of a database (Dbase type Edit)
DbExample()
// Output to end tags in one call
htmlBodyEnd()
return (Nil)
//--------------------------------------------------------------
function DbExample()
//--------------------------------------------------------------
local nI := 0
local cTxt := ""
local cRecNo := ""
local nRecNo := 1
local aCgi := {}
local nGoto := 1
// Begin PRE-formatted output display
PreBeg()
// You need a FORM BEGIN/END tag for the Web Browser to send form variables
// to the Web Server using either POST or GET method.
FormBeg("cxStates", "/cgi-bin/cxStates.exe", "POST")
// Open the DBF file
use st new shared
if ( neterr() )
htmlWrite("Error opening file...") ; br()
quit
endif
// Declare Form variable as public for easy access (SUMMER 87 STYLE)
// for e.g.: below we access CRECNO & BTNMOVE variables directly
pubvars()
// NOTE: here "cRecNo" is accessed using the cxCgiValue() function
// whereas,"btnMove" is directly access as memvar due to PubVars()
//nRecNo := if(type("cRecNo")=="C", val(memvar->cRecNo), 1)
nRecNo := val(cxCgiValue("cRecNo"))
nRecNo := if(nRecNo>0,nRecNo,1)
// Move to the record as per the pressed button
if ( type("btnMove")=="C" )
do case
case ( upper(memvar->btnMove) == "TOP" )
dbgotop()
nRecNo := recno()
case ( upper(memvar->btnMove) == "PREV" )
nRecNo := if(nRecNo > 1, nRecNo-1, 1)
case ( upper(memvar->btnMove) == "NEXT" )
nRecNo := if(nRecNo < reccount(), nRecNo+1, nRecNo)
case ( upper(memvar->btnMove) == "BOTTOM" )
dbgobottom()
nRecNo := recno()
case ( upper(memvar->btnMove) == "GOTO" )
nGoto := val(memvar->txtGoto)
if ( nGoto > 0 .and. nGoto < reccount()+1 )
nRecNo := nGoto
endif
other
// Display the same record
// Make sure the name of the buttons are correct
endcase
endif
// Goto the desired record
dbgoto(nRecNo)
// Use Hidden INPUT field to keep track of the current record number
HiddenFld("cRecNo", ltrim(str(nRecNo)))
// Display Navigation buttons
Input("btnMove","Top" ,"Submit")
htmlWrite(" ")
Input("btnMove","Prev" ,"Submit")
htmlWrite(" ")
Input("btnMove","Next" ,"Submit")
htmlWrite(" ")
Input("btnMove","Bottom","Submit")
htmlWrite(" ")
Input("btnMove","GoTo" ,"Submit")
Input("txtGoto", ltrim(str(nGoto)),"TEXT") ; br() ; cr()
// Display file name and the currrent record number
htmlWrite("File : " + alias()) ; cr()
htmlWrite("Record #: " + ltrim(str(recno())) +" of "+
ltrim(str(reccount())) )
br() ; cr()
// Display all the fields-1 of the DBF file
for nI := 1 to fcount() - 1
cTxt := fieldget(nI)
if ( valtype(cTxt)=="L" )
cTxt := transform(fieldget(nI), "Y")
else
cTxt := xtoStr(cTxt)
endif
htmlWrite(padr(fieldname(nI),10) + "(" + valtype(fieldget(nI)) + ") : ")
if ( valtype(fieldget(nI)) == "M" )
TextArea("c"+fieldname(nI), 4, 50, cTxt) ; br()
else
htmlWrite(InputTypes("c"+fieldname(nI), cTxt, "TEXT",
if(len(cTxt)>50,50,len(cTxt)), len(cTxt))) ; br()
endif
next
// Display the first field of the DBF file
nI := fcount()
htmlWrite(padr(fieldname(nI),10) + "(" + valtype(fieldget(nI)) + ") : ")
TextArea("c"+fieldname(nI), 4, 50, fieldget(nI)) ; br()
//htmlWrite(InputTypes("c"+fieldname(nI), fieldget(nI), "TEXT", 12, 12))
// FORM End tag
FormEnd()
// End PRE-formatted output display
PreEnd()
return (Nil)
//--------------------------------------------------------------
function xtoStr( x )
//--------------------------------------------------------------
local cRtn := ""
local cType := ""
cType := valType( x )
do case
case cType == "C" // character string
cRtn := x
case cType == "N" // numeric value
cRtn := str( x )
case cType == "D" // date value
cRtn := dtos( x )
case cType == "L" // logical value
cRtn := iif( x, ".T.", ".F." )
case cType == "A" // array
cRtn := "Array"
case cType == "B" // code block
cRtn := "Code Block"
case cType == "M" // memo field
cRtn := x
case cType == "O" // object
cRtn := "Object"
case cType == "U" // Nil
cRtn := "Nil"
endcase
return (cRtn)
//--------------------------------------------------------------
The following is the function list from the ClipX help system:
AHRef()
Returns/writes HTML linked URL anchor tag
BgSound()
Returns/writes HTML Background Sound tag
Big()
Returns/writes wrapper for Big font tag ...
BodyBeg()
Returns/writes HTML Body begin tag < Body ... >
BodyEnd()
Returns/writes HTML Body end tag
BoldBeg()
Returns/writes HTML Bold begin tag
BoldEnd()
Returns/writes HTML Bold end tag
BoldItalBeg()
Returns/writes wrapper for Bold and Italic begin tags
BoldItalEnd()
Returns/writes wrapper for Bold and Italic end tags
BoldULineBeg()
Returns/writes wrapper for Bold and UnderLine begin tags
BoldULineEnd()
Returns/writes wrapper for Bold and UnderLine end tags
Br()
Returns/writes HTML Line Break tag
Button()
Returns/writes a Button form-object using HTML Input tag
CenterBeg()
Returns/writes HTML Center begin tag
CenterEnd()
Returns/writes HTML Center end tag
CheckBox()
Returns/writes HTML Checkbox form-object
ClipXOpen()
Required first call in each CGI program
ClipXClose()
Called last in a CGI program
Cr()
Returns/writes Carriage Return / Line Feed
cxCgiCount()
Returns the element count of the form array
cxCgiIVal()
Returns the name or value of a form object by index number
cxCgiStr()
Returns the cooked form object data passed by the Web Server
cxCgiStrRaw()
Returns the raw form object data passed by the Web Server
cxCgiValue()
Get Form-object value by object-name
cxFormArray()
Creates an array of parsed form-data
cxSpace()
Returns/writes space character in escape-sequence format &npsp;
cxOut()
Writes a character string plus CR/LF to standard-out
cxxOut()
Writes a character string to standard-out - Same as htmlWrite()
FontBeg()
Returns/writes HTML Font begin tag and font attributes
FontEnd()
Returns/writes HTML Font end tag
FormBeg()
Returns/writes HTML Form begin tag and attributes
headBeg()
Returns/writes HTML head begin tag
headEnd()
Returns/writes HTML head end tag
header()
Returns/writes required context-header
HiddenFld()
Returns/writes HTML Hidden Input Text field
HR()
Returns/writes HTML horizontal line tag
htmlAlert()
Writes Javascript Alert Box
HtmlBeg()
Returns/writes HTML begin tag
HtmlEnd()
Returns/writes HTML end tag
HtmlBodyBeg()
Writes wrapper for HTML begin through Body begin tags
HtmlBodyEnd()
Writes wrapper for Body end through HTML end tags
htmlWrite()
Writes a string to the web server
Image()
Returns/writes HTML Image tag
Input()
Returns/writes HTML INPUT form tag
ItalicsBeg()
Returns/writes HTML Italics Begin tag
ItalicsEnd()
Returns/writes HTML Italics end tag
JavaScrBeg()
Returns/writes Javascript language begin script
JavaScrEnd()
Returns/writes Javascript language end script
LI()
Returns/writes HTML Line Item tag
ListBox()
Writes wrapper for Select/Option tags
Marquee()
Returns/writes scrolling message - MSIE only
Olbeg()
Returns/writes HTML Ordered List begin tag
Olend()
Returns/writes HTML Ordered List end tag
Option()
Returns/writes HTML Option tag