ErrorLevel("syntax") # 2010/05/17 (Mon) ネット接続部分修正 SleepTime = 3 TenkiVer = 412 selindex[1] = "しない" selindex[2] = "する" Mortexe = systempath("ScriptExe") \ "MortScript.exe" Tenkimscr = systempath("ScriptPath") \ systempath( "ScriptName" ) & systempath( "ScriptExt" ) TenkiRunAtT = """" & Tenkimscr & """ RunAtTimer=ON" TenkiRunAtA = """" & Tenkimscr & """ RunAtAutoexec=ON" gozen = "Software\5zen\Weather" NotifyApp = "\Program Files\cmdRegistryNotifyApp\cmdRegistryNotifyApp.exe" NotifyAppStop = "\Program Files\cmdRegistryNotifyApp\cmdRegistryStopNotification.exe" ConnectName = split("接続しない,その他,インターネット設定",",") #ダイアルアップ(自動切断はできない) InetPath = "\Program Files\WkTask\WkTaskCmd.exe" InetParam = "/w" ### URL設定 URL_root = "http://tenki.jp/" URL_tenki = URL_root & "forecast/" URL_index = URL_root & "indexes/" ### データフォルダのパス DATA_path = systempath("ScriptPath") \ "Tenki" Script_Path = systempath("ScriptPath") rlTodayskin = "\Program Files\HomeScreen PlusPlus\Floyd\Weather" if(direxists(DATA_path) = 0) mkdir(DATA_path) endif ### テンポラリファイル名 DL_temp = DATA_path \ "Tenki.txt" ### 各指数ファイル名 TodayIndex = DATA_path \ "TodayIndex.txt" TomorrowIndex = DATA_path \ "TomorrowIndex.txt" ### テキスト出力名 Tenkiout = DATA_path \ "TenkiText.txt" ### レジストリ読み込み # 終了時にToday画面を再描画させるか call("RegstorySet","RDToday",1) # 最高・最低気温の取得 call("RegstorySet","Temperature",1) # 降水確率の取得 call("RegstorySet","Rainfall",1) # 風向きの取得 call("RegstorySet","Wind",0) # 波の高さの取得 call("RegstorySet","Wave",0) # 接続方法 call("RegstorySet","InternetConnect",3) # タイマー call("RegstorySet","Timelag",15) call("RegstorySet","Interval",5) # データのバージョン if(regvalueexists("HKCU",gozen,"version")) RegVer = regread("HKCU",gozen,"version") endif if(RegVer < 400) regwritestring("HKCU",gozen,"SelectArea","未選択") delete(DATA_path \ "*.txt") delete(DATA_path \ "*.gif") endif # 初期設定 #if(RegVer < 400) # call("GIFDownload") #endif regwritedword("HKCU",gozen,"version",TenkiVer) regwritestring("HKCU",gozen,"Hi", "最高:") regwritestring("HKCU",gozen,"Low", "最低:") ### タイマー起動 ### if(RunAtTimer eq "ON") # Desktopが表示されている場合、五分後に再実行 if (ActiveWindow() ne "Desktop") call("TimerSet",timestamp() + 5 * 60) exit endif # ネット接続 i = 0 callfunction("NetConnect",i) if(i) # 回線接続できなかった call("TimerSet",timestamp() + Interval * 60) exit else # お天気データダウンロード callfunction("TenkiDownload",i) if(i) call("TimerSet",timestamp() + Interval * 60) else call("TimerRoundSet") endif endif # ネット切断 call("NetDisconnect") exit endif ### マニュアル起動 ### if(RunAtManual eq "ON") # 実行問い合わせ if (Question("天気情報を取得します。",""."YesNo")) # ネット接続 i = 0 callfunction("NetConnect",i) if(i) message("ネット接続できませんでした") else call("TenkiDownload") call("NetDisconnect") endif endif exit endif ### 回線接続時の自動起動によるダウンロード ### if(RunAtAutoexec eq "ON") NowTime = (((timestamp() - TimeLag * 60) / 3600) + 1) / 6 NowTime = ((NowTime - ((NowTime mod 4) = 0)) * 6 - 1) * 3600 T_Year = formattime("Y",NowTime) T_Month = formattime("m",NowTime) T_Day = formattime("d",NowTime) T_Hour = formattime("H",NowTime) # 更新確認 if(((regread("HKCU",gozen,"ReleaseYear") = T_Year) and \ (regread("HKCU",gozen,"ReleaseMonth") = T_Month) and \ (regread("HKCU",gozen,"ReleaseDay") = T_Day) and \ (regread("HKCU",gozen,"ReleaseHour") = T_Hour)) = 0) NowTime = timestamp() + 60 while((regread("HKLM","System\State\Connections","Count") = 0) and (NowTime > timestamp())) sleep(1000) endwhile if(regread("HKLM","System\State\Connections","Count") = 0) exit endif for i = 1 to 3 callfunction("TenkiDownload",j) if(j) sleep(10000) else i = 3 endif next endif exit endif while(1) ### メニュー選択 ### callfunction("TimerStr",buff) choice("お天気情報","本日のお天気:" & regread("HKCU",gozen,"Weather1") & "^NL^現在のお天気情報は^NL^" & regread("HKCU",gozen,"ReleaseYMDT") & "^NL^のものです", \ "地域選択(" & regread("HKCU",gozen,"SelectArea") & ")" , \ "最高低気温    取得" & selindex[Temperature + 1] , \ "降水確率     取得" & selindex[Rainfall + 1] , \ "風向き      取得" & selindex[Wind + 1] , \ "波の高さ     取得" & selindex[Wave + 1] , \ "TodayRedraw      " & selindex[RDToday + 1] , "" , \ "タイマー設定(" & buff & ")" , \ "その他の設定" , "" , \ "お天気情報ダウンロード") ## 終了 case(0) exit ## 地域選択 case(1) # ネット接続 i = 0 callfunction("NetConnect",i) if(i) message("ネット接続できませんでした") else # お天気 URL for AreaSelect = 2 to 0 switch(AreaSelect) ### 地域選択 ### case(2) # html読み込み callfunction("DL_html",text,URL_tenki & "index.html",DATA_path \ "index.txt") # 地域切り出し callfunction("BetweenStrings",text,text,1,"各地の天気","^NL^") callfunction("GetArea",i,text,"area-",".html",">","<") if(i) # 選択する i = choice("地方選択","地方を選択してください",1,0,area_dir_name) if(i) DL_url = URL_tenki & "area-" & area_dir[i] & ".html" DL_name = DATA_path \ "area-" & area_dir[i] & ".txt" else # キャンセル AreaSelect = 0 endif else # 切り出し失敗 AreaSelect = 0 endif ### 都道府県等の選択 ### Case(1) # html読み込み callfunction("DL_html",text,DL_url,DL_name) # 地域切り出し callfunction("BetweenStrings",text,text,1,"各地の天気","") callfunction("GetArea",i,text,"forecast/pref-",".html",">","<") area_dir_name[i + 1] = "戻る" # 選択する j = choice("都道府県選択","都道府県等を選択してください",1,0,area_dir_name) if(j) if(j <= i) # 選択 AreaName = area_dir_name[j] else # 戻る AreaSelect = AreaSelect + 2 endif else # キャンセル AreaSelect = 0 endif ### 地域の選択 ### Case(0) # 選択した都道府県の選択肢のあるテキストを切り出す callfunction("BetweenStrings",text,text,1,"abbr=""" & AreaName,"") # 切り出したテキストから選択肢を作る callfunction("GetArea",i,text,"forecast/city-",".html",">","<") area_dir_name[i + 1] = "戻る" # 選択する j = Choice(AreaName ,"お天気を知りたい地域を選択してください" ,1 ,0 ,area_dir_name) if((j <= i) && j) # ダウンロードURL設定 regwritestring("HKCU",gozen,"DownloadURL","city-" & area_dir[j] & ".html") regwritestring("HKCU",gozen,"SelectArea",area_dir_name[j]) elseif(j) # 戻る AreaSelect = AreaSelect + 2 endif EndSwitch next endif ## 最高低気温 case(2) call("RegstoryToggle","Temperature") ## 降水確率 case(3) call("RegstoryToggle","Rainfall") ## 風向き case(4) call("RegstoryToggle","Wind") ## 波の高さ case(5) call("RegstoryToggle","Wave") ## Today画面の再描画 case(6) call("RegstoryToggle","RDToday") ## タイマー設定 case(8) i = 1 while(i) callfunction("TimerStr",buff) choice("メニュー選択","メニューを選択してください", \ "タイマーセット(" & buff & ")" , \ "タイマーキャンセル" , \ "タイムラグ(" & Timelag & "分)" , \ "インターバル(" & Interval & "分間隔)") # 終了 case(0) regwritedword("HKCU",gozen,"Timelag",Timelag) regwritedword("HKCU",gozen,"Interval",Interval) i = 0 # タイマーセット case(1) if(question("タイマーをセットしますか?")) call("TimerDelete") callfunction("TimerRoundSet",j) message("初回 " & formattime("y/m/d H:i:s",j) & " にセットしました") endif # タイマーキャンセル case(2) if(question("タイマーをキャンセルしますか?^NL^現在 " & buff)) call("TimerDelete") message("タイマーを削除しました") endif # タイムラグ設定 case(3) j = input("更新時間の何分後にチェックしますか?","タイムラグ",0,0,Timelag) * 1 if(j<0) j = 0 endif if(question(j & "分後でよろしいですか?")) Timelag = j endif # Interval設定 case(4) j = input("更新失敗時何分間隔に再度チェックしますか?","インターバル",0,0,Interval) * 1 if(j<1) j = 1 endif if(question(j & "分間隔でよろしいですか?")) Interval = j endif endchoice endwhile ## その他の設定 case(9) i = 1 while(i) LANautoexec = regkeyexists("HKLM","System\Notifications\Weather.LANautoexec") ASautoexec = regkeyexists("HKLM","System\Notifications\Weather.ASautoexec") choice("お天気情報","各種設定", \ "ネット接続設定(" & ConnectName[InternetConnect] & ")" , \ "LAN接続時に自動更新" & selindex[LANautoexec + 1] , \ "AS開始時に自動更新" & selindex[ASautoexec + 1] , \ "アイコンダウンロード") # キャンセル case(0) i = 0 # 接続設定 case(1) j = choice("お天気情報","インターネット接続名の選択",InternetConnect,0,ConnectName) if(j) InternetConnect = j regwritedword("HKCU",gozen,"InternetConnect",InternetConnect) endif #LAN接続時の自動更新 case(2) if(LANautoexec) runwait(NotifyAppStop,"3;Weather.LANautoexec") else runwait(NotifyApp,"3;Weather.LANautoexec;HKLM;System\State\Hardware;WiFi;" & Mortexe & ";'" & TenkiRunAtA & "';-;-;-1;1;2;16;16;-") endif # AS開始時の自動更新 case(3) if(ASautoexec) runwait(NotifyAppStop,"3;Weather.ASautoexec") else runwait(NotifyApp,"3;Weather.ASautoexec;HKLM;System\State\Hardware;Cradled;" & Mortexe & ";'" & TenkiRunAtA & "';-;-;-1;1;2;-;1;-") endif # アイコンダウンロード case(4) call("GIFDownload") endchoice endwhile ## お天気データダウンロード case(11) showwaitcursor i = 0 call("NetConnect", i) if(i) hidewaitcursor message("ネット接続できませんでした") else call("TenkiDownload") call("NetDisconnect") hidewaitcursor endif endchoice endwhile exit ### アイコンダウンロード ### sub GIFDownload local(i,x) callfunction("PrintQuestion",i,"アイコンデータをダウンロードしますか?(約120kb)") if(i) x = 0 call("NetConnect", x) if(x) hidewaitcursor message("ネット接続できませんでした") else for i = 1 to 30 j = substr("0" & i,-2) call("ImageDL","http://tenki.jp/images/icon/weatherIcon/" & j & ".gif",DATA_path \ j & ".gif") call("ImageDL","http://tenki.jp/images/icon/weatherIcon/" & j & "_n.gif",DATA_path \ j & "_n.gif") next endif endif endsub ### ネット接続 ### # out...(ret.) 0...接続している/接続した 1...接続失敗 sub NetConnect WifiNow = regread( "HKLM" , "System\State\Hardware" , "Wifi" ) CellularNow = regread( "HKLM" , "System\State\Connections\Cellular", "Count") AsNow = regread( "HKLM" , "Drivers\USB\FunctionDrivers", "ActiveSyncConnected") ipAddr = regread( "HKLM" , "Comm\Tcpip\Hosts\dtpt_peer" , "ipaddr" ) ipAddrFlg = RegValueExists( "HKLM" , "Comm\Tcpip\Hosts\dtpt_peer", "ipaddr" ) if (CellularNow > 0) return(0) else if((WifiNow = 19) or (WifiNow = 23) or (WifiNow = 27)) return(0) else if (AsNow = 1 && ipAddrFlg = TRUE) #ActiveSync接続済みでIPアドレス割り当て済み return(0) else if (AsNow = 1 && ipAddrFlg = FALSE) #ActiveSync接続済みでIPアドレス割り当てなし return (1) else if ((CellularNow = 0) and (InternetConnect <> 1)) # 回線接続する Connect(ConnectName[InternetConnect]) Sleep( 8000 ) NetConnect = regread("HKLM","System\State\Connections","Count") endif return( NetConnect = 0 ) endif endif endif endif endsub ### ネット切断 ### sub NetDisconnect endsub ### ダウンロード(ファイルキャッシュ付) ### # in....[1] ダウンロードするURL # [2] 書き込むファイル名 sub DL_html local(i) i = fileexists(argv[2]) switch(1) case(i = 1) i = (filesize(argv[2]) > 0) case(i = 0) showwaitcursor download(argv[1],argv[2]) hidewaitcursor endswitch return(readfile(argv[2],0,"utf8-prefix")) endsub ### 配列に読み込む ### # in....[1] html # [2] html切り出し切欠 # [3] html切り出しここまで # [4] 地域名切り出し切欠 # [5] 地域名切り出しここまで # out...area_dir[] html # area_dir_name[] 地域名 sub GetArea local(i,GetStr) i = 1 x = 1 clear(area_dir) clear(area_dir_name) while(x) callfunction("BetweenStrings",GetStr,argv[1],x,argv[2],argv[3]) if(GetStr ne "") area_dir[i] = GetStr callfunction("BetweenStrings",area_dir_name[i],argv[1],x,argv[4],argv[5]) i = i + 1 else x = 0 endif endwhile return(i - 1) endsub ### レジストリ読み込み ### # in....[1] レジストリ名 # [2] 初期値 sub RegstorySet if(regvalueexists("HKCU",gozen,argv[1])) [argv[1]] = regread("HKCU",gozen,argv[1]) else [argv[1]] = argv[2] endif endsub ### レジストリトグル ### # in....[1] レジストリ名 sub RegstoryToggle [argv[1]] = 1 - [argv[1]] regwritedword("HKCU",gozen,argv[1],[argv[1]]) endsub ### タイマーをセットした時間を返す ### sub TimerStr call("RegstorySet","DownloadTime",0) if(DownloadTime) return(formattime("Y/m/d({W}) H:i:s",DownloadTime)) else return("----/--/--(---) --:--:--") endif endsub ### 巡回タイマーセット ### sub TimerRoundSet local(i) # 時間を23-4:0/5-10:1/11-16:2/17-22:3に四分割する i = ((timestamp() / 3600) + 1) / 6 # 17-22を23-4に統合する(17-4:0/5-10:1/11-16:2) i = i + ((i mod 4) = 3) # 23-4:6時/5-10:11時/11-16:17時にしTimelag分ずらす i = (i * 6 + 5 +((i mod 4) = 0)) * 3600 + Timelag * 60 call("TimerSet",i) return(i) endsub ### タイマーセット ### sub TimerSet runat(argv[1],Mortexe,TenkiRunAtT) regwritedword("HKCU",gozen,"DownloadTime",argv[1]) endsub ### タイマー削除 ### sub TimerDelete removenotifications(Mortexe,TenkiRunAtT) regwritedword("HKCU",gozen,"DownloadTime",0) endsub ### 画像読み込み ### # in....[1] ダウンロードファイル名 # [2] ダウン先ファイル名 sub ImageDL # DL済みか # if(fileexists(argv[2]) = 0) # DLする download(argv[1],argv[2]) # if(filesize(argv[2]) = 0) # delete(argv[2]) # endif # endif endsub ### メッセージ表示 ### # タイマー起動の場合は表示しない sub PrintMessage if((RunAtTimer ne "ON") and (RunAtAutoexec ne "ON")) sleepmessage(SleepTime,argv[1]) endif endsub ### エラーメッセージ表示 ### # メッセージを表示して終了する sub PrintError call("PrintMessage",argv[1]) exit endsub ### Yes/No表示 ### # タイマー起動の場合はそのまま終了 sub PrintQuestion if((RunAtTimer eq "ON") or (RunAtAutoexec eq "ON")) exit endif return(question(argv[1])) endsub ### お天気データダウンロード ### sub TenkiDownload # ダウンロードする地域のURL(goo天気) TenkiURL = URL_tenki & regread("HKCU",gozen,"DownloadURL") if(TenkiURL eq URL_tenki) call("PrintError","ダウンロード地域が指定されていません^NL^終了します") endif # データダウンロード download(TenkiURL,DL_temp) # 読み込みに成功しているか if(fileexists(DL_temp)) text = readfile(DL_temp,0,"utf8-prefix") # 必要な所だけ切り出す callfunction("BetweenStrings",today,text,1,"","") callfunction("BetweenStrings",otherday,text,1,"","") ### 地域取得 ### callfunction("BetweenStrings",DT_area,today,1,"

