一、lr_save_string函数

1.该函数主要是将程序中的常量或变量保存为参数;

//将常量保存为参数
lr_save_string("777","page");
web_url(http://www.sina.com.cn/{page});
lr_eval_string("{page}"); //将变量保存为参数,tmp为变量
lr_save_string(tmp,"page");
web_url(http://www.sina.com.cn/{page});
lr_eval_string("{page}");

  

二、sprintf函数

定义函数 int sprintf( char *str,const char * format,.........);
函数说明     sprintf()会根据参数format字符串来转换并格式化数据,然后将结果复制到参数str所指的字符串数组,直到出现字符串结束(’\0’)为止。关于参数format字符串的格式请参考printf()。
返回值 成功则返回参数str字符串长度,失败则返回-1,错误原因存于errno中。
附件说明 使用此函数得留意堆栈溢出,或改用snprintf()。
示例 #include<stdio.h>
main()
{
char * a=”This is string A!”;
char buf[80];
sprintf(buf,”>>> %s<<<\n”,a);
printf(“%s”.buf);
}
执行 >>>This is string A!<<<
常用该函数代替itoa,将整数格式化为字符串形式。
例如:
int page=0;
char page_ch[60];
page=page + 10;
sprintf(page_ch,"%d",page);

  

三、lr_eval_string函数

用于返回instring参数中的实际字符串值,可以使用该函数来查看参数化取值是否正确;

char *tmp="hello";
lr_save_string("777","page"); //将常量777保存为参数page
lr_output_message(lr_eval_string("{page}")); //获取并输出参数page的当前值
lr_save_string(tmp,"page"); //将变量保存为参数,tmp为变量 lr_output_message(lr_eval_string("{page}"));

脚本示例:

example:
int count;
web_reg_save_param("flight_num",
"LB=新",
"RB=闻",
"ORD=All",
LAST);
count=atoi(lr_eval_string("{flight_num_count}")); //sprintf The following example uses sprintf to write the name of a file to a string buffer,
filename. This name is made up of the word "log", an underscore, the value of i, and the
file suffix. example:
Action()
{
int index = 56;
char filename[64], *suffix = "txt"; sprintf(filename, "log_%d.%s", index, suffix);
lr_output_message("The new file name is %s", filename); return 0;
}
Output:
Action.c(9): The new file name is log_56.txt //
lr_save_string Saves a null-terminated string to a parameter. int lr_save_string (const char *param_value, const char *param_name); aram_value The value to assign to the parameter.
param_name The name of the parameter. The lr_save_string function assigns the specified null-terminated string to a parameter.
This function is useful in correlating queries. To determine the value of the parameter,
use the lr_eval_string function. example:
lr_save_string("777", "emp_id"); ///
#include "as_web.h" Action()
{ int i;
int count;
char param[10][20]; web_reg_save_param("flight_num",
"LB=新",
"RB=闻",
"ORD=All",
LAST); web_add_cookie("BAIDUID=643CC8042E92F7FB5EF83827498BDBDC:FG=1; DOMAIN=www.baidu.com"); web_add_cookie("BDSTAT=495409234680ac099258d109b3de9c82d158ccbf6f81800a19d8bc3eb035a10e;
DOMAIN=www.baidu.com"); web_add_header("Accept-Language",
"zh-cn"); web_url("www.baidu.com",
"URL=http://www.baidu.com/",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=t1.inf",
"Mode=HTML",
LAST); count=atoi(lr_eval_string("{flight_num_count}"));
lr_error_message("已经数量:%d",count);
for(i=1;i<=count;i++)
{
sprintf(param[i],"{flight_num_%d}",count);
lr_error_message(param[i]);
}
for(i=1;i<count;i++)
{
lr_error_message(lr_eval_string(param[i]));
} return 0;
}

  

最新文章

  1. ASP.NET MVC 异步获取和刷新ExtJS6 TreeStore
  2. clip:rect矩形剪裁
  3. What is “:-!!” in C code?
  4. go语言 类型:复数类型
  5. [转]Android下拉刷新完全解析,教你如何一分钟实现下拉刷新功能
  6. linq 延迟执行带来的困扰
  7. SqlHelper帮助类
  8. Merge Cells for DataGrid 合并单元格
  9. 在iptables和selinux中放行smb服务
  10. lesson5:Condition的原理分析及demo展示
  11. Knockout获取数组元素索引的2种方法,在MVC中实现
  12. [C++]UVaLive7324 ASCII Addtion
  13. JavaScript递归函数解“汉诺塔”
  14. SVG分组和引用
  15. 获取或操作DOM元素特性的几种方式
  16. python并发编程之守护进程、互斥锁以及生产者和消费者模型
  17. [转]查看处于被锁状态的表:v$locked_object dba_objects v$session all_objects v$sqlarea v$lock
  18. 关于layoutparam 请铭记。。。。
  19. C#大数据循环
  20. java 中sendredirect()和forward()方法的区别

热门文章

  1. jackson json序列化 首字母大写 第二个字母需小写
  2. Yii中实例化类的四种方式
  3. String转int,int转String
  4. Windows下搭建Nacos及Seata
  5. LeNet-5模型的keras实现
  6. 22_2mybatis——CURD
  7. MYSQL explain详解[转载]
  8. Django学习系列2:django环境中安装selenium并查看selenium版本号
  9. kettle批量导入json数据
  10. Iconfont 阿里图库使用(小程序和H5)