![]() |
|
ScriptDev page programming is under preparation in ScriptDev Html pages based on the application, and dynamic page (ASP / PHP / JSP, etc.) similar to some of the concept, different from the dynamic pages are web-based applications, dynamic page script In running the server side, generated by a server-side scripting WEB pages to the client after the visit. ScriptDev page programming is run entirely on the client side of a dynamic pages, ScriptDev from a client's script (currently only supports Tcl script) directly in client generated pages, and then ScriptDev in here. This client the benefits of dynamically generated pages can not spend much energy to the preparation of various complex interface, but the pages are used to express various forms of interface, because Html pages very rich, to meet the various Complex interface needs, and the interface style reunification, as can be done to make the page as the interface is very nice, very easy to modify, the workload compared to C++, should be smaller.
ScriptDev pages of the principles of programming through Html template and user data to generate pages and pages need to generate a template file, the user script, user data, page generator parts to match completed.Html template file is the template pages, generally by Web developers to create a prototype pages, and then transform the prototype pages as a template, the transformation is in accordance with the requirements of ScriptDev page templates increase in the number of pages in a special tag .User data may be derived from users of a database or other places, such as a log pages application, the user data is log database, the database can read and write operations, including ADO, ScriptDev in a package Tcl the ADO module, can facilitate the adoption of Tcl script to access various databases.The script will be responsible for templates and user data combined, the page generator is responsible for generating the final pages.
Note: ScriptDev V2.0 of the page program has been optimized, the use of TclFace extension, instead of the original programming, so that pages programming more convenient, the use of specific TclFace html directory please refer to the number of pages script source code .Below is the introduction V1.1 version of the method, for reference purposes only.
Generally speaking counterparts of the two pages of a template file, suffixes are .Tph and .Tpf, .Tph document is transformed prototype pages of documents, generated pages in tph document is based on the replacement of some of these tags , Tpf document is marked to replace some of the collection, storage is a marker for each corresponding section of the replacement text, which can also replace the text there are other tags, in fact if not tpf document is feasible, but that we should replace the content Generation wrote the script, flexibility will be reduced, because if tpf wrote in the document, as long as the modified tpf replace the contents of the document, you can modify generated pages style.
tph document format to replace the tag "%tag name%", which is surrounded by two percent a name tag, for example, the following paragraph in% TABLE_ALL%:
<TABLE cellSpacing=0 cellPadding=5 width="100%" border=0> %TABLE_ALL% </TABLE>
tpf documents for the replacement of each of the paragraphs [replacement] ... content ...[/replacement] to that at all between the replacement of the Notes can be, a footnote format for the '#' beginning of the text, such as Below is a section of this document tpf a replacement, the replacement called TR_VAR_LINE, and which also can replace the tags:
# For the variables that will form [TR_VAR_LINE] <TR> <TD class=text_all bgColor=#ffffff>%NAME%</TD> <TD class=text_all bgColor=#ffffff>%VALUE%</TD> </TR> [/TR_VAR_LINE]
Can make reference to FtpClient demonstration projects in the FTP page template file.
Pages generator as a iTcl class, class defined as follows:
#------------------------------------------------------------- # TPageMake class define #------------------------------------------------------------- ::itcl::class TPageMake { constructor {targetHtml templateHtml templateFile} {}; destructor {}; ### data member ### private variable _targetHtml; #Goals pages private variable _templateHtml; #Template pages private variable _templateFile; #Template file private variable _tclTr; #Storage Tr the Tcl internal variables private variable _targetVarList;#Storage target pages in all the variables ### public methods ### #Add a form of tag to the internal variables _tclTr public method AppendItemFromTpf {tagTr {names ""} {values ""}} #Tag of storage to the target in the buffer zone public method SaveToTargetBuf {tagTr {cleartag "-cleartag"}} #Replacement goal buffer zone in a tag public method ReplaceTargetTr {tagTr replaceTr} #Creating goals pages public method MakeTargetHtml {} #Goals from page to read all the variable information public method LoadTargetHtmlVar {} #Will be designated variable information write to the goal buffer zone public method SaveTargetVar {varName varValue} #Get to the designated target pages in the value of variables public method GetTargetVar {varName} }
Constructors are three parameters, namely to generate the target page document, tph documents and tpf documents. In addition to a number of functions used to generate pages, this category there are still some function to access the goal of pages stored in a number of variables, these variables stored in html file in the Note, this is not any of the pages of , Is provided in the pages of the variables in the storage method, because such programming pages, pages created the role of the script, create a page once completed, will be the end of the script, the script interpreter in the internal State information, and other variables will be the end of the script with the disappearance of the next generation of script pages to call when you will not be able to remember the previous information, but sometimes we do need to get prior information, such as FTP application to remember FTP address and the last visit path, it has provided in the pages of such variables in the preservation of the way in the script before the end of the variables stored in the target pages in the Note, after the next script can be activated from the pages Read the last storage of information.Storage format of the variables are as follows:
<!-- varName=varValue -->
Below is a page of the Application Programming, tph template file are as follows:
<HTML><HEAD><TITLE>Form demo</TITLE> <BODY> <TABLE> %TABLE_ALL% </TABLE> </BODY> </HTML>
%TABLE_ALL% of which is for the replacement of the tag, this example tph document has revealed a form of the framework, as long as the content can be filled, so our aim is to replace %TABLE_ALL% for a table of contents.
tpf template file are as follows:
# Forms the subject line [TABLE_WITH_TITLE] <TR> <TD>%COL1%</TD> <TD>%COL2%</TD> </TR> %ROW% [/TABLE_WITH_TITLE] # Form line [TABLE_ROW] <TR> <TD>%COL1%</TD> <TD>%COL2%</TD> </TR> [/TABLE_ROW]
There are two replacement, the forms are the title and content.
Generation script examples are as follows:
source "$platform_path/lib/plat/pagemake.tcl"; #------------------------------------------------------------- # main #------------------------------------------------------------- if {[itcl_info objects pageMake -class TPageMake] != "pageMake"} { set _htmlCurrentFile "$platform_path/Samples/page/demo1.htm" TPageMake pageMake "$_htmlCurrentFile" \ "$platform_path/Samples/page/demo1.tph" \ "$platform_path/Samples/page/demo1.tpf"; } # Create a header row set value [list "column1" "column2" "%TABLE_ROW%"]; pageMake AppendItemFromTpf "TABLE_WITH_TITLE" {"COL1" "COL2" "ROW"} $value; pageMake SaveToTargetBuf "TABLE_ALL" -append; # To create a table set value [list "1-1" "1-2"]; pageMake AppendItemFromTpf "TABLE_ROW" {"COL1" "COL2"} $value; set value [list "2-1" "2-2"]; pageMake AppendItemFromTpf "TABLE_ROW" {"COL1" "COL2"} $value; pageMake SaveToTargetBuf "TABLE_ROW"; # Storage to the buffer zone pageMake SaveToTargetBuf "TABLE_ALL"; # Generation pages pageMake MakeTargetHtml; # Release Generator ::itcl::delete object pageMake; ::itcl::delete class TPageMake; # Setting page transfer set _htmlNewURL "$platform_path/Samples/page/demo1.htm";
Finally create pages as follows:
column1 | column2 |
1-1 | 1-2 |
2-1 | 2-2 |