Dialog Toolkit raises an error after editing to remove a button

After an ill-advised attempt to expand a dialog toolkit dialog with an extra button I have reverted, I think.

That dialog when summoned by its containing script registers this alert at least once (sometimes two or three times) before the script actually draws the dialog:
120 doesn’t match the parameters «script theLeft» for «event !ASuCrLa». (-1721)

I’ve googled and dashed this error which suggests that its asking for more than the script expects but I cannot see it.

My focus is on this line:

set {theButtons, minWidth} to create buttons {"Cancel", "OK"} cancel button 1 default button 2 given «class btns»:2

which I know I previously edited to include an extra button. The “given «class btns»:2” confuses me because I can’t find any reference to it in the dictionary but in its expanded version I changed it to 3 and then back.

Can someone (Shane?) clarify this for me please?

Lee

on drawDialog()
	set theTop to 0
	set alertMessage to "Check which Scripts you want to Run"
	set theLabelStrings to {"Keep Server Up", "Document Loader", "Mount Network Drive", "Backup Script", "Hour Full Backup Runs-" & backupScriptRunHourStartRO, "Min Start-" & backupScriptRunMinStartRO, "Min End-" & backupScriptRunMinStopRO, "Production Mode"}
	set maxLabelWidth to max width for labels theLabelStrings
	
	--set controlLeft to maxLabelWidth / 4 - 32
	--set accViewWidth to 600
	
	set controlLeft to maxLabelWidth / 2 + 8
	set accViewWidth to maxLabelWidth + 400
	
	set {theButtons, minWidth} to create buttons {"Cancel", "OK"} cancel button 1 default button 2 given «class btns»:2
	if minWidth > accViewWidth then set accViewWidth to minWidth -- make sure buttons fit
	
	-------------
	
	
	set {productionMode, theTop, newWidth} to create checkbox (item 8 of theLabelStrings) left inset controlLeft bottom (theTop + 16) max width accViewWidth initial state {productionMode}
	
	set {backupScriptRunMinStop, runMinEndLabel, theTop, fieldLeft} to create side labeled field backupScriptRunMinStop left inset 120 bottom (theTop + 12) total width 160 placeholder text "Min end" label text (item 7 of theLabelStrings) field left 0
	set {backupScriptRunMinStart, runMinStartLabel, theTop, fieldLeft} to create side labeled field backupScriptRunMinStart left inset 120 bottom (theTop + 12) total width 160 placeholder text "Min Start" label text (item 6 of theLabelStrings) field left 0
	set {backupScriptRunHourStart, runHourStartLabel, theTop, fieldLeft} to create side labeled field backupScriptRunHourStart left inset controlLeft bottom (theTop + 16) total width 200 placeholder text "Hour" label text (item 5 of theLabelStrings) field left 0
	
	set {shouldBackupScriptRun, theTop, newWidth} to create checkbox (item 4 of theLabelStrings) left inset controlLeft bottom (theTop + 16) max width accViewWidth initial state {shouldBackupScriptRun}
	
	set {shouldMountNetDriveScriptRun, theTop, newWidth} to create checkbox (item 3 of theLabelStrings) left inset controlLeft bottom (theTop + 16) max width accViewWidth initial state {shouldMountNetDriveScriptRun}
	
	set {shouldDocLoaderScriptRun, theTop, newWidth} to create checkbox (item 2 of theLabelStrings) left inset controlLeft bottom (theTop + 16) max width 400 initial state {shouldDocLoaderScriptRun}
	
	set {shouldKeepUpScriptRun, theTop, newWidth} to create checkbox (item 1 of theLabelStrings) left inset controlLeft bottom (theTop + 16) max width 400 initial state {shouldKeepUpScriptRun}
	
	set {introLabel, theTop} to create label alertMessage bottom (theTop + 16) max width accViewWidth control size regular size aligns left aligned with multiline without bold type
	
	
	--this is where the controlling starts
	set allControls to {introLabel, shouldKeepUpScriptRun, shouldDocLoaderScriptRun, shouldMountNetDriveScriptRun, shouldBackupScriptRun, backupScriptRunHourStart, runHourStartLabel, backupScriptRunMinStart, runMinStartLabel, backupScriptRunMinStop, runMinEndLabel, productionMode}
	
	-- controlResults will be in the same order as allControls
	set alertTitle to "Turn Scripts On or Off"
	set {buttonName, controlResults} to display enhanced window alertTitle acc view width accViewWidth acc view height theTop acc view controls allControls buttons theButtons --active field logProcess with align cancel button
	-- put the results in variables
	set {aLabel, shouldKeepUpScriptRun, shouldDocLoaderScriptRun, shouldMountNetDriveScriptRun, shouldBackupScriptRun, backupScriptRunHourStart, unused01, backupScriptRunMinStart, unused02, backupScriptRunMinStop, unused03, productionMode} to controlResults
	
	
	set theTextlist to {{"shouldKeepUpScriptRun"}, {"shouldDocLoaderScriptRun"}, {"shouldMountNetDriveScriptRun"}, {"shouldBackupScriptRun"}, {"backupScriptRunHourStart"}, {"unused01"}, {"backupScriptRunMinStart"}, {"unused02"}, {"backupScriptRunMinStop"}, {"unused03"}, {"doProductionMode"}}
	set theParamPlus to {}
	set finalList to {}
	set x to 2 -- had to adjust this from 1 to allow for the damn label (choose which scripts, etc.)
	repeat with i in theTextlist
		set theListItem to i
		set theListItem2 to item x of controlResults
		set theParamPlus to (theListItem & theListItem2) as list
		copy theParamPlus to the end of finalList
		set x to (x + 1)
	end repeat
	
	return buttonName
	
	
