0

Below is the answer:

I wanted to write the extracted values to file in vugen, Loadrunner.
There may be multiple values extracted and count of extracted values may differ on each iteration.

Below is the working condition:

count = atoi(lr_eval_string("{correlation_param_count}"));  // to save the values count in parameter
        
         hf = fopen("D:\\value.txt", "w"); 

         for(i=1; i<=count;i++)
         {
            sprintf(value,"{correlation_param_%d}",i);

            
            fprintf(hf, "correlation_value=%s,\n", lr_eval_string(value));  //to write all values in new line
             
         }
        fclose( hf);

It is working as expected

Vikash
  • 1
  • 1

1 Answers1

0

The most common reason to engage in this behavior is you expect to pass this values to another script. Otherwise, you would hold the values in memory to be used within the iteration.

The recommended path for this is to use a queue to pass the data between scripts, not a file. Consider the challenges of lock when multiple users attempt to write to this same file. This is a non trivial problem to solve, leading to the use of a service to maintain lock on the file across multiple sessions. LoadRunner ships with the Virtual Table Server for just this reason. If you prefer not to use this tool, then consider any one of the queue services available from cloud provider or an open source solution such as RabbitMQ.

James Pulley
  • 5,606
  • 1
  • 14
  • 14