Get Random Jokes with MS

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
kpassaur
Automation Wizard
Posts: 696
Joined: Wed Jul 07, 2004 1:55 pm

Get Random Jokes with MS

Post by kpassaur » Fri Sep 19, 2008 11:33 am

It has been a while since I posted something and some may find this will make their day a little more humorous. The script uses the HTTPRequest command to go to Comedy Central's website and pull a random joke down and display it in a Message Box.

The user can input how often to run it, so every hour or so they will be displayed with a joke. If someone is clever they could incorporte it into the VB Script example with Merlin and have the Joke read to them as well.
Anyway here it is and have fun with it.


Let>INPUT_BROWSE=0
Input>WT,Enter in minutes how often to dispaly a Joke

If>WT>0,continue
MDL>The wait time cannot be determined - The program will now exit
Exit>0

Label>continue
Let>WT=WT*60

Label>runagain
Random>999,DiceResult1
Let>rnumber=1%DiceResult1%
Let>joke=
DeleteFile>c:\temp\test.txt

HTTPRequest>http://jokes.comedycentral.com/random_j ... MLResponse
WriteLn>c:\temp\test.txt,result,HTMLResponse
Let>k=1

Label>start

ReadLn>c:\temp\test.txt,k,line


If>line=##EOF##,finish
Position>,line,1,StartPos
If>StartPos>0

Let>z=k+1
Label>startreadjoke
ReadLn>c:\temp\test.txt,z,line

If>line=##EOF##,finish

Position>,line,1,StartPos
If>StartPos>0,finish

Let>joke=%joke%%line%%CRLF%
Let>z=z+1
Goto>startreadjoke
Goto>finish
Endif
Let>k=k+1
Goto>start

Label>finish
If>%Joke%=
Goto>runagain
Endif
StringReplace>Joke, ,,Joke
StringReplace>Joke,,%CRLF%,Joke
StringReplace>Joke,,,Joke
StringReplace>Joke,,,Joke
StringReplace>Joke,,,Joke
//StringReplace>Joke,. ,.%CRLF%,Joke
StringReplace>Joke,,,Joke
StringReplace>Joke,,,Joke
StringReplace>Joke,,,Joke
StringReplace>Joke,,,Joke
StringReplace>Joke, ,,Joke
StringReplace>Joke,",",Joke
StringReplace>Joke,,",Joke
StringReplace>Joke,,",Joke
StringReplace>Joke,Â,",Joke
StringReplace>Joke,?,%CRLF%,Joke
StringReplace>Joke,!,%CRLF%,Joke
MDL>Joke
Wait>%WT%
Goto>runagain

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts