LR_函数

来源:互联网 发布:sql连表update 编辑:程序博客网 时间:2024/06/05 04:22

一:WEB_URL

Web_url(“这里是步骤名”,”URL=你要访问的地址”,LAST);

二:编码转换lr_convert_string_encoding

例如:把“楂樼骇鎼滅储”从utf-8转换到系统编码格式,并且保存到test这个参数里面

lr_convert_string_encoding("楂樼骇鎼滅储",LR_ENC_UTF8,LR_ENC_SYSTEM_LOCALE,"test");

三:输出函数 lr_output_message 只能输出字符串

1.    int c;
       char x[100];
       char *y;
       c=10;
       strcpy(x,"abc");
       y="aya i love you";
       lr_output_message("%d",c);
     lr_output_message(x);
      lr_output_message(y);

2.参数和变量之间的转化,lr_save_string/ lr_save_int  把变量当到参数里面

char *y;                                                                                          int i;

y="helloword";                                                                           for(i=0;,i<=10;i++)

lr_save_string(y,"temp");                                                         { lr_save_int(i,"temp");

lr_output_message(lr_eval_string("{temp}"));                      lr_output_message(lr_eval_straing("{temp}"));}

3.变量是数字以及字符串时放到参数里面

   int i;
   char *y;
   char x[100];                                    //定义字符数组char name[20]="xiaoli";
   y="i love you";
   for(i=0;i<=10;i++)
   {
    sprintf(x,"clound_%s%d",y,i);   把clound_y_i转换到x里面,将格式化的数据存放到一个字符串中
    lr_save_string(x,"temp");
lr_output_message(lr_eval_string("{temp}"));
   }

将两个字符串拼接到一起:char *strcat(char *to, const char *from)

4.语句:循环、控制语句

yuju()
{//控制语句、循环语句
int i,j;
for(i=1;i<=5;i++)
{
      if(i==3) break;
 else lr_output_message("i=%d",i);
      for(j=1;j<=5;j++)
 {
         if(j==2) break;                 //一个break跳出一个循环
lr_output_message("j=%d",j);
 }
}
return 0;
}

三:数字以及数组的定义

1. int i;
   char *string="hello";
   char string[10]="hello"; //定义字符数组

   for(i=1;i<=9;i++){
sprintf(mystring,"{forum_%d}",i);
lr_output_message(lr_eval_string(mystring));
}

2.字符串转成数字atio

cnt=atoi(lr_eval_string(mystring));

3.关联数组

1)关联数组

web_reg_save_param("forum",
"LB=<a href=\"thread.php?fid=",
"RB=\"",
"Ord=All",
"NotFound=WARNING",
"Search=Body",
LAST);

2)关联数组的长度

for(i=1;i<=lr_paramarr_len("forum");i++){              //参数不用在加大括号
lr_output_message(lr_paramarr_idx("form",i));    //按下标索引输出
lr_output_message(lr_paramarr_random ("form")); //随机输出

         lr_save_string(lr_paramarr_random("pageid"),"pid");  //随机取出的变量值放置到pid参数中
lr_output_message(lr_eval_string("{pid}")); //从参数中取值输出
}

四:预处理

#define PI 3.14

#include "base64.h" ,一般f.h放置在lr安装目录的"include"子目录下


五:实例

double atof( const char *string );  //变量申明
Action1()
{  
char totalprice[64]="6279.60";
float price[3]={1380.00,859.80,450.00};
int quantity[3]={2,2,4};
    char strtmpres[64];
float ftotalprice=0;
int i;
for(i=0;i<=2;i++){
ftotalprice=ftotalprice+price[i]*quantity[i];
}
lr_output_message("总价totalprice=%.2f",atof(totalprice));
lr_output_message("计算价格=%.2f",ftotalprice);
sprintf(strtmpres,"%.2f",ftotalprice);
lr_output_message(strtmpres);
if(*totalprice==*strtmpres){
lr_output_message("预期与实际相等");
}
else
{
      lr_output_message("预期与实际不相等");
}
return 0;
}

0 0
原创粉丝点击