Title: Topic: Text, Date and Time Functions
1Module 1
Relationship
Computer Technology III
Topic Text, Date and Time Functions
By Shiela Marie B. Pelayo
2Day 1
3Objectives
- At the end of the lesson, the students should be
able to - make a function in ASP
- give the return values of the pre-defined ASP
functions - use the pre-defined ASP functions correctly in
getting the desired output - determine the relationship of some ASP functions
- include the ASP pre-defined functions in the El
Fili web page
4Each class has a set of officers with different
functions or roles. The secretary takes care of
the attendance report and other secretarial
works. The treasurer collects different payments
from the class. The Vice President takes charge
of the class in the absence of the President. The
President implements programs and leads the
entire class in any activity.
5Directions Get your notebook. Write the answers
for the questions below in your notebook. What
if there are no class officers? How will the
teacher or the class assigns work like checking
the attendance, collecting money, representing
the class in an activity, and other similar work?
What is the relationship between the function of
the class officers and efficiency? Be ready to
share your answer to the class.
6In scripting, the relationship of some functions
are important in getting the desired output. But
before we dig deeper to the concept of the
different ASP functions, we will consider first
how these functions and procedures are made.
Let us consider the example in the next slide.
7Example In order to display the average of 3
numbers 10 times in the web page, the script
below should be typed in the Notepad 10 times
(!!!!!) also. lt dim q1,q2,q3 q1CInt(request.
form("quiz1")) q2CInt(request.form("quiz2")) q3
CInt(request.form("quiz3")) response.write("The
average is ") response.write((q1q2q3)/3 .
ltbrgt) gt (Note The labserve does not
interpret thick double quotes. Change the thick
double quotes into thin ones before viewing the
output.) Naturally, you dont like to have a
repetition of scripts. To avoid this, a FUNCTION
is needed. But what is a FUNCTION?
8To understand the topic, please read the lesson
about Function on http//www.webcheatsheet.com/a
sp/subs_and_functions.php . (Check the Function
Square part only.) Please check how the
functions are written. Reading Time10 minutes
only
9Hands-on1
- Open the Notepad.
- Copy the script below in the Notepad.
- lthtmlgt
- ltbodygt
- ltform name"averageform" methodpost
action"average.asp"gt - Please enter 3 quiz scores.ltbrgtltbrgt
- Quiz 1ltinput type"text" name"quiz1"gt ltbrgt
- Quiz 2ltinput type"text" name"quiz2"gt ltbrgt
- Quiz 3ltinput type"text" name"quiz3"gt ltbrgt
- ltinput type"submit" name"submit"
value"Submit"gt - lt/formgt
10 lt dim q1,q2,q3 q1CInt(request.form("quiz1"))
q2CInt(request.form("quiz2")) q3CInt(request.f
orm("quiz3")) response.write("The average is
") response.write((q1q2q3)/3 .
ltbrgt)gt lt/bodygt lt/htmlgt 3. Save the file as
average.asp in the Functions subfolder. 4. View
the output using your browser.
115. After viewing the output of average.asp,
please copy the script below that has a function
now which shall compute the average of the 3
quiz scores. lthtmlgt ltheadgtlttitlegtThe Function
Average Activity of Vitto Antonio
JrB lt/titlegtlt/headgt ltbodygt ltform
name"averageform" methodpost
actionfunctionaverage.asp"gt Please enter 3
quiz scores.ltbrgtltbrgt Quiz 1ltinput type"text"
name"quiz1"gt ltbrgt Quiz 2ltinput type"text"
name"quiz2"gt ltbrgt Quiz 3ltinput type"text"
name"quiz3"gt ltbrgt ltinput type"submit"
name"submit" value"Submit"gt lt/formgt
12 lt dim q1,q2,q3 q1CInt(request.form("quiz1"))
q2CInt(request.form("quiz2")) q3CInt(request.f
orm("quiz3")) response.write("The average is
") gt ltfunction average(q1,q2,q3) average
(q1q2q3)/3 end functionresponse.write(average
(q1,q2,q3))gt lt/bodygt lt/htmlgt 6. Save the file
as functionaverage.asp in the Functions
subfolder. 7. View the output using your browser.
This is how to write a function
This is how to call the function
13Group work
Directions Make a group consisting of 3 members
each. Decide whether the statements are True or
False. Write X on the blank that corresponds to
your answer. True False True False
(Before) (After) __ __ 1. A
function has a return value.
__ __ __ __ 2. The Len
function does not include spaces in the
__ __ text counting. __ __ 3.
The equal symbol is used to display the
functions __ __ value in the web
page. __ __ 4. Functions have different
parameters. __ __ __ __ 5. Len
function can be used inside Mid function.
__ __
14The group shall read the lesson about functions
on http//www.asptutorial.info/learn/Datetime.asp
or on http//www.codetricks.com/article.php?cat
aspid14pagenumber6 and www.bellaonline.com/
articles/art10925.asp and shall answer the
questions in the next slide. One will be assigned
as recorder.
15- What is a function?
- 2. What are examples of text functions?
- 3. What are examples of time functions?
- 4. What are examples of date functions?
16Hands-on2
- Open the Notepad.
- Copy the script below in the Notepad. Be sure to
check the output of each function. - lthtmlgt
- ltbodygt
- The output of now( ) is lt now gt ltbrgt
- The output of date( ) is lt date gt ltbrgt
- The output of month(now) is lt month(now) gtltbrgt
- The output of time( ) is lt time gtltbrgt
- The output of monthname( month ( now)) is lt
monthname(month(now)) - gtltbrgt
- The output of hour(now ) is lt hour(now) gtltbrgt
17There are lt len("The cat is on the mat.") gt
characters in "The cat is on the
mat.ltbrgt "Frankenstein" begins with the letter
lt left("Frankenstein", 1) gt.ltbrgt The last
three letters of "Wednesday" are
ltright("Wednesday", 3) gt. ltbrgt The output of
mid("I am cool!",6,4) is lt mid("I am
cool!",6,4)gt lt/bodygt lt/htmlgt 3. Save the
file as myfunctions.asp in the Functions
subfolder. 4. View the output using your
browser.
18Group work
Please determine the output of the following
scripts in your notebook. You shall be given 8
minutes only. 1 lt len(Animo La Salle!) gt
2. lt left(Animo La Salle! ,5) gt 3. lt
mid(De La Salle,4,8) gt 4. lt
right(Lasallians are smart,5) gt 5. lt
mid(Lasallians are smart,16,5) gt 6. lt
month(now) gt 7. lt monthname(month(now))
gt 8. lt left(Animo La Salle! , len(Hello)
gt One group shall be called to present their
answers to the class.
19- Open the Notepad.
- Make scripts that will display the form below
- Name
-
-
-
- Hi John Lopez. Today is September 24, 2007 955
AM. - 3. Use a text box for the name .
- 4. Use date and time functions to display the
date and time after the user clicks the Submit
button.. - 5. Save the file as mynameanddate.asp in the
Functions subfolder. - Use ASP Forms Using Textboxes at www.sirpats.com
as guide.
Hands-on3
John Lopez
Textbox
SUBMIT
CLEAR
20Get 1/8 cross wise of paper and rate your
output. Rating Scale 10/10 The script is
working perfectly. The target output comes
out. 6/10- The script has a minor error. 4/10-
The script has many errors. Not output was
shown. Write your name, section, title of the
activity (My name and Date Activity), and the
score in 1/8 cross wise. Show the output to the
seatmate and ask him/her to sign in the 1/8 cross
wise. Submit the paper with complete information
to the teacher.
21Assignment In ½ cross wise of pad paper, write
the dates and important events in El
Filibusterismo. Write also the URL where you get
your answer. The information shall be used in
your next activity. Seatwork Please take the
seatwork at the Q Online. The URL is
http//qserver.zobel.dlsu.edu.ph .