Checklist with user log of actions

Applescripts ‘‘Choose from list’’ function already allows multiple selections so this may be overkill. This script converts a list into a checked or unchecked list. It also logs the sequence in which each item was checked or unchecked. Uses might include a nice printout of choices, or a menu of option settings, or a record of changes to settings(perhaps add a timestamp?).

Instructions:
Each item on the CHECKLST is either checked or unchecked.
The CHECKLST is updated to display all checked or unchecked choices.
When the user ends the updating cycle, the result of all checked and unchecked items is returned.

Examples outputs below include both the final checklist, and a log of the users choosing sequence. ie: { (result list) , (sequence list) }

Output Example 1:
{{‘’_1. Bird’‘, ‘’_2. Cat’‘, ‘‘√3. Dog’’}, {’‘√3. Dog’', ‘‘false’’}}
– in example 1, dog was checked then the user ended the cycle. The ‘false’ flag indicates the user ended the update cycle.

Output Example 2:
{{‘’_1. Bird’‘, ‘‘√2. Cat’’, ‘‘√3. Dog’’}, {’‘√3. Dog’‘, ‘‘√2. Cat’’, {’‘_1. Bird’', ‘‘√2. Cat’’, ‘‘√3. Dog’’}}}
– in example 2, cat and dog were checked but dog was checked first. Instead of a ‘false’ flag, the checklist itself is used to indicate the user has ended the update cycle.

Output Example 3:
{{‘‘√1. Bird’’,‘’_2. Cat’‘,’‘√3. Dog’‘}, {’‘√1. Bird’‘,’‘√2. Cat’‘,’‘√3. Dog’‘, {’‘√1. Bird’‘,’‘_2. Cat’‘,’‘√3. Dog’‘},’‘_2. Cat’‘, {’‘√1. Bird’‘,’‘_2. Cat’‘,’‘√3. Dog’'}}}
– in example 3, bird and dog were checked, but in a prior cycle all were checked; Cat was unchecked in cycle two. Finalized checklists were used twice to indicate the user went thru two update cycles.

Output Example 4:
{{‘’_1. Bird’‘,’‘_2. Cat’‘,’‘_3. Dog’‘}, {’‘√2. Cat’‘,’‘√1. Bird’‘,’‘_2. Cat’‘,’‘√3. Dog’‘,’‘_1. Bird’‘,’‘_3. Dog’‘, {’‘_1. Bird’‘,’‘_2. Cat’‘,’‘_3. Dog’'}}}
-in example 4, no items were checked in the final result, but in previous activity multiple checking & unchecking occurred.



set myLST to {"Bird", "Cat", "Dog"}

# CONVERT USERS LIST INTO A CHECKLIST:
property CHECKLST : {}
if CHECKLST is {} then
	set n to 0
	repeat with eachITM in myLST
		set n to n + 1
		set end of CHECKLST to "_" & n & "." & space & item n of myLST
	end repeat
end if

# CHECK OR UNCHECK LIST ITEMS:
property CHOSN : {}
property SEQUNCE : {}
property processComplete : false
repeat while processComplete is false
	set CHOSN to (choose from list CHECKLST with prompt "Check or Uncheck Items" default items CHOSN OK button name {"Update"} cancel button name {"Done"}) as text
	if CHOSN is "false" then
		--set end of SEQUNCE to CHOSN --uncomment this to log ''false'' at the end of a cycle, ie:{"√1. Cat", "√2. Dog", "false"}
		set end of SEQUNCE to CHECKLST --or uncomment this to log the full result at the end of a cycle , ie:{"√1. Cat", "√2. Dog", {"√1. Cat", "√2. Dog", "_3. Bird"}}
		set processComplete to true
	end if
	repeat with n from 1 to count of CHECKLST
		set eachOPT to item n of CHECKLST as text
		if eachOPT is CHOSN then
			if character 1 of (eachOPT as text) is "_" then
				set item n of CHECKLST to "√" & items 2 thru -1 of eachOPT
			else if character 1 of (eachOPT as text) is "√" then
				set item n of CHECKLST to "_" & items 2 thru -1 of eachOPT
			end if
			set end of SEQUNCE to item n of CHECKLST
		end if
	end repeat
end repeat
set processComplete to false

# DISPLAY REPORT:
set rprt to "You chose:" & return
repeat with eachITM in CHECKLST
	set rprt to rprt & eachITM & return
end repeat
display dialog rprt

return {CHECKLST, SEQUNCE}

FYI, here’s a simpler version without sequencing or logging. It does include a fancier variation of the ‘‘check-marking graphic’’; whereby unchecked is ‘’[]‘’ instead of ‘’‘’, and checked is ‘’[√]‘’ instead of merely ‘‘√’’. The box-like graphic may seem more visually appealing to some.


set myLST to {"Bird", "Cat", "Dog"}

# CONVERT USERS LIST INTO A CHECKLIST:
property CHECKLST : {}
if CHECKLST is {} then
	set n to 0
	repeat with eachITM in myLST
		set n to n + 1
		set end of CHECKLST to "[_] " & n & "." & space & item n of myLST
	end repeat
end if

# CHECK OR UNCHECK LIST ITEMS:
property CHOSN : {}
property processComplete : false
repeat while processComplete is false
	set CHOSN to (choose from list CHECKLST with prompt "Check or Uncheck Items" default items CHOSN OK button name {"Update"} cancel button name {"Done"}) as text
	if CHOSN is "false" then set processComplete to true
	repeat with n from 1 to count of CHECKLST
		set eachOPT to item n of CHECKLST as text
		if eachOPT is CHOSN then
			if (characters 1 thru 3 of (eachOPT as text)) as text is "[_]" then
				set item n of CHECKLST to "[√] " & items 5 thru -1 of eachOPT
			else if (characters 1 thru 3 of (eachOPT as text)) as text is "[√]" then
				set item n of CHECKLST to "[_] " & items 5 thru -1 of eachOPT
			end if
		end if
	end repeat
end repeat
set processComplete to false

# DISPLAY REPORT:
set rprt to "You chose:" & return
repeat with eachITM in CHECKLST
	set rprt to rprt & eachITM & return
end repeat
display dialog rprt

return CHECKLST

You might want to take a look at Shane Stanley’s Myriad Tables library.

https://www.macosxautomation.com/applescript/apps/Script_Libs.html#MyriadTablesLib

You can get a list that just has a checkbox by each item the user can check/uncheck. It also allows drag-reordering.

Very Cool tool! Thanks for the tip, t.spoon!