More Aptilis |
Try online | Examples |
To progress a bit in Aptilis, here is how to
calculate your age in seconds. Provided you were born
after January 1st, 1970...
Here's what the HTML looks like:
<FORM action="!(_AptilisURL)" method="POST"> <INPUT type="hidden" name="file" value="!(_ScriptsRepository)age.e.txt"> The day you were born:<BR> <INPUT type="text" name="day" size=10><BR> <BR> The month you were born:<BR> <INPUT type="text" name="month" size=10><BR> <BR> The year you were born:<BR> <INPUT type="text" name="year" size=10><BR> <BR> <INPUT type="submit" value="Get my age in seconds"> </FORM>
And now, the Aptilis program...
sub main
print("Content-type: text/html\n\n")
// The next line is to clear the array, however
// all variables are initialized to empty values
// anyway in Aptilis.
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
print("<HTML>\n<BODY>\n\n")
print("your age in seconds is: ")
age = dotime(ta[])
tn = gettime()
print(int(tn - age)$)
print("<BODY>\n</HTML>")
end main
See also:
doTime,
getTime.
Things learnt