NAME

button, buttonlabel - Create a button on the HTML page

SYNOPSIS

button( label, fun )
buttonlabel(
b, label )

DESCRIPTION

button() creates a button on the HTML page with text specified by the label argument. When pressed, the function passed in as fun will execute. The function should not include parentheses or arguments. Only the name of the function should be passed in as a reference.

Like other Tranquility functions that create HTML elements, button() opens a new browser window when called if one had not previously existed.

buttonlabel() updates the text displayed on the button b with the string specified by the label argument. b should be an identifier for a button that was returned by a call to button().

Buttons will be placed on the HTML page, left to right, top to bottom in order of being called.

RETURN VALUE

button() returns a unique identifier to the newly created button.

buttonlabel() has no return value.

ERRORS

Using parentheses for the fun argument when calling button() produces a variety of unexpected behaviors.

EXAMPLES

The following example changes the label on the button randomly after each click.

var b
fun change() {
     var r
     r : random( 3 )


     if( .r == 0 ) {
          buttonlabel( .b, "Zero" )
     }
     else if( .r == 1 ) {
          buttonlabel( .b, "One" )
     }
     else {
          buttonlabel( .b, "Two" )
     }
}
fun init(){
     b : button( "Unclicked", change )
}

AUTHORS

Charlie Stuart cstuart11@protonmail.com
Amalia Sorribes, Fall 21-22
Donovan Dolan, Fall 21-22
Evan Yan, Fall 21-22
Kevin Lin, Fall 21-22
Nicolo Agbayani, Fall 21-22
Nicholas Ingravallo, Fall 21-22

REPORTING BUGS

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

SEE ALSO

tranqc(1), html(3)

Tranquility Programmer’s Manual
https://www.cs.drexel.edu/~bls96/tranquility.pdf