【求助】(lr如何打印下个月份)请大神看看我的代码错在哪里了?
lr打印当前月份的函数是 lr_save_datetime("%Y-%m", DATE_NOW,"NOW_YM"); ****2015-09我想打印出下个月份****2015-10,但是调了大半天还是不行,请大神指点:
char *N_M;
lr_save_datetime("%Y", DATE_NOW,"Year");
lr_save_datetime("%m", DATE_NOW,"NOW_Mon");
sprintf(N_M,"{NOW_Mon_%d}",1); //将当前月份存到变量N_M里面
lr_save_string(N_M++,"NEXT_Mon"); //将变量N_M+1存到参数NEXT_Mon里面
lr_save_string(lr_eval_string("{Year}-{NEXT_Mon}"), "Ymd");
return 0;
报错如下:
Starting action Action.
Action.c(7): Warning: Invalid parameter detected in function.
Action.c(8): Error: C interpreter run time error: Action.c (8):Error -- memory violation : Exception ACCESS_VIOLATION received.
Action.c(8): Notify: CCI trace: Action.c(8): lr_save_string(0x00000000, 0x026b019f "NEXT_Mon")
.
Action.c(8): Notify: CCI trace: Compiled_code(0): Action()
.
Ending Vuser...
你把每一步赋值的结果都打印出来看看 善于利用lr本身的参数化, 里面有个额date/time,,可以设置时间的,很多格式。 注意你要的是时间偏差。 使用offset。 加上一个 for循环 你这样做当然不行,如果你需要实现这样的功能,代码如下:
char *N_M;
int currentYear, currentMonth;
int nextYear, nextMonth;
lr_save_datetime("%Y", DATE_NOW,"Year");
lr_output_message(lr_eval_string("{Year}"));
lr_save_datetime("%m", DATE_NOW,"NOW_Mon");
lr_output_message(lr_eval_string("{NOW_Mon}"));
currentYear = atoi(lr_eval_string("{Year}"));
currentMonth = atoi(lr_eval_string("{NOW_Mon}"));
if (currentMonth == 12) {
nextMonth = 1;
nextYear = currentYear + 1;
} else {
nextMonth = currentMonth + 1;
nextYear = currentYear;
}
lr_output_message("The new year is:%d new month is:%d", nextYear, nextMonth);
return 0;
页:
[1]