","の天気",16) ### 発表日時 ### # 年 callfunction("BetweenStrings",DT_year,today,x,""">","年",4) # 月 callfunction("BeforeStrings",DT_month,today,x,"月",2) # 日 callfunction("BeforeStrings",DT_day,today,x,"日",2) # 時 callfunction("BeforeStrings",DT_hour,today,x + 1,"時",2) # 分 callfunction("BeforeStrings",DT_minute,today,x,"分",2) #発表時間+エリア情報 textout = DT_year & "年 " & DT_month & "月 " & DT_day & "日 " & DT_hour & "時" & DT_minute & "分発表(" & DT_area & ")" regwritestring("HKCU",gozen,"ReleaseArea",DT_area) regwritestring("HKCU",gozen,"ReleaseYear",DT_year) regwritestring("HKCU",gozen,"ReleaseMonth",DT_month) regwritestring("HKCU",gozen,"ReleaseDay",DT_day) regwritestring("HKCU",gozen,"ReleaseHour",DT_hour) regwritestring("HKCU",gozen,"ReleaseMinute",DT_minute) regwritestring("HKCU",gozen,"ReleaseYMDT",textout) textout = DT_area & "の天気^NL^" & textout & "^NL^^NL^" ### 今日・明日の切り分け ### callfunction("BetweenStrings",weather[1],today,x,"

