I’m using Applescript with github.com/BlueM/Pashua. I’m using checkboxes in the dialog box, and I can get the output of those as a result in the script editor, i.e., when cat
and cat 2
are checked, I get:
But what I need to do is loop through the checkboxes to find only those that have been toggled to 1, and I don’t know where to start.
How can I loop through all categories - cat, cat2, cat3, cat4, etc. - in the result, find only those that are boolean 1, and then output those in one variable, separated by a comma?
I.e. using this script result
how can I loop through and get a variable that has a value of:
This is the script that generates the dialog box and the checkboxes:
tell application "Finder" to set thisFolder to (container of (path to me)) as text -- get the folder path
try
set thePath to alias (thisFolder & "Pashua.scpt")
set pashuaBinding to load script thePath
tell pashuaBinding
try
set dialogConfiguration to my getDialogConfiguration() -- configure the dialog
set dialogResult to showDialog(dialogConfiguration, "") -- show the dialog
end try
end tell
end try
on getDialogConfiguration() -- return the configuration string
return "
# Add category checkboxes
txtcats.type = text
txtcats.default = Categories
cat.rely = -18
cat.type = checkbox
cat.label = Category 1
cat2.type = checkbox
cat2.label = Category 2
cat3.type = checkbox
cat3.label = Category 3
cat4.type = checkbox
cat4.label = Category 4
"
end getDialogConfiguration
AppleScript: 2.7
Browser: Firefox 73.0
Operating System: macOS 10.14