end drawDialog

It confuses me too – cut it out.

I tried that but I’m still plagued by this error messages:

120 doesn’t match the parameters «script theLeft» for «event !ASuCrLa». (-1721)

Blockquote

We can’t help you if you don’t tell us where the error is generated.

This edited version of your script works.

If you’re getting error messages like

Can’t get item 3 of {{«class ocid» id «data optr00000000E0EDCF0704000000», «class ocid» id «data optr00000000D023216701000000»}, 162}
item 3 of {<NSButton: 0x407c2db10>, <NSButton: 0x4265852b0>, <NSButton: 0x42658a070>}.

or

Can’t get item missing value of {{«class ocid» id «data optr00000000E0EDCF0704000000», «class ocid» id «data optr00000000D023216701000000»}, 162}.
item missing value of {<NSButton: 0x407c2db10>, <NSButton: 0x4265852b0>, <NSButton: 0x42658a070>}

The error may not have anything to do with the buttons, but one or more of the values sent to a create control command may be a wrong type. Like a string rather than a boolean.

use script "Dialog Toolkit Plus"
use scripting additions
drawDialog()
on drawDialog()
   set backupScriptRunHourStartRO to "10:00 "
   set backupScriptRunMinStopRO to "10:00 "
   set productionMode to true
   set backupScriptRunMinStartRO to "10:00 "
   set backupScriptRunMinStop to "10:00 "
   set backupScriptRunMinStart to "10:00 "
   set backupScriptRunHourStart to "10:00 "
   set shouldBackupScriptRun to true
   set shouldMountNetDriveScriptRun to true
   set shouldDocLoaderScriptRun to true
   set shouldKeepUpScriptRun to true
   set theTop to 0
   set alertMessage to "Check which Scripts you want to Run"
   set theLabelStrings to {"Keep Server Up", "Document Loader", "Mount Network Drive", "Backup Script", "Hour Full Backup Runs-" & backupScriptRunHourStartRO, "Min Start-" & backupScriptRunMinStartRO, "Min End-" & backupScriptRunMinStopRO, "Production Mode"}
   set maxLabelWidth to max width for labels theLabelStrings
   
   --set controlLeft to maxLabelWidth / 4 - 32
   --set accViewWidth to 600
   
   set controlLeft to maxLabelWidth / 2 + 8
   set accViewWidth to maxLabelWidth + 400
   
   set {theButtons, minWidth} to create buttons {"Cancel", "OK"} cancel button 1 default button 2 given «class btns»:2
   if minWidth > accViewWidth then set accViewWidth to minWidth -- make sure buttons fit
   
   -------------
   
   
   set {productionMode, theTop, newWidth} to create checkbox (item 8 of theLabelStrings) left inset controlLeft bottom (theTop + 16) max width accViewWidth initial state {productionMode}
   
   set {backupScriptRunMinStop, runMinEndLabel, theTop, fieldLeft} to create side labeled field backupScriptRunMinStop left inset 120 bottom (theTop + 12) total width 160 placeholder text "Min end" label text (item 7 of theLabelStrings) field left 0
   set {backupScriptRunMinStart, runMinStartLabel, theTop, fieldLeft} to create side labeled field backupScriptRunMinStart left inset 120 bottom (theTop + 12) total width 160 placeholder text "Min Start" label text (item 6 of theLabelStrings) field left 0
   set {backupScriptRunHourStart, runHourStartLabel, theTop, fieldLeft} to create side labeled field backupScriptRunHourStart left inset controlLeft bottom (theTop + 16) total width 200 placeholder text "Hour" label text (item 5 of theLabelStrings) field left 0
   
   set {shouldBackupScriptRun, theTop, newWidth} to create checkbox (item 4 of theLabelStrings) left inset controlLeft bottom (theTop + 16) max width accViewWidth initial state {shouldBackupScriptRun}
   
   set {shouldMountNetDriveScriptRun, theTop, newWidth} to create checkbox (item 3 of theLabelStrings) left inset controlLeft bottom (theTop + 16) max width accViewWidth initial state {shouldMountNetDriveScriptRun}
   
   set {shouldDocLoaderScriptRun, theTop, newWidth} to create checkbox (item 2 of theLabelStrings) left inset controlLeft bottom (theTop + 16) max width 400 initial state {shouldDocLoaderScriptRun}
   
   set {shouldKeepUpScriptRun, theTop, newWidth} to create checkbox (item 1 of theLabelStrings) left inset controlLeft bottom (theTop + 16) max width 400 initial state {shouldKeepUpScriptRun}
   
   set {introLabel, theTop} to create label alertMessage bottom (theTop + 16) max width accViewWidth control size regular size aligns left aligned with multiline without bold type
   
   
   --this is where the controlling starts
   set allControls to {introLabel, shouldKeepUpScriptRun, shouldDocLoaderScriptRun, shouldMountNetDriveScriptRun, shouldBackupScriptRun, backupScriptRunHourStart, runHourStartLabel, backupScriptRunMinStart, runMinStartLabel, backupScriptRunMinStop, runMinEndLabel, productionMode}
   
   -- controlResults will be in the same order as allControls
   set alertTitle to "Turn Scripts On or Off"
   set {buttonName, controlResults} to display enhanced window alertTitle acc view width accViewWidth acc view height theTop acc view controls allControls buttons theButtons --active field logProcess with align cancel button
   -- put the results in variables
   set {aLabel, shouldKeepUpScriptRun, shouldDocLoaderScriptRun, shouldMountNetDriveScriptRun, shouldBackupScriptRun, backupScriptRunHourStart, unused01, backupScriptRunMinStart, unused02, backupScriptRunMinStop, unused03, productionMode} to controlResults
   
   
   set theTextlist to {{"shouldKeepUpScriptRun"}, {"shouldDocLoaderScriptRun"}, {"shouldMountNetDriveScriptRun"}, {"shouldBackupScriptRun"}, {"backupScriptRunHourStart"}, {"unused01"}, {"backupScriptRunMinStart"}, {"unused02"}, {"backupScriptRunMinStop"}, {"unused03"}, {"doProductionMode"}}
   set theParamPlus to {}
   set finalList to {}
   set x to 2 -- had to adjust this from 1 to allow for the damn label (choose which scripts, etc.)
   repeat with i in theTextlist
      set theListItem to i
      set theListItem2 to item x of controlResults
      set theParamPlus to (theListItem & theListItem2) as list
      copy theParamPlus to the end of finalList
      set x to (x + 1)
   end repeat
   
   return buttonName
   
   
