MATLAB Web Server Previous page   Next Page
htmlrep

Substitute values for variable names in HTML document

Syntax

Description

htmlrep(instruct,infile) replaces all MATLAB variables in infile, an HTML document, with corresponding values of variables of the same name in instruct. Variables can be character strings, matrices, or cell arrays containing strings and scalars. String and scalar variables are replaced by straight substitution. Output is returned in outstring. Variable names in infile must be enclosed in dollar signs, e.g., $varname$.

outstring = htmlrep(instruct,infile,outfile) additionally writes output to the HTML document outfile (for stand-alone testing).

instruct is a MATLAB structure containing variable names (field names) and corresponding values.

infile is an HTML template file with MATLAB variable names enclosed in dollar signs.

outfile is the name of an output file for optional standalone testing.

outstring = htmlrep(instruct,infile,outfile,attributes) provides additional directives to htmlrep. The third argument in this form of the command must be present for the attributes argument to be recognized. Use an empty string ' ' for the third argument if you do not want to direct output to a file. The attributes argument is a MATLAB string (enclosed in ' ') with the listed attributes separated by spaces.

Two attributes are allowed.

noheader
Suppresses the output of the HTML header 'Content-type: text/html\n\n' to outfile and outstring.
extendmemory
Enables dynamic memory extension beyond 256 KB.

HTML tables and select lists can be generated dynamically from matrices or cell arrays containing strings and scalars:

  1. Tables can be generated using the special MATLAB AUTOGENERATE HTML table attribute with the matrix or cell array name as the value. For example, the following code automatically generates all the HTML needed to display the entire matrix, msquare, in an HTML table.

At least one of each of the tags listed above is required.

htmlrep uses the HTML code from the <TABLE> tag to the </TABLE> tag as a template for generating the entire table. If different column attributes are required, additional pairs of cell tags (<TD> and </TD>) can be included up to the number of columns in the matrix or cell array. For example, adding these tags

after the </TD> tag above causes the second column to be center-justified.

If there are more columns in the matrix or cell array than <TD> </TD> pairs, the last pair is used for all subsequent columns.

  1. SELECT lists are generated using the special MATLAB AUTOGENERATE HTML SELECT attribute with the vector, matrix or cell array name as the value. For example, the following code automatically generates all the HTML needed to display the entire vector, mylist, in an HTML SELECT list. (SELECT lists must appear inside HTML <FORM> and </FORM> tags.)

htmlrep uses the HTML code from the <SELECT> tag to the </SELECT> tag as a template for generating the entire SELECT list. One of each of the tags shown above is required.

If mylist is a matrix or cell array, htmlrep uses only the first column vector to construct the select list.


Previous page  Functions - Alphabetical List matweb Next page