Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


BOFH-style Excuse Generator

 
Logged in as: Guest
arrSession:exec spGetSession 2,16,31054
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> Post a VBScript >> BOFH-style Excuse Generator
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 BOFH-style Excuse Generator - 2/14/2006 1:43:45 AM   
  SirBlade

 

Posts: 28
Score: 0
Joined: 1/11/2006
Status: offline
A script to display a random line from a textfile, an example file can be found here:

http://www.cs.wisc.edu/~ballard/bofh/excuses



      
 
 
Post #: 1
 
 RE: BOFH-style Excuse Generator - 2/14/2006 9:21:12 AM   
  ebgreen


Posts: 4595
Score: 29
Joined: 7/12/2005
Status: offline
Here are some comments:

1) Use Option Explicit. It only seems like it causes more work. It really saves work.
2) Use block indentation. It makes code so much easier to read and understand.
3) Use a consistent variable naming convention. It also makes it much easier to understand what is going on in the code.

Those comments are all more stylistic than anything else. Here is the code with those changes:

      

Now for more functional suggestions:

1) There is no need for a variable to count the number of lines in the array. Use the UBound() function if you need to know how many items are in an array.
2) It is not necessary to open the textfile and read in every line. Instead, open the file read in the entire thing and split it to create your array.
3) It is not necessary to define the top and bottom indices for the array. All arrays have a lower index of 0 and UBound gives you the upper index.

Here is the code with these changes as well:

      

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to SirBlade)
 
 
Post #: 2
 
 RE: BOFH-style Excuse Generator - 10/22/2007 7:35:31 PM   
  djredmar

 

Posts: 42
Score: 0
Joined: 12/11/2006
From: Europe, The Netherlands
Status: offline
with the need of several modifications i like it :D

Will use it if my colleques ask questions :)

(in reply to ebgreen)
 
 
Post #: 3
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> Post a VBScript >> BOFH-style Excuse Generator Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts