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