Results 1 to 4 of 4

Thread: Passing Arguments

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2009
    Posts
    9

    Passing Arguments

    Hi there
    I need help passing extra arguments to one of the function in my script. The code below is one of the functionality of the script and it creates Log Folder

    Code:
    function CreateNewLogSubDir(){
    	var strSubdirName='';
    	strSubdirName=WScript.Arguments.Named.Item('New');
    	if('string'!=typeof(strSubdirName)||0==strSubdirName.length){
    		var strDate = new Date();
    		var iMonth =Number(strDate.getMonth()+1);
    		var sMonthPrefix = '';
    		if(Number(iMonth)<10){sMonthPrefix='0';}
    
    		strSubdirName=strDate.getFullYear()+'-';
    		strSubdirName+=sMonthPrefix+iMonth
    				+'-'
    				+(strDate.getDate() < 10 ? '0':'')
    				+(strDate.getDate());
    I need to pass 4 arguments to the above script. These arguments are values to input to the name of the newly created log folder and these are the information passed from SourceSafe Change Mgt Sys

    Arguments to pass are : 1) Enter Build
    2)Enter Transaction Number
    3)Enter Short Log Description

    Ex: If i enter Build = 49834 and Transaction = 238113 and Short Description = TestingSample, then the newly created Folder should have the following name i.e.

    2009-02-23-B-49834-T-238113-TestingSample

    Is it possible to do this?. Please guide me

    regards

  2. #2
    Hyperactive Member gtilles's Avatar
    Join Date
    Dec 2004
    Location
    Planet Earth
    Posts
    394

    Re: Passing Arguments

    your function with arguments Code:
    1. function CreateNewLogSubDir(pBuild,pTransNumber,pDescription){
    2.     var strSubdirName='';
    3.     strSubdirName=WScript.Arguments.Named.Item('New');
    4.     if('string'!=typeof(strSubdirName)||0==strSubdirName.length){
    5.         var strDate = new Date();
    6.         var iMonth =Number(strDate.getMonth()+1);
    7.         var sMonthPrefix = '';
    8.         if(Number(iMonth)<10){sMonthPrefix='0';}
    9.  
    10.         strSubdirName=strDate.getFullYear()+'-';
    11.         strSubdirName+=sMonthPrefix+iMonth
    12.                 +'-'
    13.                 +(strDate.getDate() < 10 ? '0':'')
    14.                 +(strDate.getDate());
    15.                 +'-B-' + pBuild + '-T-' + pTransNumber + '-' + pDescription
    Truly, you have a dizzying intellect.

  3. #3

    Thread Starter
    New Member
    Join Date
    Dec 2009
    Posts
    9

    Re: Passing Arguments

    Hi gtilles

    i now seem to have the following issue

    Code:
    function CreateNewLogSubDir(pBuildID,pLogID,pDescription) 
    { var strSubdirName=''; 
      strSubdirName=WScript.Arguments.Named.Item'New'); 
    if('string'!=typeof(strSubdirName)||0==strSubdirName.length) 
    { var strDate = new Date(); 
      var iMonth =Number(strDate.getMonth()+1); 
      var sMonthPrefix = ''; 
        if(Number(iMonth)<10)sMonthPrefix='0';} 
      strSubdirName=strDate.getFullYear()+'-'; 
      strSubdirName+=sMonthPrefix+iMonth +'-'+ 
     (strDate.getDate() < 10 ? '0':'')+(strDate.getDate()); 
    strSubdirName+='-B-' + pBuildID + '-L-' + pLogID+ '-' + pDescription;
    The problem is this creates a log folder as follows

    2010-01-05-B-undefined-L-undefined-undefined

    The script doesn't prompt or ask me for entering B which is Build ID
    or L which is LogID or does it ask for entering the issue
    description

    When i run that file, all i have is

    2010-01-05-B-undefined-L-undefined-undefined
    While actually the script should be asking me Build ID and then
    passing whatever argument i'm passing onto Name of the Log Folder

    For Ex: I run the script and then the script should ask enter the
    value of B, i then enter B= 105475
    and then script should ask to enter the value of L, i then enter L=
    165487
    and then the script should ask to enter a short description and then
    i
    should enter testlog
    and then the script should create a new log folder as follows:
    2010-01-05-B-105475-L-165487-testlog

    Please help

  4. #4
    Hyperactive Member gtilles's Avatar
    Join Date
    Dec 2004
    Location
    Planet Earth
    Posts
    394

    Re: Passing Arguments

    If your asp script requires user input you will have to have a form and a submit button.
    Here is some partial code

    Form Code:
    1. dim myBuildID,myLogID,myDescription
    2. myBuildID=request.form("myBuildID")
    3. myLogID=request.form("myLogID")
    4. myDescription=request.form("myDescription")
    5.  
    6.  
    7. if myBuildID<>"" and myLogID<>"" and myDescription<>"" then
    8. CreateNewLogSubDir(myBuildID,myLogID,myDescription)
    9. else
    10. %>
    11. <form name=FileName method=post>
    12. <input type=text name=myBuildID>
    13. <input type=text name=myLogID>
    14. <input type=text name=myDescription>
    15. <input type=submit name=submit>
    16. </form>
    17. <%
    18. end if


    if your using vbscript check out this link for using the inputbox
    http://wsh2.uw.hu/ch08b.html
    Last edited by gtilles; Jan 7th, 2010 at 02:44 PM.
    Truly, you have a dizzying intellect.

Posting Permissions

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



Click Here to Expand Forum to Full Width