Action()
{
char test[1024], *a = "@qq.com";
strcpy(test, "330491860");
strcat(test, a);
lr_output_message("We can see %s",test);
return 0;
}
输出:
Action.c(7): We can see 330491860@qq.com
【示例二】:
Action()
{
char Temp[1024];
//char fullpath[1024], * filename = "logfile.txt";
lr_save_datetime("Today is %m月 %d日 %Y年 ", DATE_NOW, "today");
// 输出:today = Today is 03月 11日 2016年
lr_save_datetime("Tomorrow is %m月 %d日 %Y年 ", DATE_NOW+ONE_DAY, "tomorrow");
//输出:tomorrow = Tomorrow is 03月 12日 2016年
strcat(Temp,lr_eval_string("{today}"));//将变量today的值追加到Temp末尾
lr_message("Temp=%s",Temp);//输出:Temp=Today is 03月 11日 2016年
strcat(Temp,lr_eval_string("{tomorrow}"));//将变量today的值追加到Temp末尾
lr_message("Temp=%s",Temp);
//输出:Temp=Today is 03月 11日 2016年 Tomorrow is 03月 12日 2016年
return 0;
}
输出:
Starting iteration 1.
Starting action Action.
Action.c(7): Notify: Saving Parameter "today = Today is 05月 05日 2017年 ".
Action.c(10): Notify: Saving Parameter "tomorrow = Tomorrow is 05月 06日 2017年 ".
Action.c(13): Notify: Parameter Substitution: parameter "today" = "Today is 05月 05日 2017年 "
Temp=Today is 05月 05日 2017年
Action.c(18): Notify: Parameter Substitution: parameter "tomorrow" = "Tomorrow is 05月 06日 2017年 "
Temp=Today is 05月 05日 2017年 Tomorrow is 05月 06日 2017年
Ending action Action.
Ending iteration 1.
【示例三】:
Action()
{
char *paperNum;
char *year;
char *month;
char *day;
char birthdate[200];
char *str;
//将620524198607023293保存到变量paperNum中
lr_save_string("620524198607023293","paperNum");
//截取变量paperNum中的年份
lr_save_var(lr_eval_string("{paperNum}")+6,4,0,"year");
//截取变量paperNum中的月份
lr_save_var(lr_eval_string("{paperNum}")+10,2,0,"month");
//截取变量paperNum中的日期
lr_save_var(lr_eval_string("{paperNum}")+12,2,0,"day");
//将-保存到变量str中
lr_save_string("-","str");
strcat(birthdate,lr_eval_string("{year}"));
strcat(birthdate,lr_eval_string("{str}"));
strcat(birthdate,lr_eval_string("{month}"));
strcat(birthdate,lr_eval_string("{str}"));
strcat(birthdate,lr_eval_string("{day}"));
lr_message("birthdate=%s",birthdate);//最后输出:birthdate=1986-07-02
return 0;
}
输出:
Starting action Action.
Action.c(12): Notify: Saving Parameter "paperNum = 620524198607023293".
Action.c(15): Notify: Parameter Substitution: parameter "paperNum" = "620524198607023293"
Action.c(15): Notify: Saving Parameter "year = 1986".
Action.c(18): Notify: Parameter Substitution: parameter "paperNum" = "620524198607023293"
Action.c(18): Notify: Saving Parameter "month = 07".
Action.c(21): Notify: Parameter Substitution: parameter "paperNum" = "620524198607023293"
Action.c(21): Notify: Saving Parameter "day = 02".
Action.c(24): Notify: Saving Parameter "str = -".
Action.c(26): Notify: Parameter Substitution: parameter "year" = "1986"
Action.c(27): Notify: Parameter Substitution: parameter "str" = "-"
Action.c(28): Notify: Parameter Substitution: parameter "month" = "07"
Action.c(29): Notify: Parameter Substitution: parameter "str" = "-"
Action.c(30): Notify: Parameter Substitution: parameter "day" = "02"
birthdate=1986-07-02
Ending action Action.
Ending iteration 1.
【示例四】:
Action()
{
//这个例子是返回第一个出现e字符以后所有的字符,和最后一次出现e字符以后所有的字符
char *string = "Cheers is a tester";
char *first_e, *last_e;
first_e = (char *)strchr(string, 'e');
lr_output_message("We can see the first occurrence of e: %s",first_e);
last_e = (char *)strrchr(string, 'e');
lr_output_message("We can see the last occurrence of e: %s", last_e);
return 0;
}
输出:
Starting iteration 1.
Starting action Action.
Action.c(8): We can see the first occurrence of e: eers is a tester
Action.c(10): We can see the last occurrence of e: er
Ending action Action.
Ending iteration 1.