SUBROUTINE TAG_A
* Demonstrate the RWA_TAG subroutine.

* Include the RealWeb definitions
INCLUDE #RW.INCLUDE.DEFS FROM /SYSFILES/REALWEB,BP

EQU LF TO CHAR(10)

* Start the HTML page.
CALL RW_START_HTML_PAGE("RWA_TAG Example", "", "", "", "")

HTML = ""

* Insert a paragraph containing some text.
CALL RW_START_PARA("", "")
CALL RW_PUT("The following example shows how to check that a " : ...
"function is invoked with the correct number of " : ...
"parameters, since JavaScript doesn't do this for you:")
CALL RW_END_PARA

* Insert the JavaScript example, with green comments.
CALL RW_FIXED_ON
CALL RW_PUT("function f(x, y, z) {" : LF)
* Define a JavaScript comment.
CODE = " "
CMT = "// First check that the right number of parameters were passed."
* Make it green, using the span tag and the style attribute.
CALL RWA_TAG(CODE, "span", CMT, 'style="color: green"')
CALL RW_PUT(CODE : " if (arguments.length != 3) {" : LF : ...
" alert('function f called with ' + arguments.length + " : LF : ...
" 'parameters - 3 parameters expected.');" : LF : ...
" return null;" : LF : ...
" }" : LF)
* Define another green JavaScript comment.
CODE = " "
CMT = "// Now do the actual function..."
CALL RWA_TAG(CODE, "span", CMT, 'style="color: green"')
CALL RW_PUT(CODE : "}")
CALL RW_FIXED_OFF

* Complete the page.
CALL RW_END_PAGE
RETURN