Myapp

Subroutine myapp

Include wbp w3Include ;* required

Err = ""                       ;* contains error value from w3Input

Sub1=""                      ;* contains substitutions for the header

Sub2=""                      ;* contains substitutions for the body

* Housekeeping: open files and read and lock the data record.

* Once locked others cannot update the data record until the

* data record is unlocked.

New = 0

Open "Mydata" to fv else

         New = 1

         Execute "create-file Mydata 1 1"

         Open "Mydata" to fv else

              call w3Log("","Cannot open Mydata")

              return

         end

End

If new = 1 then write 1 on fv, 1

* read and lock the record being modified

readok = 1

Readvu item from fv, 1,1 locked

    readok = 0

end else

    readok = 0

end

if not(readok) then

    call w3HtmlInit("Myapp", "")

    Sub1<1,1> = "##TITLE##"

    Sub1<1,2>="MyApp record locked"

    Sub1<2,1>="??HEADLINE??"

    Sub1<2,2>="MyApp is being used"

    Call w3HtmlHeader("",Sub1)             ;* perform the subsitution

    call w3Printn("<P>To demonstrate the locking capabilities of")

    call w3Printn("FlashCONNECT, MyApp was written as a program which")

    call w3Printn("is used by one person at a time. Right now someone")

    call w3Printn("else is using the application.")

    call w3Printn("Please try again in a few minutes")

    Call w3HtmlFooter("","")

    w3ClosingPage = ""

    release fv, 1

    return

end

Call w3HtmlInit("Myapp","")             ;* set the heading and footing

* set up the substitution array for the header

Sub1<1,1> = "##TITLE##"

Sub1<1,2>="MyApp title"

Sub1<2,1>="??HEADLINE??"

Sub1<2,2>="A simple FlashCONNECT demonstration"

Call w3HtmlHeader("",Sub1)             ;* perform the subsitution

Call w3HtmlFormBeg("","")              ;* start a form

* setup the substitution array for the body, then insert it into the Web page

Sub2<1,1> = "!!VALUEHERE!!"

Sub2<1,2>=item

call w3HtmlInsert("Myapp.body", Sub2)

call w3HtmlFormEnd                    ;* End the form

call w3HtmlFooter("","")              ;* move the footing into the Web page, no substitutions

call w3Input(Err, 120, "")             ;* send the Web page and wait for a response

* code continues here after a timeout or the user submits a reply

if Err = w3_OK then                     ; * verify no errors

* get the value returned by the user, reuse the item variable

   call w3GetVal(item, "USERSSTRING")

* write the new value back into the database and release the record lock

   writev item on fv, 1, 1

end else

* process the error

   release fv, 1

end

close fv

return