njhuangfy 发表于 2006-12-27 11:10:24

这样的控制语句要如何写?请教!

LR8.0自带的sample中的飞机订票系统中,飞机的出发点与到达点,一般情况下应该是不相同的,比如说从上海出发,那到达地一般不会是上海,而是别的城市。
那在订飞机票时如何优化脚本来控制这一点呢。
以下我的脚本:
Action()
{
char city;
char city1;

lr_start_transaction("reserver");

web_set_max_html_param_len("10240");
// Parameter {WCSParam_Diff2} created by Correlation Studio
web_reg_save_param( "WCSParam_Diff2", "LB= NAME=\"", "RB=\"", "Ord=6", "Search=Body", "RelFrameId=1.2", LAST );
// Parameter {WCSParam_Diff3} created by Correlation Studio
web_reg_save_param( "WCSParam_Diff3", "LB= VALUE=\"", "RB=\"", "Ord=12", "Search=Body", "RelFrameId=1.2", LAST );
// Parameter {WCSParam_Diff4} created by Correlation Studio
web_reg_save_param( "WCSParam_Diff4", "LB= VALUE=\"", "RB=\"", "Ord=25", "Search=Body", "RelFrameId=1.2", LAST );
web_url("welcome.pl",
"URL=http://localhost:1080/mercuryWebTours/welcome.pl?page=search",
"Resource=0",
"RecContentType=text/html",
"Referer=http://localhost:1080/mercuryWebTours/nav.pl?page=menu&in=home",
"Snapshot=t5.inf",
"Mode=HTML",
EXTRARES,
"Url=../MercuryWebTours/images/itinerary.gif", "Referer=http://localhost:1080/mercuryWebTours/nav.pl?page=menu&in=flights", ENDITEM,
"Url=../MercuryWebTours/images/splash_findflight.gif", "Referer=http://localhost:1080/mercuryWebTours/reservations.pl?page=welcome", ENDITEM,
"Url=FormDateUpdate.class", "Referer=", ENDITEM,
"Url=CalSelect.class", "Referer=", ENDITEM,
LAST);
   
lr_think_time( 6 );
// Parameter {WCSParam_Diff1} created by Correlation Studio
web_reg_save_param( "WCSParam_Diff1", "LB=outboundFlight value=", "RB= ", "Ord=1", "Search=Body", "RelFrameId=1", LAST );
web_submit_form("reservations.pl",
"Snapshot=t6.inf",
ITEMDATA,
"Name=depart", "Value={city}", ENDITEM,
"Name=departDate", "Value={WCSParam_Diff3}", ENDITEM,
"Name=arrive", "Value={city1}", ENDITEM,
"Name={WCSParam_Diff2}", "Value={WCSParam_Diff4}", ENDITEM,
"Name=numPassengers", "Value=1", ENDITEM,
"Name=roundtrip", "Value=<OFF>", ENDITEM,
"Name=seatPref", "Value=None", ENDITEM,
"Name=seatType", "Value=Coach", ENDITEM,
"Name=findFlights.x", "Value=39", ENDITEM,
"Name=findFlights.y", "Value=12", ENDITEM,
LAST);
   


lr_think_time( 1 );
web_submit_form("reservations.pl_2",
"Snapshot=t7.inf",
ITEMDATA,
"Name=outboundFlight", "Value={WCSParam_Diff1}", ENDITEM,
"Name=reserveFlights.x", "Value=72", ENDITEM,
"Name=reserveFlights.y", "Value=14", ENDITEM,
LAST);
lr_think_time( 26 );
web_submit_form("reservations.pl_3",
"Snapshot=t8.inf",
ITEMDATA,
"Name=firstName", "Value=huang", ENDITEM,
"Name=lastName", "Value=fy", ENDITEM,
"Name=address1", "Value=", ENDITEM,
"Name=address2", "Value=", ENDITEM,
"Name=pass1", "Value= ", ENDITEM,
"Name=creditCard", "Value=12345678", ENDITEM,
"Name=expDate", "Value=", ENDITEM,
"Name=saveCC", "Value=<OFF>", ENDITEM,
"Name=buyFlights.x", "Value=74", ENDITEM,
"Name=buyFlights.y", "Value=11", ENDITEM,
LAST);
strcpy(depart,lr_eval_string("{city}"));
    strcpy(arrive,lr_eval_string("{city1}"));

if (strcmp(depart,arrive) == 0)
   
      {
lr_advance_param( "city1" );
      strcpy(arrive,lr_eval_string("{city}"));

      }
   lr_output_message("depart is %s",lr_eval_string("{city}"));
   lr_output_message("arrive is %s",lr_eval_string("{city1}"));
lr_end_transaction("reserver", LR_AUTO);
return 0;

njhuangfy 发表于 2006-12-27 11:19:44

以上的脚本并没能保证出发点与到达点不一样。
分析如下:
1:depart取了‘上海’,如果arrive也取了‘上海’,这时候脚本继续运行,此时“"Name=roundtrip", "Value=<OFF>", ENDITEM,”此句中value=off
控制语句没能起到作用,不知道是不是语句放的位置不对?
2:还有一种想法,因为当value=on时,此订票才是有效的,有什么办法可以在发现出发点与到达点相同时就把这个value的值置为on呢?
3:另外 或者发现相同时,先把这条订票删除再重新订票而不是只是重新选择到达点(arrive)?

rickyzhu 发表于 2006-12-28 18:52:13

没太看明白,:(

rickyzhu 发表于 2006-12-28 18:53:13

好像这次CPC考试就有一个这样的题目,呜呜,没弄出来.

njhuangfy 发表于 2006-12-30 10:56:34

是吗?你也要参加这次的考试?那你已经通过SP考试了?有何收获
页: [1]
查看完整版本: 这样的控制语句要如何写?请教!