AppleScript NSMutableArray

[NSSet]Arrayの重複項目を除去


【スクリプトエディタで開く】|

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use scripting additions

property refMe : a reference to current application

set strText to "美しい日本語1"

set ocidArrayM to refMe's NSMutableArray's alloc()'s initWithCapacity:0
ocidArrayM's addObject:strText

set listArray to {"美しい日本語1", "美しい日本語2", "美しい日本語3"} as list
ocidArrayM's addObjectsFromArray:listArray

log ocidArrayM as list
-->(*美しい日本語1, 美しい日本語1, 美しい日本語2, 美しい日本語3*)

##重複削除
set ocidTrimArray to ocidArrayM's valueForKeyPath:("@distinctUnionOfObjects.self")
log ocidTrimArray as list
-->(*美しい日本語2, 美しい日本語3, 美しい日本語1*)

##重複削除 NSset
set ocidArraySet to refMe's NSSet's setWithArray:(ocidArrayM)
set ocidTrimArray to ocidArraySet's allObjects()
log ocidTrimArray as list
-->(*美しい日本語2, 美しい日本語3, 美しい日本語1*)

##並び替え
set ocidSortedArray to ocidTrimArray's sortedArrayUsingSelector:("localizedCaseInsensitiveCompare:")
log ocidSortedArray as list
-->(*美しい日本語2, 美しい日本語3, 美しい日本語1*)

repeat with itemSortedArray in ocidSortedArray
  log itemSortedArray as text
end repeat


repeat with itemNo from 0 to (count of ocidSortedArray) - 1 by 1
  log (ocidSortedArray's objectAtIndex:(itemNo)) as text
end repeat



|

[sortedArrayUsingSelector]重複行を調べる

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7

use AppleScript version "2.8"
use framework "Foundation"
use scripting additions


property objMe : a reference to current application
property objNSString : a reference to objMe's NSString
property objNSURL : a reference to objMe's NSURL
property objNSMutableString : a reference to objMe's NSMutableString
property objNSArray : a reference to objMe's NSArray
property objNSMutableArray : a reference to objMe's NSMutableArray
property objNSCharacterSet : a reference to objMe's NSCharacterSet



####ダイアログで使うデフォルトロケーション
tell application "Finder"
##set aliasDefaultLocation to container of (path to me) as alias
set aliasDefaultLocation to (path to desktop folder from user domain) as alias
end tell

####UTIリスト
set listUTI to {"public.plain-text"}

####ダイアログを出す
set aliasFilePath to (choose file with prompt "PDFファイルを選んでください" default location (aliasDefaultLocation) of type listUTI with invisibles and showing package contents without multiple selections allowed) as alias

set strFilePath to POSIX path of aliasFilePath
####ドキュメントのパスをNSString
set ocidFilePath to objNSString's stringWithString:strFilePath
####ドキュメントのパスをNSURL
set ocidFilePathURL to objNSURL's alloc()'s initFileURLWithPath:ocidFilePath

####################################
###読み込みデータの格納先の初期化
set ocidReadData to objNSMutableString's alloc()'s initWithCapacity:0
####データ読み込み
set ocidReadData to objNSMutableString's stringWithContentsOfURL:ocidFilePathURL encoding:(objMe's NSUTF8StringEncoding) |error|:(missing value)
#####並び替え用のリストの初期化
set ocidMutableArray to objNSMutableArray's alloc()'s initWithCapacity:0
#####改行を区切り文字に
set ocidNewlineCharacterSett to objNSCharacterSet's newlineCharacterSet()
#####テキストをリストに格納
set ocidMutableArray to ocidReadData's componentsSeparatedByCharactersInSet:ocidNewlineCharacterSett


####################################
###並び替え
set ocidSelf to objNSString's stringWithString:"self"
####並び替え実行
set ocidSortedArray to ocidMutableArray's sortedArrayUsingSelector:"localizedCaseInsensitiveCompare:"

