SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Oct 2011
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    What's wrong with this code?

    Hi,

    I'm a complete novice at this so please bear with my ignorance.
    I have taken part of some code I know works and simply added a print statemet to it as I want it to print to the command prompt, where I am running the script, the value of REMOTEDIR

    Can you please let me know why the addition of the print statement provides an error:

    ERROR:

    JScript runtime error: Object expected

    CODE:

    var date = new Date();

    // helper function to pad zeroes to the

    left of number
    function pad(n, len)
    {
    var s = n.toString();
    while (s.length < len)
    {
    s = '0' + s;
    }
    return s;
    }

    // format remote directory name
    var REMOTEDIR =
    pad(date.getFullYear(), 4) +
    pad(date.getMonth()+1, 2) +
    pad(date.getDate()-1, 2);

    print(REMOTEDIR);

  2. #2
    SitePoint Member
    Join Date
    Oct 2011
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just in case anyone was wondering the code needed to be change, replacing the

    print(REMOTEDIR);

    with


    WSH.Echo(REMOTEDIR);


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •