The 2008 Winter Scripting Games

Beginner Event 4: Count Yourself In

Important: The deadline for this event has passed. Solutions are available in VBScript, Windows PowerShell, and Perl.

Count Yourself In involves reading from a text file, a text file that just happens to be a script.

Not a native speaker of English? These event instructions are also available in the following languages: Chinese (Simplified); Chinese (Traditional); French; German; Japanese; Portuguese Brazilian; Russian; and Spanish. For more information, and to access these localized instructions, see the Scripting Games International page.

*
On This Page
About This EventAbout This Event
Event ScenarioEvent Scenario

About This Event

Division

Beginner

Deadline

Friday, February 22, 2008 (8:00 AM PST)

Points Awarded

5

Top of pageTop of page

Event Scenario

In this event, all you need to do is count the number of characters in a text file. That doesn’t sound too difficult, does it? The twist is that the text file is the script itself. In other words, create a script that counts the number of characters in that script. For example, if you create a script named C:\Scripts\Count.vbs, that script should return the number of characters in the file C:\Scripts\Count.vbs. The script should count all characters, including spaces, but it should not count the carriage-return linefeed character.

Now for the really tricky part: the script should work no matter what you name the script file (assuming, of course, that it has the correct file extension – .vbs, .ps1, or .pl – in order to run) or what folder you put it in. And yes, that means that the name of the script should not be hard-coded into the script itself.


Top of pageTop of page