end drawDialog

I couldn’t see the error in my ways nor in your code but when I replaced the side labelled fields with labelled popups that particular error disappeared.

Now I’m getting first run crashes on the Dialog which are very difficult to understand. That is: if, after some indeterminate period, I launch the app it will exit with a type 1700 error or just crash. If I make one or two subsequent attempts the thing just works properly and stays that way until I stop launching in it. Next day, the first launch problem reappears.

One one occasion so far the crash was real as fas the crash reporter was concerned and I got this:

Version:               1.5 (21)
Code Type:             X86-64 (Native)
Parent Process:        ??? [1]
Responsible:           applet [33915]
User ID:               502

Date/Time:             2025-01-07 23:52:05.348 -0500
OS Version:            Mac OS X 10.14.6 (18G9323)
Report Version:        12
Bridge OS Version:     5.5 (18P4759a)
Anonymous UUID:        9F9CC07C-7F37-1F32-D88F-B6A9696FE8D5


Time Awake Since Boot: 14000000 seconds

System Integrity Protection: enabled

Crashed Thread:        0  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       KERN_INVALID_ADDRESS at 0x00000000000100f0
Exception Note:        EXC_CORPSE_NOTIFY

Termination Signal:    Segmentation fault: 11
Termination Reason:    Namespace SIGNAL, Code 0xb
Terminating Process:   exc handler [33915]

