sample(Result) for cgictrl-0.1


Google

samp_calc_result_e.html(View definition)

#
# Result View definition
#
Content-Type: text/html; charset=utf-8

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Caluculate area of circular and volume of ball(Result)</title>
</head>
<body>
<div align="center"><h1>Caluculate area of circular and volume of ball(Result)</h1></div>
<form method="post" action="./cgictrl.cgi">
<input type="hidden" name="SYS_sessionid" value="@{SYS_sessionid}@">
<div>
Area of circular which have radius @{hankei}@ (cm) is @{menseki}@ cm2.
</div>
<div>
Volume of ball which have radius @{hankei}@ (cm) is @{taiseki}@ cm3.
</div>
<div>
<input type="submit" name="return" value="Return">
</div>
</form>
<div>
<font color="@{msg_color=black}@">@{msg}@</color>
</div>
</body>
</html>

samp_calc_result_e.cgi(CGI program)

#! /usr/bin/ruby
#
# cgictrl ver.0.1 2009.07.07 Masahiko Ito <m-ito@myh.no-ip.org>
#
#   User coding sample script
#
require "cgi"
require "uri"
require "nkf"
require "cgictrl_common"
#--- user coding start ---
#--- user coding end   ---
#
# Main
#
def main()
	cc = Cgictrl.new
	cc.start(cc.default_nkf_param)
	sub_open(cc)
	if (cc.is_send())
		next_tran = sub_send(cc)
	else
		next_tran = sub_recieve(cc)
	end
	sub_close(cc)
	cc.end(next_tran)
	exit 0
end
#
# Open
#
def sub_open(cc)
#--- user coding start ---
#--- user coding end   ---
end
#
# Edit/Output View
#
def sub_send(cc)
#--- user coding start ---
	pi = 3.14
	html_param = {}
	html_param["hankei"] = cc.get_spa("hankei")
	html_param["menseki"] = pi * cc.get_spa("hankei").to_f ** 2
	html_param["taiseki"] = 4.0 / 3.0 * pi * cc.get_spa("hankei").to_f ** 3

	cc.out_html("samp_calc_result_e", html_param)

	return "SAMP_CALC_RESULT_E"
#--- user coding end   ---
end
#
# Process input data
#
def sub_recieve(cc)
#--- user coding start ---
	cc.set_spa("err_sw", "")

	return "SAMP_CALC_ENTRY_E"
#--- user coding end   ---
end
#
# Close
#
def sub_close(cc)
#--- user coding start ---
#--- user coding end   ---
end
#
# Another user define functions
#
#--- user coding start ---
#--- user coding end   ---
#
# Start Main
#
main()

m-ito@myh.no-ip.org

[Update]