Code:
So each day it selects a new line, so when one user logs on Tuesday, they see the selection for Tuesday, along with any other user that logs on that day?
This doesn't sound like a requirement for random results to me, it sounds more like you just want a new message each day.
If this is the case, use an INI file to record the message for the day.
You need two entries in the file - one is the cureent message number and the other is the date that the message was used. If the date <> today, add two to the message counter (wrap to zero when you reach the end of the file) and set the used day to today.
Here is an example (untested):
Code:
Break ON
$=SetOption("Explicit","ON")
Dim $sIni,$sMOTD,$fhMOTD,$asData,$sRecord,$sUsedDay,$iMessage
; If the INI file does not exist it will be created
$sINI=@SCRIPTDIR+'\MessageOfTheDay.ini'
; MOTD file contains all the empowering messages
$sMOTD=@SCRIPTDIR+'\MessageOfTheDay.txt'
$fhMOTD=FreeFileHandle()
If @ERROR
"Cannot allocate a free file handle [" +@ERROR+"] "+@SERROR ?
Else
If Open($fhMOTD,$sMOTD)
"Cannot open message file for reading ["+@ERROR+"] "+@SERROR ?
Else
$sRecord=readline($fhMOTD)
While Not @ERROR
$asData=$asData+$sRecord+Chr(10)
$sRecord=readline($fhMOTD)
Loop
$=Close($fhMOTD)
$asData=Split(Left($asData,-1),Chr(10))
$sUsedDay=ReadProfileString($sINI,"CONTROL","LastUsed")
$iMessage=Val(ReadProfileString($sINI,"CONTROL","Message"))
If $sUsedDay="" $sUsedDay=@DATE EndIf
If $sUsedDay<>@DATE
$iMessage=$iMessage+2
If $iMessage>=UBound($asData) $iMessage=0 EndIf
$=WriteProfileString($sINI,"CONTROL","LastUsed",@DATE)
$=WriteProfileString($sINI,"CONTROL","Message",$iMessage)
EndIf
">> "+$asData[$iMessage] ?
">> "+$asData[$iMessage+1] ?
EndIf
EndIf
You will need to ensure that your users can write to the INI file during logon.