VM Regions Near 0x100f0:
--> 
    __TEXT                 00000001069ac000-00000001069ad000 [    4K] r-x/rwx SM=COW  /Users/USER/Library/Scripts/*/dBrightBackupController.app/Contents/MacOS/applet

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   com.apple.applescript         	0x00007fff5da633cc UASList_Head1(TUASList*) + 8
1   com.apple.applescript         	0x00007fff5da3129a DisplayProc + 354
2   com.apple.applescript         	0x00007fff5da8b8ae TASUnparser::PrintObject() + 436
3   com.apple.applescript         	0x00007fff5da8b658 TASUnparser::PrintSource(TUASScript*) + 108
4   com.apple.applescript         	0x00007fff5da8a99d DoFormat(TASUnparser&, __CFString const*, long) + 301
5   com.apple.applescript         	0x00007fff5da8939b ReportError1(TASUnparser&) + 139
6   com.apple.applescript         	0x00007fff5da8af55 ReportError(TASUnparser&, unsigned char) + 1050
7   com.apple.applescript         	0x00007fff5da8b2ef ReportErrorToDesc(unsigned char, AEDesc&) + 213
8   com.apple.applescript         	0x00007fff5da260b0 ASScriptError(unsigned int, unsigned int, AEDesc*) + 207
9   com.apple.applescript         	0x00007fff5da21c43 AppleScriptComponent + 1535
10  com.apple.openscripting       	0x00007fff4caef4d2 OSAScriptError + 47
11  com.apple.applescript         	0x00007fff5da67bb3 -[OSAAppletDelegate scriptErrorDescriptorOfType:forKey:] + 46
12  com.apple.applescript         	0x00007fff5da67c16 -[OSAAppletDelegate scriptErrorStringForKey:] + 31
13  com.apple.applescript         	0x00007fff5da67ca0 -[OSAAppletDelegate scriptErrorWithCode:] + 45
14  com.apple.applescript         	0x00007fff5da68433 -[OSAAppletDelegate handleEvent:withReply:error:] + 700
15  com.apple.applescript         	0x00007fff5da68a67 __HandleScriptEvent_block_invoke + 103
16  libdispatch.dylib             	0x00007fff795955f8 _dispatch_call_block_and_release + 12
17  libdispatch.dylib             	0x00007fff7959663d _dispatch_client_callout + 8
18  libdispatch.dylib             	0x00007fff795a168d _dispatch_main_queue_callback_4CF + 1135
19  com.apple.CoreFoundation      	0x00007fff4d4f4ef7 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
20  com.apple.CoreFoundation      	0x00007fff4d4f4621 __CFRunLoopRun + 2289
21  com.apple.CoreFoundation      	0x00007fff4d4f3ade CFRunLoopRunSpecific + 455
22  com.apple.HIToolbox           	0x00007fff4c7521ab RunCurrentEventLoopInMode + 292
23  com.apple.HIToolbox           	0x00007fff4c751ee5 ReceiveNextEventCommon + 603
24  com.apple.HIToolbox           	0x00007fff4c751c76 _BlockUntilNextEventMatchingListInModeWithFilter + 64
25  com.apple.AppKit              	0x00007fff4aae9e89 _DPSNextEvent + 1135
26  com.apple.AppKit              	0x00007fff4aae8b77 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1361
27  com.apple.AppKit              	0x00007fff4aae2c94 -[NSApplication run] + 699
28  com.apple.applescript         	0x00007fff5da688b3 OSAAppletExecute + 459
29  com.apple.applescript         	0x00007fff5da21507 AppletComponent + 71
30  com.databright.dBrightBackupController	0x00000001069acee7 0x1069ac000 + 3815
31  com.databright.dBrightBackupController	0x00000001069acec4 0x1069ac000 + 3780
32  com.databright.dBrightBackupController	0x00000001069ace9c 0x1069ac000 + 3740

I really would appreciate some pointers on how to interpret what is going on here.

Unfortunately that log only tells us there’s been an AppleScript error – there’s no indication of what the relevant AS code was.