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:
Log to the www account.
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 |
Compile and catalog the application. For example:
compile-catalog bp IHello (O |
At TCL in the www account:
Use the m command to display the FlashConnect Main Menu.
Select the Maintain FlashConnect Applications option.
Select the Update a w3Apps item option.
Add the IHello application as below:
Application IHello Desc A slightly more rude Hello World type application. Anon y |
NOTE |
Experiment with the effect of the Users and Group attributes. |
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:
There are several subroutines used to facilitate building HTML elements such as forms and input prompts. Any time a new form is built for a dynamic application, it is advisable to use the w3HtmlFormBeg() subroutine. This routine correctly sets up elements (such as the form's action property) and passes several hidden variables used internally by FlashConnect.
There are several subroutines for generating HTML inputs. For example:
w3HtmlText() generates a text box.
w3HtmlSubmit() generates a submit button.
Note that each Web page ends with a call to w3Input. This subroutine waits here for user input, much like a BASIC input statement.
See Also