Page 1 of 1 1
Topic Options
#168273 - 2006-09-22 12:57 PM MOTD script
ChrisJ Offline
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 Offline
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
#168275 - 2006-09-22 02:38 PM Re: MOTD script
Björn Offline
Korg Regular
*****

Registered: 2005-12-07
Posts: 953
Loc: Stockholm, Sweden.
Garg; Doesn't MessageBox sit and wait for userinteraction before script execution continues? If it does it could prove a 'problem'.
Top
#168276 - 2006-09-22 03:37 PM Re: MOTD script
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
Provide the 4th MessageBox parameter, Time-Out in seconds.
I presume to have really random MOTD's you will want to use SRnd() ?
I thought I read somewhere that using Rnd() without SRnd() does not really generate randoms.

Top
#168277 - 2006-09-22 03:43 PM Re: MOTD script
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
Quote:

Garg; Doesn't MessageBox sit and wait for userinteraction before script execution continues? If it does it could prove a 'problem'.




Yep it does but is also has a timeout option.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#168278 - 2006-09-22 03:52 PM Re: MOTD script
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Don't use RND. Use a modulo of the date, which will ensure different MOTD each day, but the same MOTD for eveyone on that day.

This came up only recently, so search recent posts for the solution.

Top
#168279 - 2006-09-22 03:55 PM Re: MOTD script
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
You could setup a message of the day source file in ini format. This way it will be quite easy to read the message for that day.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#168280 - 2006-09-22 04:01 PM Re: MOTD script
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Quote:

Yep it does but is also has a timeout option.



But the timer stops if focus is lost.

While I am a staunch believer that logon scripts should neither be seen nor heard, if you really do want to annoy users, at least separate the message from the script by spawning it in the web browser. Users tend to view the message as just slowing them down during logon and will simply stop logging off.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#168281 - 2006-09-22 04:05 PM Re: MOTD script
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Here is that discussion thread I referred to: http://www.kixtart.org/ubbthreads/showflat.php?Cat=0&Number=162749&an=&page=&vc=1
Top
#168282 - 2006-09-22 05:28 PM Re: MOTD script
Witto Offline
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 Offline
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
#168284 - 2006-09-22 06:19 PM Re: MOTD script
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
If you read the rest of his post, he goes on to say "This came up only recently, so search recent posts for the solution".
How hard can it be?
http://www.kixtart.org/ubbthreads/showflat.php?Cat=0&Board=UBB1&Number=162841

Top
#168285 - 2006-09-22 06:31 PM Re: MOTD script
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
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.
Top
#168286 - 2006-09-22 06:36 PM Re: MOTD script
masken Offline
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
#168287 - 2006-09-22 07:06 PM Re: MOTD script
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
No, I meant the searching bit.
Top
#168288 - 2006-09-25 09:53 AM Re: MOTD script
Richard H. Administrator Offline
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 Offline
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
Page 1 of 1 1


Moderator:  Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 84 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.15 seconds in which 0.075 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org