loadrunner取出关联数组中的所有元素

方法一:

	int num;

	char nameVar[100];

	char nameValue[100];

	lr_save_string("AAA","name_1");

	lr_save_string("BBB","name_2");

	lr_save_string("CCC","name_3");
 
	lr_save_string("3","name_count");//定义数组长度


	for(num=1;num<=atoi(lr_eval_string("{name_count}"));num++){

		sprintf( nameVar,"{name_%d}",num );

		sprintf( nameValue,"%s",lr_eval_string(nameVar) );

//		lr_output_message("name_%d的值:%s",num,nameValue);

		lr_save_string(lr_eval_string(nameVar),"nameValue");

		lr_output_message("nameValue的值:%s",lr_eval_string("{nameValue}"));

	}

 

方法二:

方法2比较简洁,定义的变量少

    int num;

    char nameVar[100];

    lr_save_string("AAA","name_1");

    lr_save_string("BBB","name_2");

    lr_save_string("CCC","name_3");

    lr_save_string("3","name_count");//定义数组长度


    for(num=1;num<=atoi(lr_eval_string("{name_count}"));num++){


        sprintf( nameVar,"{name_%d}",num );//将num变量保存到fidVar中,

//      lr_output_message("name的值:%s",lr_eval_string(nameVar));

        lr_save_string(lr_eval_string(nameVar),"test");

        lr_output_message("test的值:%s",lr_eval_string("{test}"));


    }

 

 

posted @ 2015-10-24 17:44  Agoly  阅读(1342)  评论(0编辑  收藏  举报