This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Print complete output of save_param function

Hello Team,

I have added web_reg_save_param function like below :web_reg_save_param ("ProfileRed", "LB=xxxx","RB=YYY","ord=ALL",LAST); I need to print message in lr_out_message for this but i could see there are multiple Parameter vaues are available in output log , like

Notify : saving parameter "ProfileRed_1" = CRM

Notify : saving parameter "ProfileRed_2" = FMS

Notify : saving parameter "ProfileRed_3" = SAP

likewise many more, So how can i print them in output message ?

Thanks

MJ

  • 0  

    , Do you want to put them in a single output message or is it good enough to print them in multiple messages?

    For the latter you can use a for()-loop and have a look to the functions lr_paramarr_len() and lr_paramarr_idx().

    How to ask questions

    Reward contributions via likes or 'verified answers'

  • 0 in reply to   

    should print in multiple line from same output message should also be ok.

  • 0 in reply to 

    and if i need to print in single output message how can do this possible ?

  • Suggested Answer

    0   in reply to 

    It is good to invest in some basic C programming skills. But here is how you might solve this.
    Put this code before of you vuser_init() function.

    int my_paramarr_out_message(char *prefix, char *sep, char * postfix, char *param_name, int value_str_len)
    /*
    	Prints a list of all values of an array parameter with some formatting to function lr_output_message().
    	A temorary buffer is allocated to contain the message. This buffer is enlarged when the estimated
    	initial size is too small.
     	Arguments:
    		prefix: The string that is printed at the beginning of message
    		sep: The string that is printed between the array elements.
    		postfix: The string is is printed at the end of the message.
    		param_name: the name of the LR array parameter
    		value_str_len: An estimate of the average length of the array parameter values.
    	Returns:
    		The length of the printed message.
    	Examle:
    		my_paramarr_out_message("Array values of TEST are: ", ", ", ".", "TEST", 10);
    	Todo:
    		Argument value validation (e.g. null-pointers or values < 0)
    	 
     */
    {
    	char *buf, *p, *s;
    	int buf_len, params, offset, idx;
    	
    	buf_len = strlen(prefix) + ( strlen(sep) + value_str_len ) * lr_paramarr_len(param_name) + strlen(postfix) +1;
    	buf = (char*)malloc(buf_len);
    	offset = 0;
    	params = lr_paramarr_len(param_name);
    	offset += sprintf(buf+offset, "%s", prefix);
    	s = sep;
    	for(idx=1; idx<=params; idx++) {
    		p = lr_paramarr_idx(param_name, idx);
    		if( idx == params ) s = postfix;
    		while(offset+strlen(p)+strlen(s) >= buf_len) {
    			// We have estimated the buffer too small: add 25%
    			buf_len += 1 + buf_len>>2;
    			buf = (char*)realloc(buf, buf_len);
    		}
    		offset += sprintf(buf+offset, "%s%s", p, s);
    	}
    	lr_output_message(buf);
    	free(buf);
    	return offset;
    }

    How to ask questions

    Reward contributions via likes or 'verified answers'