HelloWorld Code Example - A Dynamic Web Application

This is a FlashConnect dynamic application example that asks the user some questions and displays a result.

To create and run the dynamic sample application:

  1. Log to the www account.

  2. Create a new subroutine in the bp file called IHello:

subroutine IHello

include www,wbp, w3include

* Get the User's name

call w3HtmlInit('simple',"")

call w3HtmlHeader('','') ;* Start the page

call w3HtmlFormBeg("","") ;* Begin a form

call w3Print("Enter your name:")

call w3HtmlText('Name','','') ;* Prompt for "Name"

call w3HtmlSubmit('','OK','') ;* Add a submit button

call w3HtmlFormEnd ;* End the form

call w3HtmlFooter('','') ;* End the page

call w3Input(err,3600,'') ;* Wait 1 hour for answer

if err # w3_OK then return ;* Timed out, just exit

call w3GetVal(Name,"Name") ;* Get the user's name

* Get the user's Birth date

call w3HtmlInit('simple',"")

call w3HtmlHeader('','') ;* Start the page

call w3HtmlFormBeg("","") ;* Begin a form

call w3Print(Name:" Please enter your birth date: ")

call w3HtmlText('Bdate','','') ;* Prompt for "Bdate"

call w3HtmlSubmit('','OK','') ;* Add a submit button

call w3HtmlFormEnd ;* End the form

call w3HtmlFooter('','') ;* End the page

call w3Input(err,3600,'') ;* Wait 1 hour for answer

if err # w3_OK then return ;* Timed out, just exit

call w3GetVal(dob,"Bdate") ;* Get the user's DOB

* Tell the user how old he or she is

call w3HtmlInit('simple',"")

call w3HtmlHeader('','') ;* Start the page

days = date()-iconv(dob,'d')

call w3Print(Name:", you are ":days:" days old. (Yikes!)")

call w3HtmlFormBeg("","")

call w3HtmlSubmit('','OK','')

call w3HtmlFormEnd

call w3HtmlFooter('','') ;* End the page

call w3Input(err,3600,'') ;* Wait 1 hour for answer

* And we're done

return

  1. Compile and catalog the application. For example:

compile-catalog bp IHello (O

  1. At TCL in the www account:

Application IHello

Desc A slightly more rude Hello World type application.

Anon y

 

NOTE

Experiment with the effect of the Users and Group attributes.

  1. Run the IHello application by navigating to this URL:

http://your.machine/cgi-bin/fccgi.exe?w3exec=IHello&w3ClosingPage=/w3library

Several new concepts are introduced with this application:

See Also

Sample FlashConnect Code Examples

HelloWorld - A Static Web Application