NAME

i2s - Produce the base-10 string represenation of an integer

SYNOPSIS

i2s( str, n )

DESCRIPTION

i2s() produces a string that contains the decimal (base-10) representation of the integer value n passed as the second argument. The first argument str should be the address of a block of memory large enough to contain the resulting string and its null terminator.

i2s() is necessary to display variable values on the HTML pop up window with the html(3), label(3), and table(3) functions.

RETURN VALUE

i2s() does not have a return value.

EXAMPLE

The following example from page 7 of the Tranquility Programmer’s Manual
https://www.cs.drexel.edu/~bls96/tranquility.pdf creates a table of factorials.

fun fact(n) {
     if .n == 0 {

     }
     else {
          return .n * fact(.n - 1)
     }
}

fun genfacts(n) {
     var i, ftab

     ftab : alloc(.n)
     i : 0
     loop {
          until .i >= .n
          (.ftab + .i) : fact(.i)
          i : .i + 1
     }
     return .ftab
}

fun filltable() {
     var i, ftab, istr

     html("<center>0)
     html("<table border=1><tr><th>n</th><th>n!</th></tr>0)
     ftab : genfacts(13)
     istr : alloc(12)
     i : 0
     loop {
          until .i > 12
          html("<tr><td>")
          i2s(.istr, .i)
          html(.istr)
          html("</td><td>")
          i2s(.istr, .(.ftab + .i))
          html(.istr)
          html("</td></tr>0)
          i : .i + 1
     }
     html("</table></center>0)
}


fun init () {
     html("<center>")
     button("Make Table", filltable)
     html("<p>Factorials</p>0/center>0)
}

AUTHORS

Charlie Stuart cstuart11@protonmail.com
Lam Nguyen, 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), makelabel(3), setlabel(3), setcell(3)

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