A WAP application |
Try online | Examples |
Remember the age in seconds
example? Well, here's the same as a WAP application!
WML, the language understood by WAP phones is a bit
fussier than HTML, so make sure you put everything
where it should be, expecially the headers.
A good place to start for WAP is:
http://www.wapforum.org/
Here is how to calculate your age in seconds on your wap phone.
Provided you were born after January 1st, 1970...
Here's what the WML looks like:
<?xml version="1.0"?> <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml"> <wml> <card id="form1"> <p>Day: <input name="day" type="text"/> Month: <input name="month" type="text"/> Year: <input name="year" type="text"/> </p> <do type="accept" name="Done"> <go href="/cgi-bin/aptilis.exe" method="get"> <postfield name="day" value="$day"/> <postfield name="month" value="$month"/> <postfield name="year" value="$year"/> <postfield name="file" value="/home/scripts/age_wml.e.txt"/> </go> </do> </card> </wml>
And now, the Aptilis programme...
sub main
print("Content-type: text/vnd.wap.wml\r\n\r\n")
// The next line is just to be tidy.
clearArray(ta[])
ta[3] = day
ta[4] = month
ta[5] = year
if ta[5] < 100
// For years entered as 'yy' instead of '19yy'
ta[5] = ta[5] + 1900
end if
// This is important - don't omit it
print("<?xml version=\"1.0\"?>\n")
print("<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\" \"http://www.wapforum.org/DTD/wml_1.1.xml\">\n")
print("<wml>\n<card id=\"answer\">\n\n")
print("<p>your age in seconds is: ")
age = dotime(ta[])
tn = gettime()
print(int(tn - age)$)
print(" - http://www.aptilis.com/")
print("</p>\n</card>\n</wml>\n")
end main
See also:
dotime,
gettime.
Things learnt