ClipX -- Clipper CGI -- Home Page

[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 <HTML> to <BODY> begin tags in one call htmlBodyBeg("Page Title can go here as a parameter...") // Simple example of a database (Dbase type Edit) DbExample() // Output </BODY> to </HTML> 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 <A HREF ... > BgSound() Returns/writes HTML Background Sound tag <BgSound SRC... > Big() Returns/writes wrapper for Big font tag <Big>...</Big> BodyBeg() Returns/writes HTML Body begin tag < Body ... > BodyEnd() Returns/writes HTML Body end tag </Body> BoldBeg() Returns/writes HTML Bold begin tag <b> BoldEnd() Returns/writes HTML Bold end tag </b> BoldItalBeg() Returns/writes wrapper for Bold and Italic begin tags <b><I> BoldItalEnd() Returns/writes wrapper for Bold and Italic end tags </I></b> BoldULineBeg() Returns/writes wrapper for Bold and UnderLine begin tags <b><u> BoldULineEnd() Returns/writes wrapper for Bold and UnderLine end tags </U></b> Br() Returns/writes HTML Line Break tag <br> Button() Returns/writes a Button form-object using HTML Input tag CenterBeg() Returns/writes HTML Center begin tag <Center> CenterEnd() Returns/writes HTML Center end tag </Center> 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 <font.> FontEnd() Returns/writes HTML Font end tag </font> FormBeg() Returns/writes HTML Form begin tag and attributes <form ... > FormEnd() Returns/writes HTML Form end tag </form> headBeg() Returns/writes HTML head begin tag <head> headEnd() Returns/writes HTML head end tag </head> header() Returns/writes required context-header HiddenFld() Returns/writes HTML Hidden Input Text field HR() Returns/writes HTML horizontal line tag <HR> htmlAlert() Writes Javascript Alert Box HtmlBeg() Returns/writes HTML begin tag <html> HtmlEnd() Returns/writes HTML end tag </html> 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 <IMG ... > Input() Returns/writes HTML INPUT form tag ItalicsBeg() Returns/writes HTML Italics Begin tag <I> ItalicsEnd() Returns/writes HTML Italics end tag </I> JavaScrBeg() Returns/writes Javascript language begin script JavaScrEnd() Returns/writes Javascript language end script LI() Returns/writes HTML Line Item tag <LI> ListBox() Writes wrapper for Select/Option tags Marquee() Returns/writes scrolling message - MSIE only Olbeg() Returns/writes HTML Ordered List begin tag <OL> Olend() Returns/writes HTML Ordered List end tag </OL> Option() Returns/writes HTML Option tag <Option ... > Password() Returns/writes HTML Password Input form field pBeg() Returns/writes HTML New Paragraph tag <p> pEnd() Returns/writes HTML New Paragraph end tag </p> PreBeg() Returns/writes HTML Pre begin tag <Pre> PreEnd() Returns/writes HTML Pre end tag </Pre> Problem() Writes wrapper Problem message page PubVars() Creates public variables for all form-variables Radio() Returns/writes HTML Radio Input button SelectBeg() Returns/writes HTML Select begin tag <Select> SelectEnd() Returns/writes HTML Select end tag </Select> Small() Returns/writes wrapper Small font tag <Small> Spacer() Returns/writes HTML Spacer tag - Netscape only StopWrite() Toggles HTML write to standard-out ( on/off ) StrikeOut() Returns/writes wrapper for Strike tag <s> StrongBeg() Returns/writes HTML Strong begin tag <Strong> StrongEnd() Returns/writes HTML Strong end tag </Strong> SUBbeg() Returns/writes Subscript begin tag <SUB> SUBend() Returns/writes Subscript end tag </SUB> Subscript() Returns/writes wrapper for Subscript font SUPbeg() Returns/writes HTML Superscript begin tag <SUP> SUPend() Returns/writes HTML Superscript end tag </SUP> Superscript() Returns/writes wrapper for Superscript font TableBeg() Returns/writes HTML Table begin tag <TABLE...> TableEnd() Returns/writes HTML Table end tag </TABLE> TableData() Writes wrapper for a complete Table Tdbeg() Returns/writes HTML Table Data begin tag <TD> Tdend() Returns/writes HTML Table Data end tag </TD> Text() Returns/writes HTML Text Input form-object tag TextArea() Returns/writes HTML TextArea form-objectt tag Thbeg() Returns/writes HTML Table Header begin tag <TH> Thend() Returns/writes HTML Table Header end tag </TH> TitleBeg() Returns/writes HTML Title begin tag <Title> TitleEnd() Returns/writes HTML Title end tag </Title> Trbeg() Returns/writes HTML Table Record begin tag <TR> Trend() Returns/writes HTML Table Record end tag </TR> Ttbeg() Returns/writes HTML TeleType/TypeWriter begin tag <TT> Ttend() Returns/writes HTML TeleType/TypeWriter end tag </TT> Ulbeg() Returns/writes HTML Unordered List begin tag <UL> Ulend() Returns/writes HTML Unordered List end tag </UL> UlineBeg() Returns/writes HTML Underline begin tag <U> UlineEnd() Returns/writes HTML Underline end tag </U> VbScrBeg() Returns/writes VB script language begin tag VbScrEnd() Returns/writes VB script language end tag xEnv() Fills array with server environment variables

Learning the ClipX commands and integrating them into CA-Clipper programs 
usable for CGI was very easy and the support was very good. If you are 
thinking about expanding your market, take a look here and see if it offers 
you what you need.


Contact information:

Intrasys International, Inc.
  OR
http://www.intraSYScorp.com