Save this page as skeleton.mv ======================================================================== The script below demonstrates one method of building a modular "multi-option" script. The script does nothing useful beyond serving as an extremely simplified working example of this type of program structure. [Note: this file has been revised to remove macros, in preparation for Miva v4] The first section of code is the only one that is processed each time the script runs. It provides an HTML header and footer and builds a menu of links to the various options available to the script user. These links call the script using a "POST" method to pass the option name which is also the name of a function in the script. The name is tested for validity then control is passed to the named function through the use of a "macro'd" function call. There are two basic types of option/function available in ANY script. Those which require further user input and those which don't. This script presents both types. The My_home() and Sleep/Wakeup() functions do not require user input. The Feedme() function requires user input which is acquired through FORMs and passed through hidden inputs. Note that no global variable other than 'action' (the option/function name) is used in this section of code. You may of course use global variables in this section of code and in the various functions if you wish but they are not required. Also note that the main options/functions can not use PARAMETERS to receive information. All data must be passed through global variables, hidden inputs or on the URL line. ========================================================================
My_Home Feedme _____"Toggle Switch" Link_____ Sleep Wakeup Wakeup Sleep _____End of "Toggle Switch" Link_____
_____Functions_____ Do_Actions ======================================================================== This function acts as a processing dispatcher by passing control to the function named in the "action" global variable. The result from that "action" function is then sent back via MvFUNCRETURN for evaluation by the calling code, above. Note it isn't necessary for the "action' function to actually return data (see the My_Home function). Its okay for the function to only output html to the browser and return no data. ======================================================================== My_Home ======================================================================== This function outputs a string then passes control to the System_Variables() function which also outputs some html then control is passed back to the do_actions() dispatcher. ======================================================================== Feedme ======================================================================== This function requires 3 passes (2 user input and 1 display) to complete. The current pass number is contained in the 'tracno' variable. It also demonstrates use of the built-in Miva function fexists() by testing the existence of the lock.txt file produced by the Sleep() function. ======================================================================== Thank you, I love ' $food$ '. How much can I have?'}"> Sleep ======================================================================== This function builds the lock.text file by using the MvEXPORT tag. Since lock.txt is an empty file neither the FIELDS= nor DELIMITER= attributes need to contain values but Miva requires that they exist. MvFUNCRETURN is again used to pass back a string to the do_actions() dispatcher. ======================================================================== Wakeup ======================================================================== This function uses the built-in Miva function fdelete() to delete the lock.text file built by the Sleep() function. Note that this function can never be accessed unless the lock.txt file exists due to the way the " toggle switch" link in the main script was coded. ======================================================================== System_Variables ======================================================================== This function builds preformatted HTML code displaying various system and CGI environment variables and their values. The code from
 to 
(inclusive) may be cut-n-pasted into another script (between an appropiate HTML header/footer) which will then run on ANY version of htmlscript or Miva. The "environment" and "user" variables are standard CGI names but not all servers or browsers will provide a value for the variable. AUTH-TYPE Tells the type of authentication used if the web server supports it and the script is protected. An example of authentication may be a something like a password. CONTENT-LENGTH When your form method is "post," the data in the form is sent in one long string of characters. The CONTENT-LENGTH tells how long the string is in bytes (characters). An example of CONTENT-LENGTH: 256 bytes CONTENT-TYPE You can send many kinds of data to a script. This variable tells what kind of data it is from a list of MIME types. A sample of CONTENT-TYPE: x-www-form-urlencoded (tells the script that this data came from a WWW form) GATEWAY_INTERFACE Tells the script what version of the CGI specification is being used. As with anything in the computer world, CGI is being updated and every change makes a new version; the higher the number, the newer the version. An example of GATEWAY_INTERFACE : 1.1 PATH_INFO Gives any information that may be included in a URL in addition to the name of the script, such as extra options. PATH_TRANSLATED Contains information on where the script resides; it lists the directories, the script name, and any other information QUERY_STRING This contains the information that follows the name of a script. It often contains information that the script can use to send you where you want to go, like a search engine. If you search for a topic in a search engine, like Infoseek, it will send you to an index of pages. In the location box, after the URL and ?, you will sometimes see some words separated with +s and other characters. This is the query string and this is what is contained in QUERY_STRING. REMOTE_ADDR Contains the IP address of a visitor who is using a script. An example of REMOTE_ADDR: 6.74.105.3 REMOTE_HOST Contains the name of the computer of a visitor who is using a script. An example of REMOTE_HOST: Excelsior. REMOTE_USER Tells a script the name of the person using it. An example of REMOTE_USER: nhiemann SCRIPT_NAME Contains the immediate location of a script from the cgi-bin directory. An example of SCRIPT_NAME: /cgi-bin/myscript.cgi SERVER_NAME Gives the name or IP address of the computer on which the web server is running. SERVER_PORT Gives the port number on which the web server is waiting for requests. An example of SERVER_PORT: 80. SERVER_PROTOCOL Contains information on whatever protocol and its version number that the Web server is using. Example of SERVER_PROTOCOL: HTTP/2.0. SERVER_SOFTWARE Gives the name and version number of the Web server that called the script. An example of SERVER_SOFTWARE: APACHE/1.2b4 HTTP_ACCEPT Contains information on the types of information the visitor's web browser can display, often it is one or more of the MIME types. An example of HTTP_ACCEPT: image/gif,image/jpeg HTTP_REFERER What form in what page the data is coming. An example of HTTP_REFERER: http://www.ourpage.com/comments.html HTTP_USER_AGENT What browser and version of that browser your visitor is using. An example of HTTP_USER_AGENT: Mozilla/2.0(Windows;32bit) HTTP_FROM The e-mail address of the user sending the request. HTTP_COOKIE A list of "cookie" values on the browser of the user sending the request (specfic to your site). HTTP_PRAGMA Mode client is running under ========================================================================
Htmlscript-specific System Variables:

cgidir          = 
htsexecutable   = 
miva version    = 
documenturl     = 


Standard CGI environment variables:

http_host          = 
gateway_interface  = 
content_type       = 
content_length     = 
query_string       = 
path_info          = 
path_translated    = 
request_method     = 
script_name        = 
server_name        = 
server_port        = 
server_protocol    = 
server_software    = 
auth-type          = 

User information

referer_url      = 
remote_ident     = 
remote_addr      = 
remote_user      = 
http_user_agent  = 
http_cookie      = 
http_accept      = 
http_from        = 
http_pragma      = 
http_connection  = 

Time information

time_t    = 
tm_sec    = 
tm_min    = 
tm_hour   = 
tm_mday   = 
tm_mon    = 
tm_year   = 
tm_wday   = 
tm_yday   =