log ocidSortedArray as list
log className() of ocidSortedArray as text


##################
####ソートされたリストを再格納
set ocidMutableArray to objNSMutableArray's alloc()'s initWithCapacity:0
ocidMutableArray's addObjectsFromArray:ocidSortedArray
####リストの数を数えて
set numCntArrayData to count of ocidMutableArray
####0スタートなので1つ引いた数を総数に
set numCntNo to (numCntArrayData - 1) as number
####リストの数だけ繰り返し
repeat numCntArrayData times
####A:カウント番号の内容(処理はリストの最後から前へ向かう)
set strItemA to (ocidMutableArray's objectAtIndex:(numCntNo as number)) as text
log strItemA
####B:カウント番号の1つ手前のリストの内容
set numCntBeforNo to numCntNo - 1 as number
set strItemB to (ocidMutableArray's objectAtIndex:(numCntBeforNo as number)) as text
log strItemB
#####ABが内容が同じなら=内容が重複していない場合
if strItemA is not strItemB then
####カウント番号の項目を削除する
ocidMutableArray's removeObjectAtIndex:numCntNo
end if
set numCntNo to numCntNo - 1 as number
#####最後の行は処理しない
if numCntNo = 0 then
exit repeat
end if
end repeat
#####重複内容のリスト
log ocidMutableArray as list
####################################
######出力先パス
set strOutFilePath to (strFilePath & ".out.txt") as text
set ocidOutFilePathURL to objNSURL's alloc()'s initFileURLWithPath:strOutFilePath
####出力用のテキストの初期化
set ocidOutPutStrings to objNSMutableString's alloc()'s initWithCapacity:0

#####リスト毎に改行を入れて
repeat with objMutableArray in ocidMutableArray
(ocidOutPutStrings's appendString:(objMutableArray as text))
log objMutableArray as text
(ocidOutPutStrings's appendString:("\n"))
end repeat

####出力
set boolWritetoUrlArray to ocidOutPutStrings's writeToURL:ocidOutFilePathURL atomically:true encoding:(objMe's NSUTF8StringEncoding) |error|:(reference)

|

[NSMutableArray]基本 セット編

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7

use AppleScript version "2.8"
use framework "Foundation"
use framework "PDFkit"
use scripting additions

property refMe : a reference to current application
property refNSArray : a reference to refMe's NSArray
property refNSMutableArray : a reference to refMe's NSMutableArray

###初期化
set ocidNewArrayM to refNSMutableArray's alloc()'s initWithCapacity:0
set ocidNewArrayM to refNSMutableArray's alloc()'s init()
log ocidNewArrayM as list
log className() of ocidNewArrayM as text
-->(*__NSArrayM*)

#####前から順に追加
ocidNewArrayM's insertObject:"5番目" atIndex:0
log ocidNewArrayM as list
(*5番目*)

#####前から順に追加insertObject
ocidNewArrayM's insertObject:"1番目" atIndex:0
log ocidNewArrayM as list
(*1番目, 5番目*)

#####後ろに追加addObject
ocidNewArrayM's addObject:"8番目"
log ocidNewArrayM as list
(*1番目, 5番目, 8番目*)


#####後ろにリストで追加addObjectsFromArray
set listAddArray to {"7番目", "9番目", "10番目"} as list
ocidNewArrayM's addObjectsFromArray:listAddArray
log ocidNewArrayM as list
(*1番目, 5番目, 8番目, 7番目, 9番目, 10番目*)

#####順番変更 8と7 indexで2と3を入れ替えるwithObjectAtIndex
ocidNewArrayM's exchangeObjectAtIndex:2 withObjectAtIndex:3
log ocidNewArrayM as list
(*1番目, 5番目, 7番目, 8番目, 9番目, 10番目*)

#####最初を1に2番目を3にatIndexes
set listAddArray to {"4番目", "6番目"} as list
set ocidNSIndex to refMe's NSMutableIndexSet's alloc()'s init()
ocidNSIndex's addIndex:1
ocidNSIndex's addIndex:3
log ocidNSIndex as list
ocidNewArrayM's insertObjects:listAddArray atIndexes:ocidNSIndex
log ocidNewArrayM as list
(*1番目, 4番目, 5番目, 6番目, 7番目, 8番目, 9番目, 10番目*)

#####置き換えatIndexedSubscript
set listAddArray to {"1番目", "2番目"} as list
ocidNewArrayM's setObject:listAddArray atIndexedSubscript:0
log ocidNewArrayM as list
(*1番目, 2番目, 4番目, 5番目, 6番目, 7番目, 8番目, 9番目, 10番目*)

##置き換えreplaceObjectsInRange
set listAddArray to {"1番目", "2番目", "3番目"} as list
set ocidNSRange to refMe's NSMakeRange(0, 1)
ocidNewArrayM's replaceObjectsInRange:ocidNSRange withObjectsFromArray:listAddArray
log ocidNewArrayM as list
(*1番目, 2番目, 3番目, 4番目, 5番目, 6番目, 7番目, 8番目, 9番目, 10番目*)


###解放
ocidNewArrayM's release()


|

[NSMutableArray] removeObjectsAtIndexes Rangeで指定した範囲の項目を削除

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
##自分環境がos12なので2.8にしているだけです
use AppleScript version "2.8"
use framework "Foundation"
use scripting additions

######ログ表示
doLogView()

property objMe : a reference to current application
property objNSString : a reference to objMe's NSString
property objNSMutableString : a reference to objMe's NSMutableString

property objNSArray : a reference to objMe's NSArray
property objNSMutableArray : a reference to objMe's NSMutableArray


set ocidMutableArray to objNSMutableArray's alloc()'s initWithCapacity:0
log ocidMutableArray as list
log className() of ocidMutableArray as text

set listArray to {"D", "E", "F"} as list

ocidMutableArray's addObjectsFromArray:listArray
log ocidMutableArray as list
log className() of ocidMutableArray as text

set listSampleB to {"A", "B", "C"} as list

####NSArray
set ocidNSFrozenArrayM to objNSArray's alloc()'s initWithArray:listSampleB
log ocidNSFrozenArrayM as list
log className() of ocidNSFrozenArrayM as text



set ocidIndexSet to objMe's NSMutableIndexSet's alloc()'s init()
log ocidIndexSet
log className() of ocidIndexSet as text
ocidIndexSet's addIndex:0
ocidIndexSet's addIndex:1
ocidIndexSet's addIndex:2
log ocidIndexSet
log className() of ocidIndexSet as text

ocidMutableArray's insertObjects:ocidNSFrozenArrayM atIndexes:ocidIndexSet
log ocidMutableArray as list
log className() of ocidMutableArray as text


set ocidNsRange to objMe's NSMakeRange(3, 3)
log class of ocidNsRange
log ocidNsRange as record



ocidMutableArray's removeObjectsInRange:ocidNsRange
log ocidMutableArray as list
log className() of ocidMutableArray as text



#########################ログ表示
to doLogView()

tell application "System Events"
set listAppList to title of (every process where background only is false)
end tell
repeat with objAppList in listAppList
set strAppList to objAppList as text
if strAppList is "スクリプトエディタ" then
tell application "Script Editor"
if frontmost is true then
try
tell application "System Events" to click menu item "ログを表示" of menu "表示" of menu bar item "表示" of menu bar 1 of application process "Script Editor"
end try
end if
end tell
tell application "Script Editor"
tell application "System Events"
tell process "Script Editor"
tell window 1
tell splitter group 1
tell splitter group 1
tell group 1
tell checkbox "返された値"
set boolValue to value as boolean
end tell
if boolValue is false then
click checkbox "返された値"
end if
end tell
end tell
end tell
end tell
end tell
end tell
end tell
end if
end repeat

end doLogView
#########################

|

[NSMutableArray] removeObjectsAtIndexes NSindexで指定した範囲の項目を削除

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
##自分環境がos12なので2.8にしているだけです
use AppleScript version "2.8"
use framework "Foundation"
use scripting additions

######ログ表示
doLogView()

property objMe : a reference to current application
property objNSString : a reference to objMe's NSString
property objNSMutableString : a reference to objMe's NSMutableString

property objNSArray : a reference to objMe's NSArray
property objNSMutableArray : a reference to objMe's NSMutableArray


set ocidMutableArray to objNSMutableArray's alloc()'s initWithCapacity:0
log ocidMutableArray as list
log className() of ocidMutableArray as text

set listArray to {"D", "E", "F"} as list

ocidMutableArray's addObjectsFromArray:listArray
log ocidMutableArray as list
log className() of ocidMutableArray as text

set listSampleB to {"A", "B", "C"} as list

####NSArray
set ocidNSFrozenArrayM to objNSArray's alloc()'s initWithArray:listSampleB
log ocidNSFrozenArrayM as list
log className() of ocidNSFrozenArrayM as text



set ocidIndexSet to objMe's NSMutableIndexSet's alloc()'s init()
log ocidIndexSet
log className() of ocidIndexSet as text
ocidIndexSet's addIndex:0
ocidIndexSet's addIndex:1
ocidIndexSet's addIndex:2
log ocidIndexSet
log className() of ocidIndexSet as text

ocidMutableArray's insertObjects:ocidNSFrozenArrayM atIndexes:ocidIndexSet
log ocidMutableArray as list
log className() of ocidMutableArray as text


set ocidDelIndexSet to objMe's NSMutableIndexSet's alloc()'s init()
log ocidDelIndexSet
log className() of ocidDelIndexSet as text
ocidDelIndexSet's addIndex:3
ocidDelIndexSet's addIndex:4
ocidDelIndexSet's addIndex:5
log ocidDelIndexSet
log className() of ocidDelIndexSet as text

ocidMutableArray's removeObjectsAtIndexes:ocidDelIndexSet
log ocidMutableArray as list
log className() of ocidMutableArray as text



#########################ログ表示
to doLogView()

tell application "System Events"
set listAppList to title of (every process where background only is false)
end tell
repeat with objAppList in listAppList
set strAppList to objAppList as text
if strAppList is "スクリプトエディタ" then
tell application "Script Editor"
if frontmost is true then
try
tell application "System Events" to click menu item "ログを表示" of menu "表示" of menu bar item "表示" of menu bar 1 of application process "Script Editor"
end try
end if
end tell
tell application "Script Editor"
tell application "System Events"
tell process "Script Editor"
tell window 1
tell splitter group 1
tell splitter group 1
tell group 1
tell checkbox "返された値"
set boolValue to value as boolean
end tell
if boolValue is false then
click checkbox "返された値"
end if
end tell
end tell
end tell
end tell
end tell
end tell
end tell
end if
end repeat

end doLogView
#########################

|

[NSMutableArray] removeObjectAtIndex ×番目を削除

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
##自分環境がos12なので2.8にしているだけです
use AppleScript version "2.8"
use framework "Foundation"
use scripting additions

######ログ表示
doLogView()

property objMe : a reference to current application
property objNSString : a reference to objMe's NSString
property objNSMutableString : a reference to objMe's NSMutableString

property objNSArray : a reference to objMe's NSArray
property objNSMutableArray : a reference to objMe's NSMutableArray


set ocidMutableArray to objNSMutableArray's alloc()'s initWithCapacity:0
log ocidMutableArray as list
log className() of ocidMutableArray as text

set listArray to {"D", "E", "F"} as list

ocidMutableArray's addObjectsFromArray:listArray
log ocidMutableArray as list
log className() of ocidMutableArray as text

set listSampleB to {"A", "B", "C"} as list

####NSArray
set ocidNSFrozenArrayM to objNSArray's alloc()'s initWithArray:listSampleB
log ocidNSFrozenArrayM as list
log className() of ocidNSFrozenArrayM as text



set ocidIndexSet to objMe's NSMutableIndexSet's alloc()'s init()
log ocidIndexSet
log className() of ocidIndexSet as text
ocidIndexSet's addIndex:0
ocidIndexSet's addIndex:1
ocidIndexSet's addIndex:2
log ocidIndexSet
log className() of ocidIndexSet as text

ocidMutableArray's insertObjects:ocidNSFrozenArrayM atIndexes:ocidIndexSet
log ocidMutableArray as list
log className() of ocidMutableArray as text



ocidMutableArray's removeObjectAtIndex:5
log ocidMutableArray as list
log className() of ocidMutableArray as text





#########################ログ表示
to doLogView()

tell application "System Events"
set listAppList to title of (every process where background only is false)
end tell
repeat with objAppList in listAppList
set strAppList to objAppList as text
if strAppList is "スクリプトエディタ" then
tell application "Script Editor"
if frontmost is true then
try
tell application "System Events" to click menu item "ログを表示" of menu "表示" of menu bar item "表示" of menu bar 1 of application process "Script Editor"
end try
end if
end tell
tell application "Script Editor"
tell application "System Events"
tell process "Script Editor"
tell window 1
tell splitter group 1
tell splitter group 1
tell group 1
tell checkbox "返された値"
set boolValue to value as boolean
end tell
if boolValue is false then
click checkbox "返された値"
end if
end tell
end tell
end tell
end tell
end tell
end tell
end tell
end if
end repeat

end doLogView
#########################

|

[NSMutableArray] insertObjects atIndexes NSIndexで指定したオブジェクトを挿入

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
##自分環境がos12なので2.8にしているだけです
use AppleScript version "2.8"
use framework "Foundation"
use scripting additions

######ログ表示
doLogView()

property objMe : a reference to current application
property objNSString : a reference to objMe's NSString
property objNSMutableString : a reference to objMe's NSMutableString

property objNSArray : a reference to objMe's NSArray
property objNSMutableArray : a reference to objMe's NSMutableArray


set ocidMutableArray to objNSMutableArray's alloc()'s initWithCapacity:0
log ocidMutableArray as list
log className() of ocidMutableArray as text

set listArray to {"D", "E", "F"} as list

ocidMutableArray's addObjectsFromArray:listArray
log ocidMutableArray as list
log className() of ocidMutableArray as text

set listSampleB to {"A", "B", "C"} as list

####NSArray
set ocidNSFrozenArrayM to objNSArray's alloc()'s initWithArray:listSampleB
log ocidNSFrozenArrayM as list
log className() of ocidNSFrozenArrayM as text



set ocidIndexSet to objMe's NSMutableIndexSet's alloc()'s init()
log ocidIndexSet
log className() of ocidIndexSet as text
ocidIndexSet's addIndex:0
ocidIndexSet's addIndex:1
ocidIndexSet's addIndex:2
log ocidIndexSet
log className() of ocidIndexSet as text

ocidMutableArray's insertObjects:ocidNSFrozenArrayM atIndexes:ocidIndexSet
log ocidMutableArray as list
log className() of ocidMutableArray as text

#########################ログ表示
to doLogView()

tell application "System Events"
set listAppList to title of (every process where background only is false)
end tell
repeat with objAppList in listAppList
set strAppList to objAppList as text
if strAppList is "スクリプトエディタ" then
tell application "Script Editor"
if frontmost is true then
try
tell application "System Events" to click menu item "ログを表示" of menu "表示" of menu bar item "表示" of menu bar 1 of application process "Script Editor"
end try
end if
end tell
tell application "Script Editor"
tell application "System Events"
tell process "Script Editor"
tell window 1
tell splitter group 1
tell splitter group 1
tell group 1
tell checkbox "返された値"
set boolValue to value as boolean
end tell
if boolValue is false then
click checkbox "返された値"
end if
end tell
end tell
end tell
end tell
end tell
end tell
end tell
end if
end repeat

end doLogView
#########################

|

[NSMutableArray] insertObject Array形式 リスト形式を指定の場所に追加

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
##自分環境がos12なので2.8にしているだけです
use AppleScript version "2.8"
use framework "Foundation"
use scripting additions

######ログ表示
doLogView()

property objMe : a reference to current application
property objNSString : a reference to objMe's NSString
property objNSMutableString : a reference to objMe's NSMutableString

property objNSArray : a reference to objMe's NSArray
property objNSMutableArray : a reference to objMe's NSMutableArray


set ocidMutableArray to objNSMutableArray's alloc()'s initWithCapacity:0
log ocidMutableArray as list
log className() of ocidMutableArray as text

set listArray to {"D", "E", "F"} as list

ocidMutableArray's addObjectsFromArray:listArray
log ocidMutableArray as list
log className() of ocidMutableArray as text

set listSampleB to {"A", "B", "C"} as list

####NSArray
set ocidNSFrozenArrayM to objNSArray's alloc()'s initWithArray:listSampleB
log ocidNSFrozenArrayM as list
log className() of ocidNSFrozenArrayM as text


ocidMutableArray's insertObject:ocidNSFrozenArrayM atIndex:0
log ocidMutableArray as list
log className() of ocidMutableArray as text

#########################ログ表示
to doLogView()

tell application "System Events"
set listAppList to title of (every process where background only is false)
end tell
repeat with objAppList in listAppList
set strAppList to objAppList as text
if strAppList is "スクリプトエディタ" then
tell application "Script Editor"
if frontmost is true then
try
tell application "System Events" to click menu item "ログを表示" of menu "表示" of menu bar item "表示" of menu bar 1 of application process "Script Editor"
end try
end if
end tell
tell application "Script Editor"
tell application "System Events"
tell process "Script Editor"
tell window 1
tell splitter group 1
tell splitter group 1
tell group 1
tell checkbox "返された値"
set boolValue to value as boolean
end tell
if boolValue is false then
click checkbox "返された値"
end if
end tell
end tell
end tell
end tell
end tell
end tell
end tell
end if
end repeat

end doLogView
#########################

|

[NSMutableArray] addObjectsFromArray Array形式 リスト形式を追加

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
##自分環境がos12なので2.8にしているだけです
use AppleScript version "2.8"
use framework "Foundation"
use scripting additions

######ログ表示
doLogView()

property objMe : a reference to current application
property objNSString : a reference to objMe's NSString
property objNSMutableString : a reference to objMe's NSMutableString

property objNSArray : a reference to objMe's NSArray
property objNSMutableArray : a reference to objMe's NSMutableArray


set ocidMutableArray to objNSMutableArray's alloc()'s initWithCapacity:0
log ocidMutableArray as list
log className() of ocidMutableArray as text

set listArray to {"A", "B", "C"} as list

ocidMutableArray's addObjectsFromArray:listArray
log ocidMutableArray as list
log className() of ocidMutableArray as text

set listSampleB to {"D", "E", "F"} as list

####NSArray
set ocidNSFrozenArrayM to objNSArray's alloc()'s initWithArray:listSampleB
log ocidNSFrozenArrayM as list
log className() of ocidNSFrozenArrayM as text


ocidMutableArray's addObjectsFromArray:ocidNSFrozenArrayM
log ocidMutableArray as list
log className() of ocidMutableArray as text

#########################ログ表示
to doLogView()

tell application "System Events"
set listAppList to title of (every process where background only is false)
end tell
repeat with objAppList in listAppList
set strAppList to objAppList as text
if strAppList is "スクリプトエディタ" then
tell application "Script Editor"
if frontmost is true then
try
tell application "System Events" to click menu item "ログを表示" of menu "表示" of menu bar item "表示" of menu bar 1 of application process "Script Editor"
end try
end if
end tell
tell application "Script Editor"
tell application "System Events"
tell process "Script Editor"
tell window 1
tell splitter group 1
tell splitter group 1
tell group 1
tell checkbox "返された値"
set boolValue to value as boolean
end tell
if boolValue is false then
click checkbox "返された値"
end if
end tell
end tell
end tell
end tell
end tell
end tell
end tell
end if
end repeat

end doLogView
#########################

|

[NSMutableArray] addObject リスト形式を追加

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
##自分環境がos12なので2.8にしているだけです
use AppleScript version "2.8"
use framework "Foundation"
use scripting additions

######ログ表示
doLogView()

property objMe : a reference to current application
property objNSString : a reference to objMe's NSString
property objNSMutableString : a reference to objMe's NSMutableString

property objNSArray : a reference to objMe's NSArray
property objNSMutableArray : a reference to objMe's NSMutableArray


set ocidMutableArray to objNSMutableArray's alloc()'s initWithCapacity:0
log ocidMutableArray as list
log className() of ocidMutableArray as text

set listArray to {"A", "B", "C"} as list

ocidMutableArray's addObject:listArray
log ocidMutableArray as list
log className() of ocidMutableArray as text


#########################ログ表示
to doLogView()

tell application "System Events"
set listAppList to title of (every process where background only is false)
end tell
repeat with objAppList in listAppList
set strAppList to objAppList as text
if strAppList is "スクリプトエディタ" then
tell application "Script Editor"
if frontmost is true then
try
tell application "System Events" to click menu item "ログを表示" of menu "表示" of menu bar item "表示" of menu bar 1 of application process "Script Editor"
end try
end if
end tell
tell application "Script Editor"
tell application "System Events"
tell process "Script Editor"
tell window 1
tell splitter group 1
tell splitter group 1
tell group 1
tell checkbox "返された値"
set boolValue to value as boolean
end tell
if boolValue is false then
click checkbox "返された値"
end if
end tell
end tell
end tell
end tell
end tell
end tell
end tell
end if
end repeat

end doLogView
#########################

|

より以前の記事一覧

その他のカテゴリー

Acrobat Acrobat Annotation Acrobat Dialog Acrobat Form Acrobat JS Acrobat Open Acrobat Plugin Acrobat python Acrobat Reader Acrobat Sequ Acrobat Stamps Admin Admin Account Admin Apachectl Admin configCode Admin Device Management Admin LaunchServices Admin Locationd Admin loginitem Admin Maintenance Admin Permission Admin Pkg Admin Power Management Admin Printer Admin SetUp Admin SMB Admin System Information Admin Tools Admin Users Admin Volumes Adobe Apple AppleScript AppleScript Guide AppleScript Accessibility AppleScript AppKit AppleScript Applications AppleScript AppStore AppleScript Archive AppleScript Attributes AppleScript Automator AppleScript AVAsset AppleScript AVconvert AppleScript AVFoundation AppleScript AVURLAsset AppleScript BackUp AppleScript Barcode AppleScript Bash AppleScript Basic AppleScript Basic Path AppleScript Bluetooth AppleScript BOX AppleScript Browser AppleScript Calendar AppleScript CD/DVD AppleScript Choose AppleScript Chrome AppleScript CIImage AppleScript CloudStorage AppleScript Color AppleScript com.apple.LaunchServices.OpenWith AppleScript Console AppleScript Contacts AppleScript CotEditor AppleScript CURL AppleScript current application AppleScript Date&Time AppleScript delimiters AppleScript Desktop AppleScript Device AppleScript Disk AppleScript do shell script AppleScript Dock AppleScript DropBox AppleScript eMail AppleScript Encode Decode AppleScript Error AppleScript EXIFData AppleScript ffmpeg AppleScript File AppleScript Finder AppleScript Firefox AppleScript Folder AppleScript Fonts AppleScript GIF AppleScript HTML AppleScript Icon AppleScript Illustrator AppleScript Image Events AppleScript Image2PDF AppleScript ImageOptim Applescript iWork AppleScript Javascript AppleScript Jedit AppleScript Json AppleScript Label AppleScript List AppleScript locationd AppleScript LRC AppleScript LSSharedFileList AppleScript m3u8 AppleScript MakePDF AppleScript Map AppleScript Math AppleScript Microsoft AppleScript Microsoft Edge AppleScript Microsoft Excel AppleScript Mobileconfig AppleScript Mouse AppleScript Movie AppleScript Music AppleScript NetWork AppleScript Notes AppleScript NSArray AppleScript NSBitmapImageRep AppleScript NSBundle AppleScript NSCFBoolean AppleScript NSCharacterSet AppleScript NSColor AppleScript NSColorList AppleScript NSData AppleScript NSDictionary AppleScript NSError AppleScript NSEvent AppleScript NSFileAttributes AppleScript NSFileManager AppleScript NSFont AppleScript NSFontManager AppleScript NSImage AppleScript NSIndex AppleScript NSKeyedArchiver AppleScript NSKeyedUnarchiver AppleScript NSLocale AppleScript NSMutableArray AppleScript NSMutableDictionary AppleScript NSMutableString AppleScript NSNotFound AppleScript NSNumber AppleScript NSOpenPanel AppleScript NSPasteboard AppleScript NSPDFImageRep AppleScript NSpoint AppleScript NSPredicate AppleScript NSRange AppleScript NSRegularExpression AppleScript NSRunningApplication AppleScript NSScreen AppleScript NSSize AppleScript NSString AppleScript NSStringCompareOptions AppleScript NSTask AppleScript NSTimeZone AppleScript NSURL AppleScript NSURL File AppleScript NSURLBookmark AppleScript NSURLComponents AppleScript NSURLResourceKey AppleScript NSUserDefaults AppleScript NSUUID AppleScript NSView AppleScript NSWorkspace AppleScript Numbers AppleScript OAuth AppleScript ObjC AppleScript OneDrive AppleScript Osax AppleScript PDF AppleScript PDFAnnotationWidget AppleScript PDFContext AppleScript PDFDisplayBox AppleScript PDFDocumentPermissions AppleScript PDFKit AppleScript PDFnUP AppleScript PDFOutline AppleScript Photos AppleScript Photoshop AppleScript Plist System Events AppleScript PostScript AppleScript prefPane AppleScript Preview AppleScript Python AppleScript QR AppleScript QR Decode AppleScript QuickLook AppleScript QuickTime AppleScript record AppleScript Regular Expression AppleScript Reminders AppleScript ReName AppleScript Repeat AppleScript RTF AppleScript Safari AppleScript SaveFile AppleScript ScreenCapture AppleScript ScreenSaver AppleScript Script Editor AppleScript Script Menu AppleScript Shortcuts AppleScript Shortcuts Events AppleScript Sort AppleScript Sound AppleScript Spotlight AppleScript SRT AppleScript StandardAdditions AppleScript stringByApplyingTransform AppleScript System Events AppleScript System Settings AppleScript TemporaryItems AppleScript Terminal AppleScript Text AppleScript Text CSV AppleScript Text TSV AppleScript TextEdit AppleScript Translate AppleScript Trash AppleScript Twitter AppleScript UI AppleScript Unit Conversion AppleScript UTType AppleScript valueForKeyPath AppleScript Video AppleScript VisionKit AppleScript Visual Studio Code AppleScript webarchive AppleScript webp AppleScript Wifi AppleScript XML AppleScript XML EPUB AppleScript XML OPML AppleScript XML Plist AppleScript XML RSS AppleScript XML SVG AppleScript XML TTML AppleScript XML webloc AppleScript YouTube AppleScript Zero Suppress Applications Barcode OnLine Tools CityCode Design iPhone List Logs lsappinfo Memo Music perl PlistBuddy pluginkit postalcode ReadMe SF Symbols character id SF Symbols Entity sips Skype Slack sqlite TCC Tools Typography Video Wacom zoom