ネットワークドライブをマウントしようとするとエラー番号 -1700 が表示される

ネットワークドライブをマウントしようとするとエラー番号 -1700 が表示される

私は AppleScript をあまり使用しませんが、自宅にいるか外出中かに基づいてネットワーク ドライブをマウントする短いスクリプトを作成しました。

set SSID to do shell script "/System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport -I | awk '/ SSID: / {print $2}'"

if SSID is "MyHomeSSID" then 
    mount volume "afp://my_local_home_server_address.local"
else if mount volume "afp://address_to_my_home_server:port" then

end if

これを実行すると、マウントするボリュームを選択できるウィンドウが表示されますが、次のエラーが表示されます。

error "Can’t make file \"Drive:\" into type boolean." number -1700 from file "Drive:" to boolean

これをエラーなしで動作させる方法がわかりません。

答え1

発生しているエラーは次のとおりです:

error "Can’t make file \"Drive:\" into type boolean." number -1700 from file "Drive:" to boolean

犯人はこれです:

    else if mount volume "afp://address_to_my_home_server:port" then

理由がわかりますか?[ ヒント:boolean値はtrueおよびですfalse]

制御ステートメントの最後の半分をif...then...else次のように再構築する必要があります。

    if SSID is "MyHomeSSID" then 
        mount volume "afp://my_local_home_server_address.local"
    else 
        mount volume "afp://address_to_my_home_server:port"
    end if

関連情報