Void Function StartupGreeting ()
; written on 11/27/2009 by rwj

Var

Int intTime, ; I added this variable to simplify the code later
String CurDate,
String CurTime,
String Date,
String strTime, ; I modified this variable's name to differentiate the string from the integer
String Greeting,
String UserName,
String UserGreeting

Let UserGreeting = "Error someplace: Try again!" ; I added this assignment
Let Greeting = "good morning,good afternoon,good evening" ; I removed the parenthesis
Let UserName = "Your Name," ; I removed the parenthesis
Let Date = SysGetDate ()
Let CurDate = "the date is " + Date ; I removed the parenthesis
Let strTime = SysGetTime ()
Let CurTime = "the time is " + strTime ; I removed the parenthesis

If StringContains ( strTime, "A" ) Then
Let UserGreeting = StringSegment ( Greeting, ",", 1 )
Else ; at this point, we've eliminated every time before 12 noon
Let intTime = StringToInt ( strTime ) ; need to call this function only once

If ( intTime == 12 )
|| ( intTime < 6 ) Then
Let UserGreeting = StringSegment ( Greeting, ",", 2 )
Else ; at this point, we've eliminated every time before 6 PM

Let UserGreeting = StringSegment ( Greeting, ",", 3 )
EndIf
EndIf

If StringContains ( UserGreeting, "Error" ) Then
SayString ( UserGreeting )
Else
SayString ( UserGreeting + UserName + CurDate + CurTime )
EndIf
EndFunction


Go Back