I've got an 8 column Outline View Table, each column of which has a Check Box installed. I need to add more rows, and each Check Box needs a unique Title, and the ability to alter the State. A total of 276 unique Check Boxes.
I just cannot get the code right, and Shane Stanley's Explored 5 doesn't help. In interface builder I have defined the valueof each Check Box to the key 'state', and the title to the key 'title’. I don’t expect Shane to answer this, much as I’d appreciate it, as I’m ‘persona non-gratis’ to him for offering criticism of Script Debugger on-line; (two major bugs, still un-fixed after many months). Ahh well. So, I’m hoping someone else will step forward.
'Saving errors reports, with (the last part), ', {Extensions1CB:{|title|:"X-Face", state:true}, Extensions2CB:{|title|:"XPM", state:true}, Extensions3CB:{|title|:"XWD", state:true}, Extensions4CB:{|title|:"YUV", state:true}, Extensions5CB:{|title|:"", state:false}, Extensions6CB:{|title|:"", state:false}, Extensions7CB:{|title|:"", state:false}, Extensions8CB:{|title|:"", state:false}}} doesn’t understand the “writeToFile_atomically_” message'.
Columns are defined as "Extensions1CB", "Extensions2CB", "Extensions3CB", "Extensions4CB", "Extensions5CB", "Extensions6CB", "Extensions7CB", "Extensions8CB"
I need to set the title and State of every Check Box, save them (as the Array Controllers contents), and read them.
Any advice appreciated. I've Googled for hours, to no real avail.
Regards
Santa
My code is...
NOTE, this is obviously wrong...
set anObj to (current application's NSMutableDictionary's dictionaryWithObjects:{item1CB, item2CB, item3CB, item4CB, item5CB, item6CB, item7CB, item8CB} forKeys:{"Extensions1CB", "Extensions2CB", "Extensions3CB", "Extensions4CB", "Extensions5CB", "Extensions6CB", "Extensions7CB", "Extensions8CB"})
--
-- AppDelegate.applescript
-- GC Name Extension lister
--
-- Created by Brian Christmas on 6/7/17.
-- Copyright © 2017 MeSelf Software. All rights reserved.
--
script AppDelegate
# property parent : class "NSObject"
property parent : class "ObjectWithFords"
-- IBOutlets
property ListWindow : missing value
property box1 : missing value
property ExtensionsArrayController : missing value
property listValues : ""
property firstCheckBox : missing value
property ListWindowSetUp : false
property ExtValueDict : {}
property mailManagerDesktopFolderPath : ((path to desktop as text) & "Mail Manager Folder:")
property setUpExtension : false
property extensionsToIgnore : {".D", "8BIM", "AAI", "Acorn Sprite", "AFP", "ALIAS", "AMBER ARR", "AMC", "Analyze", "ANI", "ANPA", "Apple File Icon", "Apple Preferred", "ART", "ARW", "ASCII", "Atari Portfolio", "B3D", "Bio", "BioRad", "BLD", "BMP", "BSB", ¬
"BSP", "BUF", "BUM", "Byte-Array Hea- der File (.H)", "CALS", "c4", "CAM", "CALS", "CEL", "CGM", "Chyron", "cicn", "CINEON", "CISCOIpPhoneI mages", "CLP", "cri", "CRW", "CR2", "csource", "CT", "CUR", "CVG", "CWK", "DCS", "DCR", "DCX", "DDS", "DeltaVision", ¬
"DESR VFF", "DICoM", "Direct icns", "Diskus YUV", "DJ1000", "DL", "dm2/dm3", "DNG", "Doodle", "DPX", "Dr. Halo", "DrawIT", "ECW", "ElectronicImage", "EPSF", "ESM", "Facesaver", "Favicon ICO", "FAX", "FaxSTF", "fep", "fig", "First Publisher art", "FireViewer PDB", ¬
"FITS", "FLH/FLI/FLC", "FPX", "Freehand 10", "FUJI", "GATAN", "GEM", "GFX", "GIF", "GrayPaint", "GRP", "HAM", "HD Photo (wdp)", "HDR", "HP-GL/2", "HGT", "HMR", "HTC splashscreens", "IBL", "IBM PIC", "IC ? Imagic", "lcd5", "ICo/ICN", "IFF/LBM", "IM", "Image ->Finder", ¬
"ImageLab/PrintTechnic", "IMG/XIMG", "IMQ", "IPLab", "ithmb", "IRIS", "ISS", "j6i", "JBI", "JEDMICS C4", "JIF", "JNG", "JPEG/JFIF", "JPEG 2000", "JPF", "JPX", "KDC", "Keynote PICT", "KISS CEL", "Koala", "Kodak DCS", "KoNTRoN", "LDF", "Liberty IM", "LIFF", "LOGO", ¬
"Lotus-PIC", "LuraDocument", "LWF (LuraWave)", "MacDraw I", "MacPaint", "MAG", "MAYA-IFF", "MBM (Psion 5)", "Meteosat 5", "MDC", "Meteosat 5", "MHT", "MonkeyLogo", "MonkeyCard", "Mov", "MPO", "MP2", "MRC", "MrSID", "MRW", "MSP", "MSX MSX2, MSX+ - MSX2+", "NAA/IPTC", ¬
"NASA Raster Metafile", "NEF", "NEO", "NGG/NCG", "NIF", "NIST PCT", "Nokia .pict", "NoL", "NV12", "ODF", "oNCoR", "ORF", "OTA", "P ? ? Degas", "Palette", "Palm image stream", "PAM", "PAC STAD", "PaperPort (MAX)", "PBM/PGM/PPM", "PCD", "PCX", "PIC (32K)", "PIC", ¬
"PIC", "PIC", "PICS", "PICT", "PICT resource", "PDB", "PDF", "PDS3", "PEF", "PFM", "PGC/PGF", "Photo PDB", "Photostudio", "PGPF", "PGC/PGF", "Photo Raw", "PIX", "PM", "PNG", "PoRST", "PowerPoint", "Ppat", "PSD", "PSP", "PTG", "PWP", "Pxx - Degas", "QDV", "QNT", "QTIF", ¬
"QTL", "RAF", "RAW", "RDC", "RIFF", "RLA", "RLE", "RSB", "RTF", "RW2", "SCR", "SCR", "Scrap", "ScreenShot Hack PDB", "SCX", "SFF", "SFW", "SGI", "SHP", "SHS", "SIGMA SD10 raw", "Sinclair QL", "SIXEL", "SKETCH", "SMV", "SNX", "SoFTIMAGE", "SPC", "SRF", "ST X SBIG", "StartupScreen s", ¬
"STV", "SUN", "Super-Hi-Res 3200", "SVG", "SWF", "System 7 clip", "TBC", "TCL", "TealPaint PDB", "TEX", "TGA", "TIFF", "TIM PSX", "Tiny Viewer PDB", "TN ?", "TRS-80", "VBM", "VFF", "VGS-8", "VITRoNIC", "VoXEL", "VPB", "VPM", "WBIN", "WBMP", "wbz", "wdb", "Webp", "Winfax (FXM)", "Winmail.dat", ¬
"WMF", "WPG", "X11", "X3F", "XBM", "XCF", "XFIG", "X-Face", "XPM", "XWD", "YUV"} -- "asc" is signature
on applicationWillFinishLaunching:aNotification
-- Insert code here to initialize your application before any files are opened
tell me to activate
my displayExtensionsWindow()
end applicationWillFinishLaunching:
on displayExtensionsWindow()
try
set p to 2
set (my setUpExtension) to true
set p to 3
set theflag to true
tell application "Finder"
if not (exists file ((my mailManagerDesktopFolderPath as text) & "Extension Data.plist")) then
set theflag to false
end if
end tell
if not theflag then
set p to 3.1
set tempList to {}
set p to 3.2
ExtensionsArrayController's removeObjects:(ExtensionsArrayController's arrangedObjects())
set p to 3.3
repeat with i from 1 to (((((count of (my extensionsToIgnore)) + 7) div 8) * 8) - 1) by 8
try
set p to 3.31
set item1CB to (current application's NSDictionary's dictionaryWithObjects:{(item i of (my extensionsToIgnore) as text), true} forKeys:{"title", "state"}) # {title:(item i of (my extensionsToIgnore) as text), value:true}
on error
beep
set item1CB to (current application's NSDictionary's dictionaryWithObjects:{"", false} forKeys:{"title", "state"}) #{title:"", value:false}
end try
try
set p to 3.32
set item2CB to (current application's NSDictionary's dictionaryWithObjects:{(item (i + 1) of (my extensionsToIgnore) astext), true} forKeys:{"title", "state"}) #{title:(item (i + 1) of (my extensionsToIgnore) as text), value:true}
on error
set item2CB to (current application's NSDictionary's dictionaryWithObjects:{"", false} forKeys:{"title", "state"}) #{title:"", value:false}
end try
try
set item3CB to (current application's NSDictionary's dictionaryWithObjects:{(item (i + 2) of (my extensionsToIgnore) astext), true} forKeys:{"title", "state"}) #{title:(item (i + 2) of (my extensionsToIgnore) as text), value:true}
on error
set item3CB to (current application's NSDictionary's dictionaryWithObjects:{"", false} forKeys:{"title", "state"}) #{title:"", value:false}
end try
try
set item4CB to (current application's NSDictionary's dictionaryWithObjects:{(item (i + 3) of (my extensionsToIgnore) astext), true} forKeys:{"title", "state"}) #{title:(item (i + 3) of (my extensionsToIgnore) as text), value:true}
on error
set item4CB to (current application's NSDictionary's dictionaryWithObjects:{"", false} forKeys:{"title", "state"}) #{title:"", value:false}
end try
try
set item5CB to (current application's NSDictionary's dictionaryWithObjects:{(item (i + 4) of (my extensionsToIgnore) astext), true} forKeys:{"title", "state"}) #{title:(item (i + 4) of (my extensionsToIgnore) as text), value:true}
on error
set item5CB to (current application's NSDictionary's dictionaryWithObjects:{"", false} forKeys:{"title", "state"}) #{title:"", value:false}
end try
try
set item6CB to (current application's NSDictionary's dictionaryWithObjects:{(item (i + 5) of (my extensionsToIgnore) astext), true} forKeys:{"title", "state"}) #{title:(item (i + 5) of (my extensionsToIgnore) as text), value:true}
on error
set item6CB to (current application's NSDictionary's dictionaryWithObjects:{"", false} forKeys:{"title", "state"}) #{title:"", value:false}
end try
try
set item7CB to (current application's NSDictionary's dictionaryWithObjects:{(item (i + 6) of (my extensionsToIgnore) astext), true} forKeys:{"title", "state"}) #{title:(item (i + 6) of (my extensionsToIgnore) as text), value:true}
on error
set item7CB to (current application's NSDictionary's dictionaryWithObjects:{"", false} forKeys:{"title", "state"}) #{title:"", value:false}
end try
try
set item8CB to (current application's NSDictionary's dictionaryWithObjects:{(item (i + 7) of (my extensionsToIgnore) astext), true} forKeys:{"title", "state"}) #{title:(item (i + 7) of (my extensionsToIgnore) as text), value:true}
on error
set item8CB to (current application's NSDictionary's dictionaryWithObjects:{"", false} forKeys:{"title", "state"}) #{title:"", value:false}
end try
set p to 3.4
set anObj to (current application's NSMutableDictionary's dictionaryWithObjects:{item1CB, item2CB, item3CB, item4CB, item5CB, item6CB, item7CB, item8CB} forKeys:{"Extensions1CB", "Extensions2CB", "Extensions3CB", "Extensions4CB", "Extensions5CB", "Extensions6CB", "Extensions7CB", "Extensions8CB"})
set p to 2
my (ExtensionsArrayController's addObject:anObj) — < DOES NOTHING
#set temp to {Extensions1:item1CB, Extensions2:item2CB, Extensions3:item3CB, Extensions4:item4CB, Extensions5:item5CB, Extensions6:item6CB, Extensions7:item7CB, Extensions8:item8CB}
set p to 3.5
#set tempArray to (current application's NSArray's arrayWithArray:temp)
set p to 3.51
end repeat
set p to 3.6
set (my ExtValueDict) to tempList
my fordEvent()
set p to 3.7
my SaveExtensionData()
else
set (my setUpExtension) to false
end if
set p to 4
try
tell ListWindow to display()
end try
my fordEvent()
set p to 5
try
tell me to activate
end try
ListWindow's makeKeyAndOrderFront:me
set p to 6
on error errmsg number errnum
tell application "System Events" to display dialog ("AppDelegate's displayExtensionsWindow " & " p = " & p & " " & errmsg as text)
end try
end displayExtensionsWindow
on SaveExtensionData()
try
set thePPath to POSIX path of ((my mailManagerDesktopFolderPath as text) & "Extension Data.plist") as text
end try
try
set ExtValueDict to ExtensionsArrayController's arrangedObjects() as list
on error errmsg number errnum
say "Extension Array controller"
set ExtValueDict to {}
tell application "System Events" to display dialog ("SaveExtensionData " & errmsg as text) giving up after 20
end try
try
say 2000
tell application id "com.apple.systemevents"
ExtValueDict's writeToFile:thePPath atomically:true —< ERRORS
end tell
on error errmsg number errnum
tell application "System Events" to display dialog ("AppDelegate's SaveExtensionData " & errmsg as text)
end try
end SaveExtensionData
on applicationShouldTerminate:sender
-- Insert code here to do any housekeeping before your application quits
return current application's NSTerminateNow
end applicationShouldTerminate:
end script