Hey, Scripting Guy! 2009 Scripting Games Event 7 Details (Beginner and Advanced; discus throw)

2009 Summer Scripting Games

Beginner Event 7: The discus throw

In the discus throw event, you will be asked to go farther than you have ever gone before. To meet this challenge, you will need to track your progress by writing information to a log file. You will also be required to read from that log file to determine progress.

Event Scenario

Obviously, IT pros must be able to troubleshoot things. Servers crash, applications hang, and computers fail. It seems that nothing runs perfectly forever. Scripters fare no better. And people who write scripts need to be able to troubleshoot scripts. When it comes time to troubleshoot something, you can never have too much information at your disposal. From a scripting perspective, a diagnostic log file may be just the ticket you need to come home with the gold.

In this scenario, you will add commands to a script that will create a diagnostic log file. The commands will write information to a text file that will document the following:

·         Successful creation of the Word.Application object or the error code that was received.

·         Successfully opening the Office Word document or the error code that was received.

·         The misspelled word and the replacement text that will be used.

·         The Word command that is being executed.

Note:  A useful and often-used feature in diagnostic logging is the addition of a timestamp for each of the activities. This can often give clues that something is amiss because of the excessive time a particular command takes to execute. It is also common practice to modify the script that does diagnostic logging to use a switch that will enable or disable the creation of the diagnostic log file. You may also wish to use a temporary file and display the contents of that temporary file when the script is run.

For this scenario, use the appropriate ReplaceWordInWord script from the Competitor’s Pack as well as the test.doc file. Make sure you modify file paths as appropriate for your environment.


Advanced Event 7: The discus throw

In the discus throw event, you will decide if you want to hold or throw cards as you attempt to reach 21 in your hand.

Event Scenario

There are many times when the IT pro might need to use random numbers. One common reason is to pause a few seconds between launching multiple applications to avoid stressing the computer too heavily. Another common use of random numbers is to randomly select computers from a list to test connectivity.

In this scenario, you will write a script that plays the old-fashioned card game 21. To do this you will need to use the following information:

·         Card suits: 1=hearts, 2=diamonds, 3=clubs, 4=spades

·         Cards: 1=ace, 2-10=face value, 11=jack, 12=queen, 13=king

·         When counting to 21, the jack, queen, and king cards are only equal to 10 points. The ace is equal to 1 point. The other cards are equal to their face value (2–10).

·         The object of the game is to get 21 points (hearts, diamonds, clubs, or spades). Each drawing of the cards deals one card. The result is displayed; if your card total goes over 21, you lose that round. You can choose to stop drawing cards at any time before going over 21. If you hit exactly 21 during your hand, you automatically win that round of cards.

For this scenario, you only need to write the code to deal single-handed 21. A good challenge would be to allow you to play against the computer. For this you will need to remember the results and compare them with that of the computer to determine who wins. A nice improvement to that would be to record the results of each game and to determine your overall win/loss record. You could also permit multiple human players to play at the same time.


Comments (1)

  1. Anonymous says:

    All the Scripting Games links in one location! Let the learning begin. (We will update this page every

Skip to main content