Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

passing arguments

Status
Not open for further replies.

captedgar

Programmer
Dec 4, 2009
20
GB
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

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
 
something like the following should get you most of the way there :

Code:
function CreateNewLogSubDir(build,transaction,desc)
{ 
  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-' + build + '-T-' + tansaction+ '-' + desc;
}

Greg Griffiths
Livelink Certified Developer & ECM Global Star Champion 2005 & 2006
 
Thanks for the reply Greg

The problem is this creates a log folder as follows

2010-01-05-B-undefined-T-undefined-undefined

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

When i run that file, all i have is

2010-01-05-B-undefined-T-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 T, i then enter T= 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-T-165487-testlog

Is it possible to do this in JScript?
 
the values are undefined probably because you have not specified them when you call my revised version of the function. If you want the user to enter them as part of the script then you will need to look at the PROMPT function - try a Google search.

Greg Griffiths
Livelink Certified Developer & ECM Global Star Champion 2005 & 2006
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top