// Switch to Mata interpreter/compiler
mata:
// Drops class object if it already exists
// mata drop table()
// Definition of HTML Tag table Mata Class
// Defines a table// Information retrieved from http://www.w3schools.com/tags/tag_table.asp
class table extends htmlglobal {
// Define private member variables
private:
// Static/final variables
static string scalar opens, opene, close
// String scalar attributes
string scalar htmlalign, htmlbgcolor, htmlborder, htmlcellpadding, htmlcellspacing, htmlframe, htmlrules, htmlsortable, htmlsummary, htmlwidth
// Make class args non-static to prevent assignment of class args to all instances of class
string scalar classargs
// Define public members/methods
public:
// Class constructor method
void new()
// Setter methods
class table scalar setClassArgs(), setAlign(), setBgcolor(), setBorder(), setCellpadding(), setCellspacing(), setFrame(), setRules(), setSortable(), setSummary(), setWidth()
// Getter methods
string scalar getOpens(), getOpene(), getClose(), print(), getClassArgs(), getAlign(), getBgcolor(), getBorder(), getCellpadding(), getCellspacing(), getFrame(), getRules(), getSortable(), getSummary(), getWidth()
} // End of class declaration
// Class constructor method declaration
void table::new() {
// Defines the start of the opening tag for the class
this.opens = "
character to allow attributes
return(this.opens)
} // End of getter method for opens member of class table
// Getter method for opening bracket closing character
string scalar table::getOpene() {
// Returns the closing character for the opening bracket
return(this.opene)
} // End of getter method for opene member of class table
// Getter method for closing bracket
string scalar table::getClose() {
// Returns the closing bracket/tag
return(this.close)
} // End of getter method for close member of class table
// Getter method for class arguments
string scalar table::getClassArgs() {
// Returns the class arguments that appear between the HTML tags
return(this.classargs)
} // End of getter method for class arguments member of class table
// Getter method for align member variable
string scalar table::getAlign() {
// Returns the align variable
return(this.htmlalign)
} // End of getter method for align member of class table
// Getter method for bgcolor member variable
string scalar table::getBgcolor() {
// Returns the bgcolor variable
return(this.htmlbgcolor)
} // End of getter method for bgcolor member of class table
// Getter method for border member variable
string scalar table::getBorder() {
// Returns the border variable
return(this.htmlborder)
} // End of getter method for border member of class table
// Getter method for cellpadding member variable
string scalar table::getCellpadding() {
// Returns the cellpadding variable
return(this.htmlcellpadding)
} // End of getter method for cellpadding member of class table
// Getter method for cellspacing member variable
string scalar table::getCellspacing() {
// Returns the cellspacing variable
return(this.htmlcellspacing)
} // End of getter method for cellspacing member of class table
// Getter method for frame member variable
string scalar table::getFrame() {
// Returns the frame variable
return(this.htmlframe)
} // End of getter method for frame member of class table
// Getter method for rules member variable
string scalar table::getRules() {
// Returns the rules variable
return(this.htmlrules)
} // End of getter method for rules member of class table
// Getter method for sortable member variable
string scalar table::getSortable() {
// Returns the sortable variable
return(this.htmlsortable)
} // End of getter method for sortable member of class table
// Getter method for summary member variable
string scalar table::getSummary() {
// Returns the summary variable
return(this.htmlsummary)
} // End of getter method for summary member of class table
// Getter method for width member variable
string scalar table::getWidth() {
// Returns the width variable
return(this.htmlwidth)
} // End of getter method for width member of class table
// Get the HTML tag w/attributes and arguments
string scalar table::print() {
// Create local variables to piece together return string
string scalar open, args, close
// Create opening string
open = getOpens() + getAlign() + getBgcolor() + getBorder() + getCellpadding() + getCellspacing() + getFrame() + getRules() + getSortable() + getSummary() + getWidth() + globalAttrs() + getOpene()
// Get class arguments
args = getClassArgs()
// Get closing tag
close = getClose()
// Return the complete HTML string
return(char((10)) + subinstr(open, " >", ">") + args + close + char((10)))
} // End of print method for class table
// End of Mata session
end