AppleScript 条件式 if文を使用するサンプルコード
環境
macOS 11.6
書式
if 条件 then
処理コード
else 条件 then
処理コード
else
処理コード
end if
if 条件 then
処理コード
else 条件 then
処理コード
else
処理コード
end if
if 条件 then 処理コード else 条件 then 処理コード else 処理コード end if
AppleScriptで、条件式 if文を使用します。
操作例
ファイル名:data.scpt
サンプルコード
set n to 15
if n = 11 then
set x to "tokyo"
else if n = 15 then
set x to "oosaka"
else
set x to "not tokyo oosaka"
end if
x
set n to 15
if n = 11 then
set x to "tokyo"
else if n = 15 then
set x to "oosaka"
else
set x to "not tokyo oosaka"
end if
x
set n to 15 if n = 11 then set x to "tokyo" else if n = 15 then set x to "oosaka" else set x to "not tokyo oosaka" end if x
実行結果
osascript data.scpt
結果 oosaka