Computers - Software Hardware : I need help with VBScripting

Discussion in 'Computers - Hardware Software' started by blazejay, May 12, 2012.

  1. blazejay Active Member

    Member Since:
    Apr 14, 2012
    Message Count:
    153
    Likes Received:
    85
    Trophy Points:
    28
    Gender:
    Male
    Thank You
    I will go there in a few minutes to read and soak it in.
  2. Shikamaru Well-Known Member

    Member Since:
    May 7, 2011
    Message Count:
    3,701
    Likes Received:
    1,981
    Trophy Points:
    113
    Gender:
    Male
    Let's go back to Task 2 for a bit.

    Within document COMP230_W2_IPO_Lab.docx; Task 2; 2nd bullet of page 3; first line of the code section; "Please" is misspelled.

    Code:
    WScript.StdOut.Write("Pleasse Enter your Full Name .............. ")
    name = Wscript.StdIn.ReadLine()
    WScript.StdOut.WriteLine() ' Skip 1 line
    WScript.StdOut.Write("Please Enter your age .................... ")
    ageStr = WScript.StdIn.ReadLine()
    First time typing all this in, there were errors on my part. If you run the script through F5, the script will partially run followed by terminating abruptly. This tells us that our script has errors.

    At that point, I jumped to command-line. Navigate to the location of your Script directory.

    Code:
    cd C:\Scripts
    From the command line you can launch your script for testing and debugging.

    To test the script using CScript.exe, type:

    Code:
    cscript nameage.vbs
    To test the script using WScript.exe, type:

    Code:
    wscript nameage.vbs
    In my case, the script had mistypings. Type up or piece together another script for Task 2. Post your code when complete. Your lab sheet has all code typed correctly for Task 2.
    I'll post mine after yours is complete.

    Task 2 is the basis for Task 3.
  3. Shikamaru Well-Known Member

    Member Since:
    May 7, 2011
    Message Count:
    3,701
    Likes Received:
    1,981
    Trophy Points:
    113
    Gender:
    Male
    About VBScript from Wikipedia.

    Here is a model of the WScript object you are working with in you scripts. Towards the bottom of the page you'll see a listing of this object's properties and methods.

    *Note: Underlined words are keywords that you definitely want to know and understand.

    StdOut and StdIn are properties of the object WScript.

    Write, WriteBlankLines, and WriteLine are all methods of the property StdOut. Should be able to discover and reference all of this from the WScript link at the beginning of my post.

    You will want to save the WScript object model page in your browser for future reference.
  4. Shikamaru Well-Known Member

    Member Since:
    May 7, 2011
    Message Count:
    3,701
    Likes Received:
    1,981
    Trophy Points:
    113
    Gender:
    Male
    When posting, there is a "Code" button at the top of the editor.

    You can use that to paste your code into.

    That's how I got those blue boxes in my posts.
  5. Shikamaru Well-Known Member

    Member Since:
    May 7, 2011
    Message Count:
    3,701
    Likes Received:
    1,981
    Trophy Points:
    113
    Gender:
    Male
    Output from Task 2:

    Task2.jpg

    The code in Task 2 works as expected when typed in correctly.