51Testing软件测试论坛

 找回密码
 (注-册)加入51Testing

QQ登录

只需一步,快速开始

微信登录,快人一步

手机号码,快捷登录

查看: 2946|回复: 4
打印 上一主题 下一主题

[原创] 如何在语句里使用变量(数组)?

[复制链接]
  • TA的每日心情
    开心
    2014-12-26 13:34
  • 签到天数: 1 天

    连续签到: 1 天

    [LV.1]测试小兵

    跳转到指定楼层
    1#
    发表于 2007-10-12 17:52:04 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
    如下语句:

    web_submit_data("StatusReporter",
         "Name=title", "Value={RunTime}", ENDITEM,
         "Name=content", "Value={GN}", ENDITEM,
         LAST);

    假设有一个数组变量:

    char *A[10][20];

    "Name=content", "Value={GN}", ENDITEM,  

    如何把里面的{GN}换成数组A?

    用 lr_save_string 当然是可以,那就每次都赋值,不停的赋值。
    在多个循环里,想直接在语句里输出 A 的值,有这样的函数或好的办法吗?
    分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
    收藏收藏
    回复

    使用道具 举报

  • TA的每日心情
    开心
    2014-12-26 13:34
  • 签到天数: 1 天

    连续签到: 1 天

    [LV.1]测试小兵

    2#
     楼主| 发表于 2007-10-15 12:21:06 | 只看该作者

    问题解决

    Action2()
    {

            char        a[6],A[70][6],b[6];
            int i;
            web_reg_save_param("A", "LB=orgID=", "RB=&amp", "Ord=All", LAST);
       
            web_url("orgAction.struts",
                    "URL=http://testserver:9080/orgAction.struts?actionType=getSubOrgs,
                    "Resource=0",
                    "RecContentType=text/xml",
                    "Referer=http://ip01:9080/orgAction.struts?actionType=orgTree&module=",
                    "Snapshot=t178.inf",
                    "Mode=HTTP",
                    LAST);

             for (i=1;i<=70;i++) {
                     itoa(i,b,10);
                     strcat(b,"}");
                     strcpy(a,"{A_");
                     strcat(a,b);
                     strcpy(A,a);
                     lr_error_message ("%s is %s",A,lr_eval_string(A));

             }


            return 0;
    }

    输出:
    Starting action Action2.
    Action2.c(6): Registering web_reg_save_param was successful          [MsgId: MMSG-26390]
    Action2.c(8): web_url("orgAction.struts_4") was successful, 20825 body bytes, 147 header bytes, 29 chunking overhead bytes          [MsgId: MMSG-26385]
    Action2.c(23): Error: {A_1} is 683bfcM114821edb20M1dfbdb73c96431d144b38bf4c3cbb6d0
    Action2.c(23): Error: {A_2} is 683bfcM114821edb20M1dfbdb73c96431d144b38bf4c3cbb6d0
    Action2.c(23): Error: {A_3} is baaea8M11367248a95Mdefc7e770f66149edf3257430bb6ba73
    Action2.c(23): Error: {A_4} is baaea8M11367248a95Mdefc7e770f66149edf3257430bb6ba73
    Action2.c(23): Error: {A_5} is 17485acM113a0167e65Mdefc7e770f66149edf3257430bb6ba73
    Action2.c(23): Error: {A_6} is 17485acM113a0167e65Mdefc7e770f66149edf3257430bb6ba73
    Action2.c(23): Error: {A_7} is eab1f2M113aa14e65aM64a67f9da79faf2ed2fc30237a795183
    Action2.c(23): Error: {A_8} is eab1f2M113aa14e65aM64a67f9da79faf2ed2fc30237a795183
    Action2.c(23): Error: {A_9} is 19c8551M114253a123eM1dfbdb73c96431d144b38bf4c3cbb6d0
    Action2.c(23): Error: {A_10} is 19c8551M114253a123eM1dfbdb73c96431d144b38bf4c3cbb6d0
    Action2.c(23): Error: {A_11} is 19c8551M11425ddb86eM1dfbdb73c96431d144b38bf4c3cbb6d0
    Action2.c(23): Error: {A_12} is 19c8551M11425ddb86eM1dfbdb73c96431d144b38bf4c3cbb6d0
    Action2.c(23): Error: {A_13} is 7c06abM11425edded5Mdefc7e770f66149edf3257430bb6ba73
    Action2.c(23): Error: {A_14} is 7c06abM11425edded5Mdefc7e770f66149edf3257430bb6ba73
    Action2.c(23): Error: {A_15} is 7c06abM11425eec974Mdefc7e770f66149edf3257430bb6ba73
    Action2.c(23): Error: {A_16} is 7c06abM11425eec974Mdefc7e770f66149edf3257430bb6ba73
    Action2.c(23): Error: {A_17} is 19c8551M11425ef2ca0M1dfbdb73c96431d144b38bf4c3cbb6d0
    Action2.c(23): Error: {A_18} is 19c8551M11425ef2ca0M1dfbdb73c96431d144b38bf4c3cbb6d0
    Action2.c(23): Error: {A_19} is 1a053d5M1142fce2694M1dfbdb73c96431d144b38bf4c3cbb6d0
    Action2.c(23): Error: {A_20} is 1a053d5M1142fce2694M1dfbdb73c96431d144b38bf4c3cbb6d0
    Action2.c(23): Error: {A_21} is 1c0e6eM1143dfcafefM1dfbdb73c96431d144b38bf4c3cbb6d0
    Action2.c(23): Error: {A_22} is 1c0e6eM1143dfcafefM1dfbdb73c96431d144b38bf4c3cbb6d0
    Action2.c(23): Error: {A_23} is 13c72dM1146df9b9baM1dfbdb73c96431d144b38bf4c3cbb6d0
    Action2.c(23): Error: {A_24} is 13c72dM1146df9b9baM1dfbdb73c96431d144b38bf4c3cbb6d0
    Action2.c(23): Error: {A_25} is 1202b71M11476d0efedM1dfbdb73c96431d144b38bf4c3cbb6d0
    Action2.c(23): Error: {A_26} is 1202b71M11476d0efedM1dfbdb73c96431d144b38bf4c3cbb6d0
    Action2.c(23): Error: {A_27} is 143b0feM11486dd587aMb1fd03d51d8306c2b257fa419aa6efb0
    Action2.c(23): Error: {A_28} is 143b0feM11486dd587aMb1fd03d51d8306c2b257fa419aa6efb0
    Action2.c(23): Error: {A_29} is 1390546M114957fcca7Mdefc7e770f66149edf3257430bb6ba73
    Action2.c(23): Error: {A_30} is 1390546M114957fcca7Mdefc7e770f66149edf3257430bb6ba73
    Action2.c(23): Error: {A_31} is 1e9d469M114aa6dd033Mb1fd03d51d8306c2b257fa419aa6efb0
    Action2.c(23): Error: {A_32} is 1e9d469M114aa6dd033Mb1fd03d51d8306c2b257fa419aa6efb0
    Action2.c(23): Error: {A_33} is eee4dcM114b020f1b6M1dfbdb73c96431d144b38bf4c3cbb6d0
    Action2.c(23): Error: {A_34} is eee4dcM114b020f1b6M1dfbdb73c96431d144b38bf4c3cbb6d0
    Action2.c(23): Error: {A_35} is a3e8f5M114b4ed6cd4M1dfbdb73c96431d144b38bf4c3cbb6d0
    Action2.c(23): Error: {A_36} is a3e8f5M114b4ed6cd4M1dfbdb73c96431d144b38bf4c3cbb6d0
    Action2.c(23): Error: {A_37} is 1252d43M114ca1de292M1dfbdb73c96431d144b38bf4c3cbb6d0
    Action2.c(23): Error: {A_38} is 1252d43M114ca1de292M1dfbdb73c96431d144b38bf4c3cbb6d0
    Action2.c(23): Error: {A_39} is 14b1dbfM114f2f91dbeM1dfbdb73c96431d144b38bf4c3cbb6d0
    Action2.c(23): Error: {A_40} is 14b1dbfM114f2f91dbeM1dfbdb73c96431d144b38bf4c3cbb6d0
    Action2.c(23): Error: {A_41} is 1feb227M114f895f7c5M64a67f9da79faf2ed2fc30237a795183
    Action2.c(23): Error: {A_42} is 1feb227M114f895f7c5M64a67f9da79faf2ed2fc30237a795183
    Action2.c(23): Error: {A_43} is 12e2355M115074cd85aM67e9f6b2e90d662a80deceb6d1ff3388
    Action2.c(23): Error: {A_44} is 12e2355M115074cd85aM67e9f6b2e90d662a80deceb6d1ff3388
    Action2.c(23): Error: {A_45} is 1e4e47fM11511780247M1dfbdb73c96431d144b38bf4c3cbb6d0
    Action2.c(23): Error: {A_46} is 1e4e47fM11511780247M1dfbdb73c96431d144b38bf4c3cbb6d0
    Action2.c(23): Error: {A_47} is 1ac385aM1151b897fa4M67e9f6b2e90d662a80deceb6d1ff3388
    Action2.c(23): Error: {A_48} is 1ac385aM1151b897fa4M67e9f6b2e90d662a80deceb6d1ff3388
    Action2.c(23): Error: {A_49} is 1fbfeaeM1154fadf3b3M64a67f9da79faf2ed2fc30237a795183
    Action2.c(23): Error: {A_50} is 1fbfeaeM1154fadf3b3M64a67f9da79faf2ed2fc30237a795183
    Action2.c(23): Error: {A_51} is e4c118M11554246305Mb1fd03d51d8306c2b257fa419aa6efb0
    Action2.c(23): Error: {A_52} is e4c118M11554246305Mb1fd03d51d8306c2b257fa419aa6efb0
    Action2.c(23): Error: {A_53} is e4c118M115542cc2b2Mb1fd03d51d8306c2b257fa419aa6efb0
    Action2.c(23): Error: {A_54} is e4c118M115542cc2b2Mb1fd03d51d8306c2b257fa419aa6efb0
    Action2.c(23): Error: {A_55} is 180daa6M115558ec40dM64a67f9da79faf2ed2fc30237a795183
    Action2.c(23): Error: {A_56} is 180daa6M115558ec40dM64a67f9da79faf2ed2fc30237a795183
    Action2.c(23): Error: {A_57} is 7d1a7aM115827c3ad1M1dfbdb73c96431d144b38bf4c3cbb6d0
    Action2.c(23): Error: {A_58} is 7d1a7aM115827c3ad1M1dfbdb73c96431d144b38bf4c3cbb6d0
    Action2.c(23): Error: {A_59} is 77e77aM115971287bfM1dfbdb73c96431d144b38bf4c3cbb6d0
    Action2.c(23): Error: {A_60} is 77e77aM115971287bfM1dfbdb73c96431d144b38bf4c3cbb6d0
    Action2.c(23): Error: {A_61} is bfba23M115a1419c60M1dfbdb73c96431d144b38bf4c3cbb6d0
    Action2.c(23): Error: {A_62} is bfba23M115a1419c60M1dfbdb73c96431d144b38bf4c3cbb6d0
    Action2.c(23): Error: {A_63} is 10ba812M1134cb7f139M67e9f6b2e90d662a80deceb6d1ff3388
    Action2.c(23): Error: {A_64} is 10ba812M1134cb7f139M67e9f6b2e90d662a80deceb6d1ff3388
    Action2.c(23): Error: {A_65} is 10ba812M1134cb7f139M67e9f6b2e90d662a80deceb6d1ff3388
    Action2.c(23): Error: {A_66} is 10ba812M1134cb7f139M67e9f6b2e90d662a80deceb6d1ff3388
    Action2.c(23): Error: {A_67} is 10ba812M1134cb7f139M67e9f6b2e90d662a80deceb6d1ff3388
    Action2.c(23): Error: {A_68} is 10ba812M1134cb7f139M67e9f6b2e90d662a80deceb6d1ff3388
    Action2.c(23): Error: {A_69} is 10ba812M1134cb7f139M67e9f6b2e90d662a80deceb6d1ff3388
    Action2.c(23): Error: {A_70} is 10ba812M1134cb7f139M67e9f6b2e90d662a80deceb6d1ff3388
    End auto log messages stack.
    回复 支持 反对

    使用道具 举报

    该用户从未签到

    3#
    发表于 2007-10-15 13:24:27 | 只看该作者
    没懂,仔细说说啊。
    回复 支持 反对

    使用道具 举报

  • TA的每日心情
    开心
    2014-12-26 13:34
  • 签到天数: 1 天

    连续签到: 1 天

    [LV.1]测试小兵

    4#
     楼主| 发表于 2007-10-15 16:17:36 | 只看该作者
    原帖由 lyscu 于 2007-10-15 13:24 发表
    没懂,仔细说说啊。


      使用  web_reg_save_param 函数时, 当 "Ord=All",  可能会读出很多值。

      二楼的方法就是将Save的所有值都读出来,存在一个数组里,供使用。

    其实还有个问题,把Vuser的ID作为参数进行取值,中午试了下,还有问题,有空搞定了补进来。
    回复 支持 反对

    使用道具 举报

  • TA的每日心情
    开心
    2014-12-26 13:34
  • 签到天数: 1 天

    连续签到: 1 天

    [LV.1]测试小兵

    5#
     楼主| 发表于 2007-10-16 12:19:43 | 只看该作者

    剩下的问题尚未解决:

    回复 支持 反对

    使用道具 举报

    本版积分规则

    关闭

    站长推荐上一条 /1 下一条

    小黑屋|手机版|Archiver|51Testing软件测试网 ( 沪ICP备05003035号 关于我们

    GMT+8, 2024-11-8 04:52 , Processed in 0.076491 second(s), 27 queries .

    Powered by Discuz! X3.2

    © 2001-2024 Comsenz Inc.

    快速回复 返回顶部 返回列表