maketable, setcell, setcellcolor - create an HTML table
maketable(
r, c, f )
setcell( t, r,
c, s )
setcellcolor( t, r,
c, color )
maketable() creates a table with r rows and c columns and returns an integer table identifier. The function specified by optional argument f will execute each time a user clicks on a cell. f will have the row and column of the clicked cell passed to it as arguments.
setcell() sets the contents of the cell at row r and column c in the table specified by t to the string specified by s. r and c are indexed at 0. The table specified by t should be a value returned by an earlier call to maketable().
setcellcolor() sets the background color of the cell at row r and column c in the table specified by t to the value specified by the color string argument. r and c are indexed at 0. The table specified by t should be a value returned by an earlier call to maketable().
The
color string should take a color in a CSS readable
form.
This includes:
RGB values ("rgb( R, G,
B)")
Hexadecimal values ("#RRGGBB")
Color Names ("Red")
A full list of the 140 browser recognizable color names can be found at https://charlierose.dev/cs164/numbers/colors.html
maketable() returns an integer table identifier.
setcell() and setcellcolor() do not have return values.
A tic tac toe example:
var table, xos
fun makemove( r, c ) {
if( .(xos + (.i * 3) + .j) == 0 ) {
setcell( .table, .i, .j, "X" )
setcellcolor( .table, .i, .j, "blue" )
.(xos + (.i * 3) + .j ) : 1
}
else if( .(xos + (.i * 3) + .j) == 1 ) {
setcell( .table, .i, .j, "O" )
setcellcolor( .table, .i, .j, "yellow" )
.(xos + (.i * 3) + .j ) : 2
}
else {
setcell( .table, .i, .j, " " )
setcellcolor( .table, .i, .j, "white" )
.(xos + (.i * 3) + .j ) : 0
}
}
fun init() {
var i, j
table : maketable( 3, 3, makemove )
xos : alloc( 9 )
i : 0
loop {
until .i == 3
j : 0
loop {
until .j == 3
setcell( .table, .i, .j, " " )
setcellcolor( .table, .i, .j, "white" )
.(xos + (.i * 3) + .j ) : 0
}
}
}
Charlie Stuart
cstuart11@protonmail.com
Irvin Fenochio, Fall 21-22
M M Farhan Salaheen Hossain, Fall 21-22
Shivang Patel, Winter 21-22
First, check
the Tranquility Programmer’s Manual
https://www.cs.drexel.edu/~bls96/tranquility.pdf
If the problem persists see Dr. Stuart or Charlie Stuart
Dr. Stuart:
brian.l.stuart@drexel.edu
Charlie Stuart:
cstuart11@protonmail.com
tranqc(1), html(3)
Tranquility
Programmer’s Manual
https://www.cs.drexel.edu/~bls96/tranquility.pdf