Forum Discussion
kso
15 years agoOccasional Contributor
thank you Jared,,
here is a snippet of code for those interested in (totaly free).
I use a flag "/arg" to recognize that it is an argument passed from the command line
I use this args to create/update projectsuites variables value, but you can do whatever you want.
//
// handle arguments passed on the command line
// the command line is in the form:
// "%ProgramFiles%\Automated QA\TestExecute 7\Bin\TestExecute.exe" <PJS File> /run /project:<project> /unit:<Unit> /routine:handleArguments /arg:S:Solution="FMFI" /arg:S:SgbdType="Oracle" /arg:S:IniFile="fileini.txt" /exit /SilentMode
// args can be already defined in the projectsuite or are added if they do not exists.
// args are defined by the /arg:<Type>:<Name>=<Value>
// Type can be S(string)|I(integer)|D(double)|B(boolean)
// the flag /exit must be passed after tha /arg flag.
function handleArguments()
{
var max=BuiltIn.ParamCount();
var i,tabVar,str;
var varType = new Array();
var re = new RegExp("[:=]","g");
// define the type of variable
varType['S']='String';
varType['B']='Boolean';
varType['D']='Double';
varType['I']='Integer';
// for each param
for (i=0;i<max;i++) {
str = BuiltIn.ParamStr(i);
// if it is an /arg flag
if(str.indexOf('/arg')!=-1) {
// Split the flag to get type, name and value of the variable
tabVar=str.split(re);
// if the variable is unknown, add it
if (!ProjectSuite.Variables.VariableExists(tabVar[2]))
ProjectSuite.Variables.AddVariable(tabVar[2],varType[tabVar[1].toUpperCase()]);
// set its new value
eval('ProjectSuite.Variables.'+tabVar[2]+'="'+tabVar[3]+'"');
}
}
// this list the default and the local value of the projectsuites variables
max=ProjectSuite.Variables.VariableCount;
for (i=0;i<max;i++) {
// this is the default value
BuiltIn.ShowMessage('Default :'+ ProjectSuite.Variables.GetVariableName(i)+'='+ProjectSuite.Variables.GetVariableDefaultValue(i));
// this is the local value
BuiltIn.ShowMessage('Local :'+ ProjectSuite.Variables.GetVariableName(i)+'='+eval('ProjectSuite.Variables.'+ProjectSuite.Variables.GetVariableName(i)));
}
}
here is a snippet of code for those interested in (totaly free).
I use a flag "/arg" to recognize that it is an argument passed from the command line
I use this args to create/update projectsuites variables value, but you can do whatever you want.
//
// handle arguments passed on the command line
// the command line is in the form:
// "%ProgramFiles%\Automated QA\TestExecute 7\Bin\TestExecute.exe" <PJS File> /run /project:<project> /unit:<Unit> /routine:handleArguments /arg:S:Solution="FMFI" /arg:S:SgbdType="Oracle" /arg:S:IniFile="fileini.txt" /exit /SilentMode
// args can be already defined in the projectsuite or are added if they do not exists.
// args are defined by the /arg:<Type>:<Name>=<Value>
// Type can be S(string)|I(integer)|D(double)|B(boolean)
// the flag /exit must be passed after tha /arg flag.
function handleArguments()
{
var max=BuiltIn.ParamCount();
var i,tabVar,str;
var varType = new Array();
var re = new RegExp("[:=]","g");
// define the type of variable
varType['S']='String';
varType['B']='Boolean';
varType['D']='Double';
varType['I']='Integer';
// for each param
for (i=0;i<max;i++) {
str = BuiltIn.ParamStr(i);
// if it is an /arg flag
if(str.indexOf('/arg')!=-1) {
// Split the flag to get type, name and value of the variable
tabVar=str.split(re);
// if the variable is unknown, add it
if (!ProjectSuite.Variables.VariableExists(tabVar[2]))
ProjectSuite.Variables.AddVariable(tabVar[2],varType[tabVar[1].toUpperCase()]);
// set its new value
eval('ProjectSuite.Variables.'+tabVar[2]+'="'+tabVar[3]+'"');
}
}
// this list the default and the local value of the projectsuites variables
max=ProjectSuite.Variables.VariableCount;
for (i=0;i<max;i++) {
// this is the default value
BuiltIn.ShowMessage('Default :'+ ProjectSuite.Variables.GetVariableName(i)+'='+ProjectSuite.Variables.GetVariableDefaultValue(i));
// this is the local value
BuiltIn.ShowMessage('Local :'+ ProjectSuite.Variables.GetVariableName(i)+'='+eval('ProjectSuite.Variables.'+ProjectSuite.Variables.GetVariableName(i)));
}
}
Related Content
Recent Discussions
- 13 hours agoSvetaG