11Jan/066
Simulating abstract classes
Java allows the creation of abstract classes but currently LotusScript does not, but I have a way of simulating. There is no way of enforcing it but here is a way of implementing it.
- Create a new LotusScript Library
- Create a class as you would normally. I have created one called DaysOfTheWeek
- Declare a variable the same name as the class
Dim DaysOfTheWeek As DaysOfTheWeek
- Declare the 'DaysofTheWeek' variable in the 'Initialize' Subrutine
Set DaysOfTheWeek = New DaysOfTheWeek
- Save the script library, I named mine "Days of the Week"
- Create a LotusScript Agent, don't forget to se the agent target to none.
- Include the LotusScript library in the agent
Use "Days of the Week"
- Just start using the class
Sub Initialize
Print "Today's Day of the week:" + DaysOfTheWeek.getWeekDay( Weekday( Now ) )
Print "Day of the week1:" + DaysOfTheWeek.getWeekDay( 1 )
Print "Day of the week2:" + DaysOfTheWeek.getWeekDay( 2 )
Print "Day of the week3:" + DaysOfTheWeek.getWeekDay( 3 )
Print "Day of the week4:" + DaysOfTheWeek.getWeekDay( 4 )
Print "Day of the week5:" + DaysOfTheWeek.getWeekDay( 5 )
Print "Day of the week6:" + DaysOfTheWeek.getWeekDay( 6 )
Print "Day of the week7:" + DaysOfTheWeek.getWeekDay( 7 )
Print "Day of the week8:" + DaysOfTheWeek.getWeekDay( 8 )
End Sub - Run the agent and watch the status bar.
Class DaysOfTheWeek
Public Function getWeekDay( dow As Integer )
Select Case dow
Case 1
getWeekDay = "Sunday"
Case 2
getWeekDay = "Monday"
Case 3
getWeekDay = "Tuesday"
Case 4
getWeekDay = "Wednesday"
Case 5
getWeekDay = "Thursday"
Case 6
getWeekDay = "Friday"
Case 7
getWeekDay = "Saturday"
Case Else
getWeekDay = ""
End Select
End Function
End Class
Public Function getWeekDay( dow As Integer )
Select Case dow
Case 1
getWeekDay = "Sunday"
Case 2
getWeekDay = "Monday"
Case 3
getWeekDay = "Tuesday"
Case 4
getWeekDay = "Wednesday"
Case 5
getWeekDay = "Thursday"
Case 6
getWeekDay = "Friday"
Case 7
getWeekDay = "Saturday"
Case Else
getWeekDay = ""
End Select
End Function
End Class
That is it! Simple, but accomplishes the task of creating abstract class in LotusScript. Just for the record I normal don't declare global varibles like this. 