把當前日期和時間保存到一個參數中 |
|
把一個整數保存爲參數 |
|
保存一個字符數組相對於字符串出現的部分。 |
|
把一個字符串保存到參數中 |
|
把字符串的一部分內容保存爲參數 |
|
返回參數的實際內容或返回一個包含參數的字符串的實際內容 |
void lr_save_datetime(const char *format, int offset, const char *name);
參數解釋:
format |
所檢索的日期/時間信息的格式 |
offset |
當前日期和時間的偏移量, 採用形式有: DATE_NOW, TIME_NOW, ONE_DAY, ONE_HOUR, ONE_MIN. 例如: TIME_NOW + ONE_HOUR |
name |
保存的參數名稱,用來存儲日期/時間信息。 |
例子:
運行結果爲:
Running Vuser...
Starting iteration 1.
Starting action Action.
Action.c(5): Tomorrow is 七月 06 2011
Ending action Action.
Ending iteration 1.
Ending Vuser...
int lr_save_int ( int value, const char *param_name);
參數解釋:
value |
將要保存到參數得整數值 |
param_name |
保存的參數名稱 |
例子:
運行結果爲:
Running Vuser...
Starting iteration 1.
Starting action Action.
Action.c(6): 10
Ending action Action.
Ending iteration 1.
Ending Vuser...
int lr_save_searched_string (const char *buffer, long buf_size, unsigned int occurrence, const char *search_string, int offset, unsigned int string_len, const char *parm_name );
參數解釋:
buffer |
The STRING or CARRAY buffer, part of whose contents you want to save. |
buf_size |
The buffer size. |
occurrence |
The occurrence number of the search_string (0-based count). For example, if the search_string occurs three times, and you want the second occurrence, set occurrence to 1. |
search_string |
The string to search for in the buffer. |
offset |
The number of characters to skip after the end of the search string occurrence. |
string_len |
The number of characters to save. |
parm_name |
Parameter name to be used in subsequent lr statements to refer to the saved information. Name is enclosed in double-quotes. |
例子:
運行結果爲:
Running Vuser...
Starting iteration 1.
Starting action Action.
Action.c(9): Fannys_brother=Will
Ending action Action.
Ending iteration 1.
Ending Vuser...
int lr_save_string (const char *param_value, const char *param_name);
int lr_save_var (const char *param_value, unsigned long const value_len, unsigned long const options, const char *param_name);
char *lr_eval_string (const char *instring );
以上三個函數我們經常會用在一起。例如:
例子:
Starting iteration 1.
Starting action Action.
Action.c(5): 8
Action.c(6): 7
Action.c(9): ShortName=testaaa
Action.c(10): ShortName=testaaa
Ending action Action.
Ending iteration 1.
*****注:在loadrunner中,字符串處理函數用的比較多,其用法也比較簡單。多加以練習操作,在項目實踐中可以很快的做到得心應手。*****