sample(Entry) for cgictrl-0.1
samp_calc_entry_e.html(View definition)
#
# View for entry 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(Entry)</title>
</head>
<body>
<div align="center"><h1>Caluculate area of circular and volume of ball(Entry)</h1></div>
<form method="post" action="./cgictrl.cgi">
<input type="hidden" name="SYS_sessionid" value="@{SYS_sessionid}@">
Radius ? : <input type="text" name="hankei" value="@{hankei}@"> (cm)
<input type="submit" name="next" value="Next">
</form>
<div>
<font color="@{msg_color=black}@">@{msg}@</color>
</div>
</body>
</html>
samp_calc_entry_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 ---
html_param = {}
html_param["hankei"] = cc.get_spa("hankei")
if (cc.get_spa("err_sw") == "ER01")
html_param["msg_color"] = "red"
html_param["msg"] = "Please input number."
end
cc.out_html("samp_calc_entry_e", html_param)
return "SAMP_CALC_ENTRY_E"
#--- user coding end ---
end
#
# Process input data
#
def sub_recieve(cc)
#--- user coding start ---
cc.set_spa("err_sw", "")
r = cc.get_input("hankei")
r.strip!
if (/^[+-]*[0-9\.]+$/ !~ r)
cc.set_spa("err_sw", "ER01")
end
cc.set_spa("hankei", r)
if (cc.get_spa("err_sw") == "")
return "SAMP_CALC_RESULT_E"
else
return "SAMP_CALC_ENTRY_E"
end
#--- 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]