#168273 - 2006-09-22 12:57 PM
MOTD script
|
ChrisJ
Fresh Scripter
Registered: 2006-09-22
Posts: 6
|
I want to send a message of the day as a pop up message on login at a school split across two sites. We need to have different messages for different groups of students/staff/locations.
My idea was to create a folder available to staff for them to add text files to, one message per file. This way I can expire files based on their date so that we don't get old messages appearing.
Does anyone have anything vaguely similar I could build on?
ChrisJ
|
Top
|
|
|
|
#168274 - 2006-09-22 02:36 PM
Re: MOTD script
|
Gargoyle
MM club member
Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
|
There are alot of different ways this could be done. Off the top of my head... Create your folders Then to present random messages from that folder, build an array that contains the message file names. At random pick one of the messages Then using @Site (assuming that you have AD and there are two seperate sites) put the contents of the selected message into a messagebox.
Here is a logic flow, not by any means a working script Code:
$Messages = DirPlus("\\server\messages","*.txt") $Count = Ubound($Messages) Select Case @Site = "Site1" $File = Rnd($Count) $ = MessageBox($Messages[$File],"MOTD") Case @Site = "Site2" $File = Rnd($Count) $ = MessageBox($Messages[$File],"MOTD") Case1 $ = MessageBox("An error was encountered please contact the help desk", "Warning") EndSelect
|
Top
|
|
|
|
#168281 - 2006-09-22 04:05 PM
Re: MOTD script
|
Richard H.
Administrator
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
|
Top
|
|
|
|
#168282 - 2006-09-22 05:28 PM
Re: MOTD script
|
Witto
MM club member
Registered: 2004-09-29
Posts: 1828
Loc: Belgium
|
Quote:
While I am a staunch believer that logon scripts should neither be seen nor heard
Me too
|
Top
|
|
|
|
#168283 - 2006-09-22 06:02 PM
Re: MOTD script
|
Gargoyle
MM club member
Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
|
Quote:
Use a modulo of the date
Care to explain how this is done?
|
Top
|
|
|
|
#168286 - 2006-09-22 06:36 PM
Re: MOTD script
|
masken
MM club member
Registered: 2000-11-27
Posts: 1222
Loc: Gothenburg, Sweden
|
Another idea, change the IE home page if possible. Or just start an IE session pointing to the right page.... ie, http://intranet/2006-09-22.htm
Or perhaps there isn't any need for formatting etc?
|
Top
|
|
|
|
#168288 - 2006-09-25 09:53 AM
Re: MOTD script
|
Richard H.
Administrator
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Quote:
Yes how to implement it, but not the how the modulus works, for those of us without a major in mathematics, it can be difficult to understand without the plain english explanation.
The link provided gives a working script.
As for the maths, it's very simple. You start with a big number (let's call it D), divide by a smaller number (lets call it Q) and take the remainder. The remainder is always going to be between 0 and Q-1. As D increases by 1, so the remainder will increase by 1. This remainder is also known as the modulus.
Here is an example. Lets start D and Q both at 3 and see what the effect of increasing D is:
Quote:
When D is 3 (D mod Q) is 0 When D is 4 (D mod Q) is 1 When D is 5 (D mod Q) is 2 When D is 6 (D mod Q) is 0 When D is 7 (D mod Q) is 1 When D is 8 (D mod Q) is 2 When D is 9 (D mod Q) is 0
So how does this help? Well, assume that "D" represents Date, and "Q" represents "Quotes". This gives us a really simple way of going through the quotes in a linear fashion. All you need to do is get the date in a numeric format.
There are a number of "serial date" functions to convert dates into an internal format that you can use in maths, but you don't really need them.
Here is one very simple way of determining the quote: Code:
Break ON $Q=12345 ; Number of quotes $D=CDbl(Join(Split(@DATE,"/"),"")) ; Convert date to a number "Number of quotes : "+$Q+@CRLF "Today : "+@DATE+@CRLF "Today as a number : "+$D+@CRLF @CRLF "Quote for today is : "+($D mod $Q)+@CRLF
See, I told you it was simple
The only drawback to using this method is that some quotes will be skipped on each cycle, however they will be picked up in later cycles so it is not an issue unless you are paranoid about all your quotes being displayed.
Don't forget that the result is between 0 and Q-1.
|
Top
|
|
|
|
#168289 - 2006-09-25 02:18 PM
Re: MOTD script
|
Gargoyle
MM club member
Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
|
Ok, I think I get the jist of it. Thanks for putting up with me
|
Top
|
|
|
|
Moderator: Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 515 anonymous users online.
|
|
|