Thursday, May 2, 2013

Let’s use web_save_timestamp_param function for something it doesn’t mean to do ;).

In my previous article, I have shown how to create unique file names in LR. Now, let’s see a simpler way using web_save_timestamp_param function. This function saves the current timestamp to a LR parameter. Timestamp is the number of milliseconds since 00.00 January 1st, 1970.

Use the below code in script:

web_save_timestamp_param("TimeStamp", LAST);
lr_output_message("Timestamp: %s", lr_eval_string("{TimeStamp}"));








You will get the following result :





One more thing to get unique name for each user we have to use lr_whoami function. So we can change our unique name generation script to following:

char uniquefilename[256];
int univuserid, uniscenarioid;
char *unigroupid;

lr_whoami(&univuserid, & unigroupid, & uniscenarioid); web_save_timestamp_param("TimeStamp", LAST);

sprintf(uniquefilename, "%s_%d_%d_%s",lr_eval_string("{TimeStamp}"),
univuserid, uniscenarioid, unigroupid);

lr_output_message(" Unique File name is: %s", uniquefilename);

Isn’t it the simplest way to generate unique names? You decide
J

No comments:

Post a Comment