AppleScript リストの値を更新する

AppleScript リストの値を更新する

AppleScriptで、リストの値を更新する手順を記述してます。

環境

  • ProductName: macOS
  • ProductVersion: 11.6
  • BuildVersion: 20G165

リストの値を更新

リストの値を更新するには、「set item of to」を使用します。

set 変数名 item 位置 of to 値

実際に、以下のコードで「test.scpt」というファイル名で作成して、リストの値を更新してみます。

set l to [1, 2, 8]

set item 3 of l to 80

l

実行してみます。

osascript test.scpt

実行結果

更新されていることが確認できます。

入れ子になっている値も更新可能です。

set l to  {{1, 2, 3},{4, 5, 6},{7, 8, 9}}

set item 3 of l to {70,80,90}

l

実行結果