タンポポ調査のツール集:「ウォッちず」で選んだ地点の経緯度を入力

カスタマイズの方法

動作に必要なファイルやスクリプト,フィールドは下記のようになります.

これらを他のファイルメーカ(ファイルメーカー Filemaler pro)のファイルに移植したり,ダウンロードしたサンプルファイルに必要に応じてフィールド等を付け加えればOKです.サンプルファイルを加工する場合は下記の3フィールドの名称は変更してはいけません.また,ファイル名は自由に変更できますが,テーブルの名前は変えてはいけません.


必要なファイル:encode.pl データベースファイルと同じフォルダに入れる.名称は変更しないこと

必要なフィールド:「緯度」,「経度」,「ランドマーク」の3つ.名称は変更しないこと

必要なスクリプト:次の2つ

スクリプト:ランドマークを「ウォッちず」で検索--AppleScript を実行 計算済みの AppleScript:
"try《改行》
set aPath to quoted form of ¥"" & Substitute ( Middle ( Get ( ファイルパス ) ;Position ( Get ( ファイルパス ) ; "/" ; 1;2 );
Position ( Get ( ファイルパス ) ; "/" ; 1 ; PatternCount ( Get ( ファイルパス ) ; "/" ) ) -Position ( Get ( ファイルパス ) ;
"/" ; 1;2)+1) ; "file:/" ; "" ) & "¥"《改行》set aText to ¥"" &
経緯度::ランドマーク &
"¥"《改行》set EncodeText to do shell script ¥"perl ¥" & aPath & ¥"encode.pl ¥" & aText《改行》
set theUrl to ¥"http://watchizu.gsi.go.jp/search.aspx?searchwords=¥" & EncodeText &
¥"&chuki=t&koukyou=t&pref=0¥"《改行》
tell application ¥"Safari¥"《改行》
activate《改行》
open location theUrl《改行》
end tell《改行》
on error errMsg《改行》
display dialog ¥"エラーが発生しました。エラー内容:¥" & errMsg《改行》
end try"

※他のファイルに移植する場合,テーブルの名称が異なればエラーとなります.上で赤で示した「経緯度」は移植した先のテーブル名称に書き換えてください.

※都道府県別に地名検索を絞り込みたい場合はちょっとした工夫をご覧ください

※スクリプト中のバックスラッシュは環境によると¥に見えます.また,《改行》で表したところはファイルメーカでは左向きのPマークです.従って上のスクリプトの最後の部分はファイルメーカのスクリプト編集画面では,次のように見えるはずです.


スクリプト:「ウォッちず」の経緯度取り込み--AppleScript を実行 計算済みの AppleScript:
"try《改行》
tell application \"Safari\"《改行》
set theCount to count of window《改行》
repeat with WindowNO from 1 to theCount《改行》
set theName to name of window WindowNO《改行》
if theName is \"名称未設定\" then《改行》
set safariText to text of document WindowNO《改行》
set aKeiFlag to 0《改行》
set aIdoFlag to 0《改行》
set Ido to \"\"《改行》
set Keido to \"\"《改行》" & "
repeat with aCount from 1 to (count text item of safariText)《改行》
set aitem to item aCount of safariText《改行》
if aIdoFlag is 0 or aIdoFlag is 1 then《改行》
if aitem is \"緯\" then《改行》
set aIdoFlag to aIdoFlag + 1《改行》
end if《改行》
else if aIdoFlag is 2 then《改行》
if aitem is \"度\" then《改行》
set aIdoFlag to 3《改行》
else《改行》
set Ido to Ido & aitem《改行》
end if《改行》
end if《改行》
if aKeiFlag is 0 or aKeiFlag is 1 then《改行》
if aitem is \"経\" then《改行》
set aKeiFlag to aKeiFlag + 1《改行》
end if《改行》
else if aKeiFlag is 2 then《改行》
if aitem is \"度\" then《改行》
set aKeiFlag to 3《改行》
exit repeat《改行》
else《改行》
set Keido to Keido & aitem《改行》
end if《改行》
end if《改行》
end repeat《改行》
exit repeat《改行》
end if《改行》
end repeat《改行》
tell application \"FileMaker Pro\"《改行》
set data cell \"緯度\" of current record of database \"" & Get ( ファイル名 ) & "\" to Ido《改行》
set data cell \"経度\" of current record of database \"" & Get ( ファイル名 ) & "\" to Keido《改行》
end tell《改行》
end tell《改行》
on error errMsg《改行》
display dialog \"エラーが発生しました。エラー内容:\" & errMsg《改行》
end try《改行》"

※このスクリプト「「ウォッちず」の経緯度取り込み」には上記の前に次の2つのステップとコメントが入っています.

・検索モードに切り替え [ ]
・ブラウズモードに切り替え
・# 上の2行はレコードが編集状態のときに"データは他のユーザ、スクリプト、またはトランザクションによって使用されています。"というエラーが出るのを防ぐためのものです。
コメントにも書いてありますが,ファイルメーカをアップルスクリプトで制御する場合.当該レコードが編集状態にあると「データは他のユーザ、スクリプト、またはトランザクションによって使用されています。」というエラーが出ます.上の2つのステップはそのエラーを防ぐためのものですが,この2つのステップが無くても動きます.そのエラーが出たら,okボタンを押してエラーメッセージを閉じ,レイアウトのフィールド以外のどこでも良いですからクリックしてカーソルがフィールド内に無いようにして,再度ボタンを押してください.

戻る