Languages Focus: Custom Routines
For non-OOP languages, a custom routine is a function, procedure, or subroutine and for pure OOP languages, a custom routine is a class method. Hybrid languages (both non-OOP and OOP) combine both.
ASP Classic Custom Routines
ASP Classic is a non-OOP language with some OOP features. It offers both Subs and Functions. A Sub does not return a value while a Function does. When Subs and Functions are used in a defined class, they become the methods of the class.
ASP Classic Sub & function Example
If you define the following sub and funtion:
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Subs and Functions
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub DoSomeCode(ByRef pMessage)
Response.Write pMessage
End Sub
Function GetLastDOW(ADate, AWeekDayConst)
While Weekday(ADate) <> AWeekDayConst
ADate = DateAdd("d", -1, ADate)
Wend
GetLastDOW = ADate
End Function
You can call them. For example:
DoSomeCode "Hello3"
Response.Write "Last Monday was " & GetLastDOW(Date, vbMonday)