","

") weather[2] = substr(today,x) for i = 1 to 2 text = weather[i] # 日付 callfunction("BetweenStrings",DT_days[i],text,1,"月","日",2) # 曜日 callfunction("BetweenStrings",DT_week[i],text,x,">","<",1) # 六曜 callfunction("BetweenStrings",DT_rokuyou[i],text,x,"[","]",2) # 天気 callfunction("BetweenStrings",DT_weather[i],text,x,"weatherIcon/","gif",5) callfunction("BetweenStrings",DT_weatherstr[i],text,x,"alt=""","""",10) # 気温 if(Temperature) # 最高気温 callfunction("Temperature",DT_hitemp[i]) callfunction("BetweenStrings",DT_himargin[i],text,x,"[","]",3) # 最低気温 callfunction("Temperature",DT_lowtemp[i]) callfunction("BetweenStrings",DT_lowmargin[i],text,x,"[","]",3) endif # 降水確率 if(Rainfall) x = find(text,"降水確率",x) for j = 1 to 4 callfunction("BetweenStrings",buff,text,x,"","",3) if(buff = "100") DT_rainfall[i] = DT_rainfall[i] & "/" & "100" else if(find(buff,"%")) DT_rainfall[i] = DT_rainfall[i] & "/" & replace(buff,"%","") else DT_rainfall[i] = DT_rainfall[i] & "/--" endif endif DT_rainfall[i] = DT_rainfall[i] & "%" next DT_rainfall[i] = substr(DT_rainfall[i],2) endif # 風向き if(Wind) x = find(text,">",find(text,">風",x) + 7) callfunction("BeforeStrings",DT_wind[i],text,x + 1,"<") endif # 波の高さ if(Wave) x = find(text,">波",x) if(x) x = find(text,">",x + 7) callfunction("BeforeStrings",DT_wave[i],text,x + 1,"<") else DT_wave[i] = "---" endif endif next ### 週間天気予報 ### # 日付 x = 1 for i = 3 to 8 # 日 callfunction("BetweenStrings",DT_days[i],otherday,x,"月","日") # 曜日 x = find(otherday,"","",1) # 六曜 callfunction("BetweenStrings",DT_rokuyou[i],otherday,x,")","^LF^",2) next # 天気 for i = 3 to 8 callfunction("BetweenStrings",DT_weather[i],otherday,x,"weatherIcon/","gif") callfunction("BetweenStrings",DT_weatherstr[i],otherday,x,"

