jacksboy 发表于 2009-1-2 16:12:13

lr.get_attrib_double函数怎么用

HP LoadRunner Online Function Reference > Utility Functions: Java Language (lr.) > Command Line Parsing Functions
里面有个lr_get_attrib_double 函数,它的JAVA SAMPLE里是这么写的,看不太明白,有人知道具体例子怎么用的么:

In the following example, lr.get_attrib_double retrieves the value of the time parameter from the command line string

test1   -host sun2   -loop 4   -time 1.5

where test1 is the name of the executable and host, loop and time are command line options. lr.get_attrib_double assigns the value to a variable, wait_time. This variable is incorporated into the script and sets how long to wait between loops.

....//

       double wait_time;

       int i;

      

       wait_time=lr.get_attrib_double("time");

       if (wait_time==0){

            lr.message("Illegal time value \n");

            return;

       }

这段脚本要放在那里啊,INIT,ACTION?

我两个地方都试运行了一下,不报错但是没输出结果。

yetties2005 发表于 2009-1-2 22:06:07

应该放在Action里吧。

zhsh1203 发表于 2009-1-3 13:45:57

试下这样操作,参考下!

action
{
double wait_time;

long secInYear;

char *mrsCollins;

long t;

int i, loops = 3;

      

wait_time=lr_get_attrib_double("time");

secInYear = lr_get_attrib_long ("secondsInYear");

mrsCollins =lr_get_attrib_string ("MrsCollins");

if ( wait_time <= 0 ){

       lr_message("Illegal time value = %f \n", wait_time);

       return;

}else

{

       lr_message("Wait time value = %f", wait_time);

       lr_message("The number of seconds in a year is %ld",

            secInYear);

       lr_message("Mr. Collins' wife is named %s Lucas",

            mrsCollins);

}

for (i=0; i < loops; ++i) {

       time(&t);

       lr_message("Time and date: %s", ctime(&t));

       lr_think_time(wait_time);

       }

       time(&t);

       lr_message("time and date: %s", ctime(&t));}

return 0;

}
页: [1]
查看完整版本: lr.get_attrib_double函数怎么用