Printable Version of Topic

Click here to view this topic in its original format

The Ring of Wonder _ Θεός Μηχανή 『神之机器』 _ Lua入门:实例二

Posted by: bx_bob 2011-08-11, 11:52

CODE
require "android"
android.smsSend("10001","108")
android.dialogCreateAlert("流量查询","已经发送短信,待收到回复后点击继续")
android.dialogSetPositiveButtonText("继续")
android.dialogShow()
android.dialogGetResponse()

all_sms=android.smsGetMessages(true)
--print("test")
sms_list=all_sms.result
--print(sms_list)
useful_sms_ids={}
for i = 1,#sms_list do
    --print (sms_list[i].address=="10001")
    if sms_list[i].address=="10001" then table.insert(useful_sms_ids,sms_list[i]) end
end

final_sms_list={}
for i=1,#useful_sms_ids do
    num=tonumber(string.match(useful_sms_ids[i].body,"^(%d)/%d%)"))
    final_sms_list[num]=useful_sms_ids[i].body
end

fulltext=""

for i,j in pairs(final_sms_list) do
    fulltext=fulltext..string.match(j,"^%d/%d%)(.-)$")
end

web_flow=string.match(fulltext,".*(已使用.-MB字节,剩余.-MB字节).*")
web_flow_now,web_flow_left=string.match(fulltext,".*已使用(.-)MB字节,剩余(.-)MB字节")

--print(web_flow,web_flow_now,web_flow_left)
android.dialogCreateHorizontalProgress("流量查询",web_flow,math.ceil(tonumber(web_flow_now+web_flow_left)))

android.dialogShow()
android.dialogSetCurrentProgress(math.ceil(tonumber(web_flow_now)))

Attached Image

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)