","

") next # 最高・最低気温 if(Temperature) for i = 3 to 8 callfunction("BetweenStrings",DT_hitemp[i],otherday,x,"HighTemp"">","

",3) callfunction("BetweenStrings",DT_lowtemp[i],otherday,x,"LowTemp"">","

",3) next endif # 降水確率 if(Rainfall) x = find(otherday,"降水確率",x) + 4 for i = 3 to 8 callfunction("BetweenStrings",DT_rainfall[i],otherday,x,"Precip"">","

",4) next endif ### テキストに書き出す for i = 1 to 8 # データがない? if(DT_weather[i] eq "") DT_weather[i] = "0." DT_weatherstr[i] = "---" DT_hitemp[i] = "---" DT_lowtemp[i] = "---" DT_rainfall[i] = "---" else if(DT_hitemp[i] ne "---") DT_hitemp[i] = DT_hitemp[i] & "℃" DT_lowtemp[i] = DT_lowtemp[i] & "℃" endif if((i > 2) and (DT_rainfall[i] ne "---")) DT_rainfall[i] = DT_rainfall[i] & "%" endif endif # 日時 textout = textout & DT_days[i] & "(" & DT_week[i] & "/" & DT_rokuyou[i] & ")^NL^" & DT_weatherstr[i] & "^NL^" regwritestring("HKCU",gozen \ i, "Day" , DT_days[i]) regwritestring("HKCU",gozen \ i, "Week" , DT_week[i]) regwritestring("HKCU",gozen \ i, "Rokuyou" , DT_rokuyou[i]) regwritestring("HKCU",gozen \ i, "Dayweek" , DT_days[i] & "日(" & DT_week[i] & ")") regwritestring("HKCU",gozen \ i, "Dayrokuyou" , DT_days[i] & "日(" & DT_rokuyou[i] & ")") # 天気 copy(DATA_path \ DT_weather[i] & "png",Script_Path \ "Tenki" & i & ".png",1) # copy(DATA_path \ DT_weather[i] & "gif",Script_Path \ "Tenki" & i & ".gif",1) regwritestring("HKCU",gozen \ i,"Weather" , DT_weatherstr[i]) # 気温 if(Temperature) regwritestring("HKCU",gozen \ i,"Hitemp" , DT_hitemp[i]) regwritestring("HKCU",gozen \ i,"Lowtemp" , DT_lowtemp[i]) if(i < 3) textout = textout & "最高気温:" & DT_hitemp[i] & "[" & DT_himargin[i] & "]^NL^" textout = textout & "最低気温:" & DT_lowtemp[i] & "[" & DT_lowmargin[i] & "]^NL^" regwritestring("HKCU",gozen \ i , "Himargin" , DT_himargin[i]) regwritestring("HKCU",gozen \ i , "Lowmargin" , DT_lowmargin[i]) else textout = textout & "最高気温:" & DT_hitemp[i] & "^NL^" textout = textout & "最低気温:" & DT_lowtemp[i] & "^NL^" endif endif # 降水確率 if(Rainfall) textout = textout & "降水確率:" & DT_rainfall[i] & "^NL^" regwritestring("HKCU",gozen \ i , "Rainfall" , DT_rainfall[i]) endif if(i < 3) # 風向き if(Wind) textout = textout & "風向き :" & DT_wind[i] & "^NL^" regwritestring("HKCU",gozen \ i , "Wind" , DT_Wind[i]) endif # 波の高さ if(Wave) textout = textout & "波の高さ:" & DT_wave[i] & "^NL^" regwritestring("HKCU",gozen \ i , "Wave" ,DT_Wave[i]) endif endif textout = textout & "^NL^" next # 天気をファイルに書き出す writefile(Tenkiout,textout) return(0) # today画面の再描画 if(RDToday) redrawtoday endif # delete(DL_temp) ### ダウンロードに失敗した else call("PrintMessage","お天気データがダウンロードできませんでした") return(1) endif endsub ### 気温を返す ### sub Temperature local(y,buff) callfunction("BetweenStrings",buff,text,x,"","") y = x callfunction("BetweenStrings",buff,buff,1,">","<",3) x = y if(buff eq "") return("---") else return(buff) endif endsub ### 指定文字列までの文字列を返す ### # in....[1] 対象文字列 # [2] 検索位置 # [3] チェックする文字列 # out...ret() 取得文字列 # x 検索後の位置 sub BeforeStrings local(i) i = find(argv[1],argv[3],argv[2]) switch(1) case(i = 1) return("") x = i + length(argv[3]) case(i > 1) return(substr(argv[1],argv[2],i - argv[2])) x = i + length(argv[3]) case(i = 0) return("") x = argv[2] endswitch endsub ### 指定文字列以降の文字列を返す ### # in....[1] 対象文字列 # [2] 検索位置 # [3] チェックする文字列 # out...ret() 取得文字列 # x 常に1 sub AfterStrings local(i) i = find(argv[1],argv[3],argv[2]) if(i) return(substr(argv[1],i + length(argv[3]))) else return("") endif x = 1 endsub ### 指定文字列間の文字列を返す ### # in....[1] 対象文字列 # [2] 検索位置 # [3] 最初の文字列 # [4] 最後の文字列 # [5] [返り血の文字数制限] # out...ret() 取得文字列 # x 検索後の位置 sub BetweenStrings local(i,text) i = find(argv[1],argv[3],argv[2]) text = "" if(i) i = i + length(argv[3]) x = find(argv[1],argv[4],i) if(x) text = substr(argv[1],i,x-i) x = x + length(argv[4]) endif else x = argv[2] endif # 返り値の制限の有無 if(argc > 4) return(substr(text,1,argv[5])) else return(text) endif endsub