## Demo 2

Demo 2 shows using subroutine 4000 to put run time data on an HTML page. demo2.html is almost identical to demo1.html except demo2.html added a 3rd button called Next.
Following is the contents of the demo2.html:

    <html>
    <head>
    <title>This is DEMO 2</title>
    </HEAD>

    <body>
    <H2> DEMO 2</h2>
    <p> This demo shows how to use the subroutine 4000 from a Load HTML created program to add run time data
    <form method="post" action="FORMINPUT">
      <B>Enter String: </b><input TYPE="Text" NAME="STRING" SIZE=40 VALUE="????STRING"><BR><br>
      <B>Check or Uncheck this checkbox</b><br>
      <B>Check Box: </b><input type="Checkbox" value="CHECKED" name="CHECKBOX" ????CHECKED><BR>
      <BR>
      <input type="submit" name="CANCEL" value="Cancel">
      <input type="submit" name="DOIT" value="  Do It  ">
      <input type="submit" name="NEXT" value="  Next  ">
    </form>
    </body>
    </html>

Note the "????STRING" and the "????CHECKED" these are what subroutine 4000 replaces before the page is displayed.
The Load Html Utility creates the program D_DEMO2 from demo2.html.
The following program DEMO2 tests the D_DEMO2 program:

    10 REM "DEMO2"
    100 REM 100,5
    105 LET I=1
    110 PRINT 'gwin'("WEB"),
    115 DIM P!
    120 LET S$="Run Time Data #"+STR(I)+" BOX is "
    125 IF MOD(I,2)=0 THEN LET C$="",S$=S$+"UNCHECKED" ELSE LET C$="CHECKED",S$=S$+"CHECKED"
    130 CALL "D_DEMO2",P![ALL],S$,C$
    135 REM "Don't accept Enter as end of input"
    140 IF P!["CANCEL"]="" AND P!["DOIT"]="" AND P!["NEXT"]="" THEN LET P!["FLAG"]="NoDisplay";GOTO 0130
    145 PRINT "The Program D_DEMO2 returned because:"
    150 IF P!["CANCEL"]<>"" THEN PRINT "Cancel button was hit"
    155 IF P!["DOIT"]<>"" THEN PRINT "Do It button was hit"
    160 IF P!["NEXT"]<>"" THEN PRINT "Next button was hit"
    165 PRINT ""
    170 PRINT "The textbox contains:"+$22$+P!["STRING"]+$22$
    175 PRINT "The Check Box is ",
    180 IF P!["CHECKBOX"]<>"" THEN PRINT "Checked" ELSE PRINT "Unchecked"
    185 IF P!["NEXT"]<>"" THEN LET I=I+1;GOTO 0115
    190 PRINT 'gwin'("CONSOLE"),

Demo2 passes into D_DEMO2 S$ and C$ to be used by subroutine 4000 to add run time data to the page. To make the page a little more interesting if the Next button is pressed, the page is redisplayed with slightly modified run time data.
After the 1st Load Html D_DEMO2 was modified as follows:

    130 ENTER P![ALL],S$,C$

    4000 REM 4000,5
    4005 LET P=POS("????STRING"=A$);IF P=0 THEN ESCAPE
    4010 LET A$=A$(1,P-1)+S$+A$(P+10)
    4015 LET P=POS("????CHECKED"=A$);IF P=0 THEN ESCAPE
    4020 IF C$="" THEN LET A$=A$(1,P-1)+A$(P+11) ELSE LET A$=A$(1,P-1)+A$(P+4)
    4025 RETURN

The ENTER adds the run time data variables. Subroutine 4000 replaces "????STRING" with S$ and
if C$ = "" replaces "????CHECKED" with "" else it replaces "????CHECKED" with "CHECKED".
Note that a subsequent Load Html of demo2.html will ONLY replace the html in D_DEMO2 and will not affect these code changes.
When D_DEMO2 returns P! will contain the following:

P! | Value
["url"]= | DIR(-1)+"HTML\FORMINPUT" - "FORMINPUT" is the ACTION= from the FORM tag
["STRING"]= | the contents of the text box
["CHECKBOX"]= | "" if not checked or "CHECKED" if checked - "CHECKED" is the VALUE= from the the INPUT tag
["DOIT"]= | "" if the Do It button was not pressed or " Do It " if it was - " Do It " is the VALUE= from the the INPUT tag
["CANCEL"]= | "" if the Cancel button was not pressed or " Cancel " if it was - " Cancel " is the VALUE= from the the INPUT tag
["NEXT"]= | "" if the Next button was not pressed or " Next " if it was - " Next " is the VALUE= from the the INPUT tag