Date   
moderated Re: Trying to set up 8 column Table with 276 embedded Check Boxes.

 


On Jul 8, 2017, at 6:51 PM, Brian Christmas <ozsanta@...> wrote:

G'day, and thanks Jens. Sorry for overstepping the etiquette. I actually posted to both lists, hopefully, but it's an ASObC Project, so I think it belongs here, or else, why not please? Does the Applescript list cover these Projects?

The objc list (like Apple’s objc-language list) is for discussing the Objective-C language itself (and its core runtime library), not any frameworks written in it.

So topics like property syntax, or ARC, or objc_msgsend are OK; but not AppKit or UIKit or AppleScript.

—Jens

moderated Re: Trying to set up 8 column Table with 276 embedded Check Boxes.

Brian Christmas
 

G'day, and thanks Jens. Sorry for overstepping the etiquette. I actually posted to both lists, hopefully, but it's an ASObC Project, so I think it belongs here, or else, why not please? Does the Applescript list cover these Projects?

I've been battling with the code, and simplified it, so I'll just post snippets, if that's OK.

                                         try

  set item1CBVisible to true # (current application's NSMutableDictionary's dictionaryWithObjects:{true} forKeys:{value})

set item1CBTitle to (item (i) of (my extensionsToIgnore) as text) #}

on error

  set item1CBVisible to false # (current application's NSMutableDictionary's dictionaryWithObjects:{false} forKeys:{value})

set item1CBTitle to "" #} forKeys:{title})

end try

  set temp to (current application's NSMutableDictionary's dictionaryWithObjects:{item1CBVisible, item1CBTitle} forKeys:{Extensions1CBValue, Extensions1CBTitle})

set anObj to {Extensions1CB:temp}

I think  that should be OK, but this next is failing, with the BOOL error. (Column 1 is bound to Extensions1CBValue).

(ExtensionsArrayController's addObjects:anObj)

I think that in turn is caused by my inability to find a way of setting the value and title of the checkbox cell to the Array Controllers nested values. I've tried to address both directly with Extensions1CBValueExtensions1CBTitle  with no result except the BOOL error. Then I tried setting a path, Extensions1CB:Extensions1CBValue using every type of separator I could think of; comma, full stop, colon, and what's shown below (a reference). All result in the BOOL error.

Does anyone know what's wrong please. Or, can someone guide me on whats the correct method of addressing nested values in an Array Controller?

Regards

Santa



 

moderated Re: Trying to set up 8 column Table with 276 embedded Check Boxes.

 

I think you meant to send this to the applescript list instead.

Also, it’s generally not good etiquette to post long listings inline. Instead, upload the code to something like gist or pastebin, and put a link to it in your message.

—Jens

moderated Trying to set up 8 column Table with 276 embedded Check Boxes.

Brian Christmas
 

G'day scripters
 
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

moderated FYI: Mike Ash analyzes objc_msgsend

 

Mike Ash has been offline for a while, but his Friday Q&A is back with a detailed line-by-line analysis of the objc_msgsend function on ARM64. This is the core Objective-C runtime function that sends messages / calls methods on objects — every bracketed expression or property access turns into a call to this function (and so do Swift calls to @objc classes.) It’s written in assembly code to make it as fast as possible, and it’s very clever but it’s not magic; Mike explains it very well. I’m always fascinated to find out how these kinds of things work.

—Jens