星期六, 7月 17, 2021

[Eggplant] Functional | 基本指令記錄-常處理商業邏輯會用到的

 記錄每次錄製都會再查一下的指令集

List 操作

取list某個值
put ["cheddar","provolone","brie","muenster","mozzarella"] into CheeseList
put item 1 of CheeseList // displays "cheddar"

如果要插入值進list

insert testScript after failTestScripts


list總數
put the number of items of testScripts into runCount 

http://docs.eggplantsoftware.com/ePF/SenseTalk/stk-lists.htm#contents

數字運算

//對變數+1

add 1 to buyCount

日期運算

天數相加

  //取得今天

put the date into currentDateObj

Log "目前要選擇的今天:"&& currentDateObj && ",欲加天數:"&&addDays

//天數加減 =>changeDateObj

put currentDateObj + (addDaysdays into changeDateObj

//找到變動的天數

put day(changeDateObj) into newDay


時間相減並轉換分


put time(depatureTime) into conv2Time

Log "轉換的時間:"&&conv2Time

put the time into nowTime

Log "當前的時間:"&&nowTime

put (conv2Time  - nowTime) into secondsElapsed

Log "相差的秒數:"&&secondsElapsed

//這樣除單位會錯誤

//put (secondsElapsed/60) into minsElapsed

put minute(secondsElapsed) into minsElapsed

Log "相差的幾分:"&&minsElapsed

return minsElapsed


字串處理

分割 split
        //2021/07/25分割

split fulldate by "/"

put item 1 of fulldate into year

put item 2 of fulldate into month

put item 3 of fulldate into day


取代

//TWD 700 => 700

replace "TWD " by "" in subTotalOfEditTicket


取出字串某個字元

Put the first character in getValidCode into replaceString 

Repeat 迴圈

//以下指令可跳出repeat

exit repeat


沒有留言:

張貼留言

留個話吧:)