Improvement to search dialog

Hi there,

first version of an (in my opinion;)) improved search dialog. Can’t attach the video so here it goes: dl.dropboxusercontent.com/u/873104/search.mov

Syntax:
A (B: C D)

A can be anything.
B is either “in” or any of the drop down alternatives in the advanced panel. multiple words (e.g. “word count” or “date modified” are abbreviated with the first letter of each word). “in” lets you set the “search in” filter
C is optional if the row has only two options. otherwise it is the first word of any of the options of the drop down. Special search: numeric filtering is mapped to </>/<=/=/!=/>= instead of “is less than”/“is greater than”/is greater than or"/“is”/“is not”/“is lesser than”
D is the actual filter value. depends on B/C. if it is a drop down,
the parenthesis term can be repeated as often as wished.

Examples:

  • Devonthink manual in: computer word: < 2500" (A: Devonthink manual / B1: in/C1: not given because optional in this case/D1: computer/B2: word/C2: </D2: 2500)
    – searches for documents containing “devonthink manual” in group “computer” with less than 2500 words
  • moo hei: < 500 (A: moo/B:hei/C: </D: 500)
    – searches for documents containing “moo” with a height of less than 500
  • moo da: is lq (A: moo/B:da/C: is/D: lq)
    – searches for documents containing “moo” where date added is last quarter
  • moo name: this works rather well
    – searches for documents containing “moo” where name is “this works rather well”

what is possible so far:

  • “search in” filter
  • all non-nested filters in the advanced dialog

not possible:

  • nested filters in advanced dialog
  • advanced dialog: date filters only work with ‘is’. others are currently not feasible because i dont know how to set the value for the ‘scroll area’/‘date time area’ that shows up as the third input of that row.
  • comparison: fuzzy/diacritics
  • advanced mapping of keywords in search, e.g.: “kind: photos” does not work. “kind: is pdf” works.
  • full names: e.g. you cannot use ‘na’ to filter on name. always full names

EDIT:
two things i forgot to mention
if you are using an ‘in’ filter, it has to be the first filter. “moo wc: < 7500 in: nlp” does not work because the advanced-search-panel is in the way, for now :wink:

i copy the initial search query to the clipboard. i have to change the value of the search text field and doing cmd+v seems like a solid way to change a query if need be
dt-search-input.scpt.zip (41.2 KB)

This is awesome bosie. :smiley: :smiley: :smiley:

I’m parsing the script to see what you’ve done – the concept of the feature you’ve coded and the extensive work you’ve put into doing it are huge.

thank you. its rough around the edges and… i haven’t refactored the code yet, wanted to get feedback first; didn’t think anyone would read my code so quickly :wink:

Despite the overwhelming responses on the forum, here is a new version.

now possible are multiple filters of the same type.

Examples

“my search text label: n impo label: n priv”
searches for: “my search text”, labels not being important and private

“my search text wc: < 7500 wc: > 5000”
searches for: “my search text”, word count lower than 7500 and higher than 5000

Behold, there is now a much neater way:
“my search text wc: 5000 < 7500”
searches for: “my search text”, word count lower than 7500 and higher than 5000

Also works for other number filters! (height, duration,width, size)
Possible comparison signs:
A < B: A is less than B
A <= B: A is less than or equal to B
A > B: A is greater than B
A >= B: A is greater than or equal to B

Now it is also possible to set fuzzy/diacritics on the main panel:
“search fu: on dia: off”

Fuzzy filter words are possible! It matches on the first characters of the filter type.
“wo” filters on “word count”
“wor” filters on “word count”
“hei” filters on “height”

Wait, there is more! we can now filter on dates!
search da: < 10/10/2001
search da: 10/10/1999 <= 10/10/2001
search da: > 10/10/2001
Same comparison signs as above. Nothing changed for = comparisons.

(*
Version: 0.2
*)
tell application "System Events"
	tell process "DEVONthink Pro"
		set search_string to my trim_line((get value of (item 1 of (get text fields of window 1)) as string), " ", 2)
		my reset_search()
		
		if my has_filter(search_string) then
			set s to 0
			set m to 0
			set map_signs_to_options to {{the_key:"Word Count", the_value:{{the_key:"<", the_value:"is less than"}, {the_key:">", the_value:"is greater than"}, {the_key:"=", the_value:"is"}, {the_key:">=", the_value:"is greater than or"}, {the_key:"!=", the_value:"is not"}, {the_key:"<=", the_value:"is less than or"}}}, {the_key:"dm", the_value:{{the_key:"t", the_value:"Today"}, {the_key:"y", the_value:"yesterday"}, {the_key:"tm", the_value:"This Month"}, {the_key:"tw", the_value:"This week"}, {the_key:"lw", the_value:"Last week"}, {the_key:"lm", the_value:"Last month"}, {the_key:"tq", the_value:"This Quarter"}, {the_key:"lq", the_value:"Last Quarter"}, {the_key:"ty", the_value:"This Year"}, {the_key:"ly", the_value:"Last Year"}}}, {the_key:"cb", the_value:{{the_key:"on", the_value:"1"}, {the_key:"off", the_value:"0"}}}}
			
			set advanced_keys to {{the_key:"Metadata", the_value:"metadata"}, {the_key:"comment", the_value:"comment"}, {the_key:"url", the_value:"url"}, {the_key:"name", the_value:"name"}, {the_key:"content", the_value:"content"}, {the_key:"Author", the_value:"Author"}, {the_key:"From", the_value:"From"}, {the_key:"Recipient", the_value:"Recipient"}, {the_key:"To", the_value:"To"}, {the_key:"Title", the_value:"Title"}, {the_key:"Headline", the_value:"Headline"}, {the_key:"Subject", the_value:"Subject"}, {the_key:"Description", the_value:"Description"}, {the_key:"Keywords", the_value:"Keywords"}, {the_key:"Organization", the_value:"Organization"}, {the_key:"Copyright", the_value:"Copyright"}, {the_key:"Album", the_value:"Album"}, {the_key:"Composer", the_value:"Composer"}, {the_key:"da", the_value:"da"}, {the_key:"Date Added", the_value:"da"}, {the_key:"Date Modified", the_value:"dm"}, {the_key:"dm", the_value:"dm"}, {the_key:"Date Open", the_value:"do"}, {the_key:"Date Created", the_value:"dc"}, {the_key:"do", the_value:"do"}, {the_key:"dc", the_value:"dc"}, {the_key:"wc", the_value:"Word Count"}, {the_key:"word Count", the_value:"Word Count"}, {the_key:"in", the_value:"in"}, {the_key:"fuzzy", the_value:"fuzzy"}, {the_key:"diacritics", the_value:"diacritics"}, {the_key:"height", the_value:"height"}, {the_key:"width", the_value:"width"}, {the_key:"size", the_value:"size"}, {the_key:"duration", the_value:"duration"}, {the_key:"label", the_value:"label"}, {the_key:"tag", the_value:"tag"}, {the_key:"unread", the_value:"unread"}, {the_key:"flag", the_value:"flag"}, {the_key:"filename", the_value:"filename"}, {the_key:"kind", the_value:"kind"}, {the_key:"instance", the_value:"instance"}, {the_key:"item", the_value:"item"}, {the_key:"locking", the_value:"locking"}}
			set categories to {"Metadata", "comment", "url", "name", "content", "Author", "From", "Recipient", "To", "Title", "Headline", "Subject", "Description", "Keywords", "Organization", "Copyright", "Album", "Composer"}
			
			set myArray to my theSplit(search_string, " ")
			set tabular to my to_table(myArray)
			set i to 1
			set e to length of myArray
			set first_encounter to 1000000
			set number_filters to {"word count", "Height", "Width", "Size", "Duration"}
			set date_filters to {"dm", "da", "dc", "do"}
			set checkbox_panel to {"diacritics", "fuzzy"}
			set main_panel to {"in"} & checkbox_panel
			set total to date_filters & number_filters
			
			repeat
				if my ends(item i of myArray) then
					if first_encounter > i then
						set first_encounter to i
					end if
					set con2 to my dropLast(item i of myArray)
					set con to my find_advanced_key(con2, advanced_keys)
					set next_index to (my next_filter_position(myArray, i)) - i
					
					if con is not in main_panel then
						if s is 0 then
							my start_search()
							set s to get sheet 1 of window 1
							set k to get scroll area 1 of s
							set m to get group 1 of k
						end if
						
						if (my get_associative_item(tabular, con2 & ":")) = 1 and not (total contains con and next_index = 3) then
							my add(m)
						else
							my addm(m)
						end if
					end if
					
					if categories contains con then
						set i to my set_textfield_filter(myArray, i, con, m)
					else if checkbox_panel contains con then
						my set_base(my getitemindex(checkbox_panel, con), my get_associative_item(my get_associative_item(map_signs_to_options, "cb"), item (i + 1) of myArray))
						set i to i + 1
					else if con is "in" then
						set i to my set_search_in_filter(myArray, i)
					else if con is in date_filters then
						set i to my set_date_filters(myArray, i, con, m, map_signs_to_options, next_index)
					else if number_filters contains con then
						set i to my set_number_filter(m, i, myArray, next_index, con, map_signs_to_options)
					else if {"flag", "unread", "locking"} contains con then
						my setPopupButton(my last_popup(m), con)
						my setPopupButton(my last_popup(m), item (i + 1) of myArray)
						set i to i + 2
					else if con is "tag" then
						set n to my filter_value(myArray, i + 1)
						my setPopupButton(my last_popup(m), con)
						my setPopupButton(my last_popup(m), item (i + 1) of myArray)
						my setTf(my last_tf(m), n)
						set i to i + 3
					else if con is "filename" then
						set n to my filter_value(myArray, i + 1)
						my setPopupButton(my last_popup(m), con)
						my setPopupButton(my last_popup(m), item (i + 1) of myArray)
						my setTf(my last_tf(m), n)
						set i to i + 3
					else if {"kind", "instance", "item", "label"} contains con then
						my setPopupButton(my last_popup(m), con)
						my setPopupButton(my second_to_last_popup(m), item (i + 1) of myArray)
						my setPopupButton(my last_popup(m), item (i + 2) of myArray)
						set i to i + 3
					else
						set i to i + 1
					end if
				else
					set i to i + 1
				end if
				if i > e then
					exit repeat
				end if
			end repeat
			my reset_string()
			if m is not 0 then
				my press_ok(m)
			end if
		end if
		click (button 5 of window 1) -- search button
	end tell
end tell

on getitemindex(thelist, theitem)
	set AppleScript's text item delimiters to return
	set thelist to thelist as text
	return count of paragraphs in (text 1 thru (get offset of theitem in thelist) of thelist)
end getitemindex

on last_datetime()
	tell application "System Events"
		tell process "DEVONthink Pro"
			set tElements to entire contents of (get sheet 1 of window 1)
			repeat with tElement in reverse of tElements
				if (exists attribute "AXRole" of tElement) then
					if value of attribute "AXRole" of tElement = "AXDateTimeArea" then
						return tElement
					end if
				end if
			end repeat
		end tell
	end tell
	return ""
end last_datetime

on set_last_datetime(input)
	set k to my theSplit(input, "/")
	tell application "System Events"
		tell process "DEVONthink Pro"
			set el to my last_datetime()
			set focused of el to true
			repeat with i in k
				keystroke i
				keystroke (ASCII character 9)
			end repeat
			my reset_time()
		end tell
	end tell
end set_last_datetime

on reset_time()
	tell application "System Events"
		keystroke 0
		keystroke (ASCII character 9)
		keystroke 0
		keystroke (ASCII character 9)
		keystroke 0
	end tell
end reset_time

on set_number_filter(m, i, myArray, next_index, con, map_signs_to_options)
	my setPopupButton(my last_popup(m), con)
	if next_index = 2 then
		my setPopupButton(my last_popup(m), my get_associative_item(my get_associative_item(map_signs_to_options, "Word Count"), item (i + 1) of myArray))
		my setTf(my last_tf(m), item (i + 2) of myArray)
		return i + 3
	else
		my setPopupButton(my last_popup(m), con)
		my setPopupButton(my last_popup(m), my sign_position_converter(item (i + 2) of myArray, 1))
		my setTf(my last_tf(m), item (i + 1) of myArray)
		my addm(m)
		my setPopupButton(my last_popup(m), con)
		my setPopupButton(my last_popup(m), my sign_position_converter(item (i + 2) of myArray, 2))
		my setTf(my last_tf(m), item (i + 3) of myArray)
		return i + 4
	end if
end set_number_filter

on set_textfield_filter(myArray, i, con, m)
	set n to my filter_value(myArray, i)
	my setPopupButton(my last_popup(m), con)
	my setTf(my last_tf(m), n)
	i + 2
end set_textfield_filter

on set_search_in_filter(myArray, i)
	tell application "System Events"
		tell application process "DEVONthink Pro"
			set n to my filter_value(myArray, i)
			set k to my select_group(n)
			try
				if length of k > 0 then
					set f to item 1 of (get pop up buttons of window 1)
					if length of k = 1 then
						set db to item 1 of k
						set db to (text 6 thru (length of db) of db)
						set db to my trim_line(db, " ", 2)
						my setPopupButton(f, db)
					else
						set k to items 2 thru (length of k) of k
						my setPopupButton2(f, k)
					end if
				end if
			on error errStr number errorNumber
				error errStr number errorNumber
			end try
			-- search window loses focus after input group selection
			tell application "DEVONthink Pro"
				activate window 1
			end tell
			i + 2
		end tell
	end tell
end set_search_in_filter

on reset_string()
	tell application "System Events"
		tell application process "DEVONthink Pro"
			set t to item 1 of (get text fields of window 1)
			set search_string to (get value of t as string)
			my copy_to_clipboard(search_string)
			set myArray to my theSplit(search_string, " ")
			set new_line to my concanate(items 1 thru ((my next_filter_position(myArray, 1))) of myArray)
			set value of t to new_line
		end tell
	end tell
end reset_string

on copy_to_clipboard(content)
	set the clipboard to content
end copy_to_clipboard

on press_ok(m)
	tell application "System Events"
		tell application process "DEVONthink Pro"
			delay 0.4
			keystroke return
		end tell
	end tell
end press_ok

on has_filter(search_string)
	repeat with ss in search_string
		if my ends(ss) then
			return true
		end if
	end repeat
	return false
end has_filter

on filter_value(l, i)
	my concanate((items (i + 1) thru (my next_filter_position(l, i)) of l))
end filter_value

on concanate(l)
	set returnval to ""
	repeat with s in l
		set returnval to returnval & s & " "
	end repeat
	returnval
end concanate

on next_filter_position(l, i)
	set k to i
	repeat
		if length of l = k or my ends(item (k + 1) of l) then
			exit repeat
		end if
		set k to k + 1
	end repeat
	return k
end next_filter_position

on ends(str)
	my return_last(str) is ":"
end ends

on dropLast(theString)
	text 1 thru ((length of theString) - 1) of theString
end dropLast

on theSplit(theString, theDelimiter)
	-- save delimiters to restore old settings
	set oldDelimiters to AppleScript's text item delimiters
	-- set delimiters to delimiter to be used
	set AppleScript's text item delimiters to theDelimiter
	-- create the array
	set theArray to every text item of theString
	-- restore the old setting
	set AppleScript's text item delimiters to oldDelimiters
	-- return the result
	return theArray
end theSplit

on find_record_for_key(the_assoc_list, the_key)
	(* This is a private handler. Users should not use it directly. *)
	repeat with record_ref in the_assoc_list
		if the_key of record_ref = the_key then return record_ref
	end repeat
	return missing value -- The key wasn't found
end find_record_for_key

on get_associative_item(the_assoc_list, the_key)
	(*
      Get the value for the given key in an associative list.
      the_assoc_list : associative list
      the_key : anything -- the key to search for
      Result : anything -- the value, if found
      Note: Raises error -1728 if the key isn't found.
   *)
	set record_ref to find_record_for_key(the_assoc_list, the_key)
	if record_ref = missing value then
		error "The key wasn't found." number -1728 from the_key
	end if
	return the_value of record_ref
end get_associative_item

on remove_last(m)
	tell application "System Events"
		tell application process "DEVONthink Pro"
			click (item 1 of (get buttons of m whose title is "-"))
		end tell
	end tell
end remove_last

on set_base(id, desire)
	tell application "System Events"
		tell application process "DEVONthink Pro"
			set cb to (get checkbox id of window 1)
			set desire to (desire as number)
			if get value of cb is not desire then
				click cb
			end if
		end tell
	end tell
end set_base

on set_fuzzy(desire)
	my set_base(2, desire)
end set_fuzzy

on set_diatritics(desire)
	my set_base(1, desire)
end set_diatritics

on last_tf(m)
	tell application "System Events"
		tell application process "DEVONthink Pro"
			my return_last(get text field of m)
		end tell
	end tell
end last_tf

on second_to_last_popup(m)
	tell application "System Events"
		tell application process "DEVONthink Pro"
			set bs to get pop up buttons of m
			get item ((length of bs) - 1) of bs
		end tell
	end tell
end second_to_last_popup

on last_popup(m)
	tell application "System Events"
		tell application process "DEVONthink Pro"
			my return_last(get pop up buttons of m)
		end tell
	end tell
end last_popup

on add(m)
	tell application "System Events"
		tell application process "DEVONthink Pro"
			try
				click (get button 1 of m)
			on error errStr number errorNumber
				error errStr number errorNumber
			end try
		end tell
	end tell
end add

on addm(m)
	tell application "System Events"
		tell application process "DEVONthink Pro"
			try
				key down option
				delay 0.2
				click (get button 1 of m)
			on error errStr number errorNumber
				key up option
				error errStr number errorNumber
			end try
			key up option
		end tell
	end tell
end addm

on return_last(l)
	get item (length of l) of l
end return_last

on start_search()
	tell application "System Events"
		tell application process "DEVONthink Pro"
			click button "Advanced..." of window 1
		end tell
	end tell
end start_search

on reset_search()
	tell application "System Events"
		tell application process "DEVONthink Pro"
			set b to button "Reset" of window 1
			if b is enabled then
				click b
			end if
			set f to item 1 of (get pop up buttons of window 1)
			if (get value of f) is not "Databases" then
				my setPopupButton(f, "")
			end if
		end tell
	end tell
end reset_search

on setTf(tf, val)
	tell application "System Events"
		tell application process "System Preferences"
			set value of tf to (my trim_line(val, " ", 2))
		end tell
	end tell
end setTf

on setPopupButton(popupButton, the_state)
	tell application "System Events"
		tell application process "System Preferences"
			click popupButton
			delay 0.1
			keystroke the_state
			delay 0.1
			keystroke return
		end tell
	end tell
end setPopupButton

on setPopupButton2(popupButton, the_states)
	tell application "System Events"
		tell application process "System Preferences"
			click popupButton
			delay 0.1
			repeat with states in the_states
				delay 0.1
				keystroke states
				delay 0.1
				tell application "System Events" to tell process "DEVONthink Pro" to key code 124
			end repeat
			keystroke return
			
		end tell
	end tell
end setPopupButton2

on trim_line(this_text, trim_chars, trim_indicator)
	-- 0 = beginning, 1 = end, 2 = both
	set x to the length of the trim_chars
	-- TRIM BEGINNING
	if the trim_indicator is in {0, 2} then
		repeat while this_text begins with the trim_chars
			try
				set this_text to characters (x + 1) thru -1 of this_text as string
			on error
				return ""
			end try
		end repeat
	end if
	-- TRIM ENDING
	if the trim_indicator is in {1, 2} then
		repeat while this_text ends with the trim_chars
			try
				set this_text to characters 1 thru -(x + 1) of this_text as string
			on error
				-- the text contains nothing but the trim characters
				return ""
			end try
		end repeat
	end if
	return this_text
end trim_line

(* 	does not yet work because tags are entered 
	with a completion text field and this 
	ruins the 'set value' command
*)
on set_tag_filter(m, tags_str)
	tell application "System Events"
		tell process "DEVONthink Pro"
			set tags to my theSplit(tags_str, " ")
			set tf to my last_tf(m)
			repeat with tag in tags
				set value of tf to (get value of tf) & tag
				keystroke return
				delay 0.5
			end repeat
		end tell
	end tell
end set_tag_filter

on to_table(a)
	set cnt to {}
	repeat with k in a
		set k to (text of k)
		try
			set num to (my get_associative_item(cnt, k)) + 1
			set idx to 1
			repeat with i in cnt
				if (get the_key of i) = k then
					set item idx of cnt to {the_key:k, the_value:num}
				end if
				set idx to idx + 1
			end repeat
		on error
			set tmp to {the_key:k, the_value:1}
			set end of cnt to tmp
		end try
	end repeat
	return cnt
end to_table

on contains_key(a, key)
	try
		my get_associative_item(a, key)
		true
	on error
		false
	end try
end contains_key

on find_advanced_key(the_key, advanced_keys)
	repeat with record_ref in advanced_keys
		if the_key of record_ref starts with the_key then return my get_associative_item(advanced_keys, the_key of record_ref)
	end repeat
end find_advanced_key

property pTitle : "Group selector "
property pstrDelim : "    "

on select_group(se)
	ProcessSelns(my trim_line(se, " ", 2))
end select_group

on ProcessSelns(strFind)
	set ret to ""
	set strFind to text of strFind
	tell application id "com.devon-technologies.thinkpro2"
		set lstParent to (incoming group of databases where name contains strFind)
		repeat with oDb in (databases where name contains strFind)
			set lstParent to lstParent & (name of oDb as text)
		end repeat
		-- AND FOLDERS WITH MATCHING NAMES
		repeat with oDb in databases
			set lstParent to lstParent & (parents of oDb where name contains strFind)
		end repeat
		
		-- BUILD NUMBERED MENU OF DESTINATION NAMES
		set lngParents to length of lstParent
		set repeatFind to lngParents = 0
		if repeatFind = false then
			set lngDigits to length of (lngParents as string)
			set lstMenu to {}
			
			set docs to 1
			repeat with i from 1 to lngParents
				tell item i of lstParent
					if its class = text then
						set strName to it
					else
						set strName to (name of its database) & its location & its name
					end if
				end tell
				if strName = "Inbox/Inbox" then set strName to "Global Inbox"
				
				set end of lstMenu to my PadNum(docs, lngDigits) & pstrDelim & strName
				set docs to docs + 1
			end repeat
			
			-- CHOOSE DESTINATION
			tell application id "com.apple.systemevents"
				activate
				set varTargets to choose from list lstMenu with title pTitle with prompt "Select your choice" default items {first item of lstMenu} without multiple selections allowed
			end tell
			if varTargets is not false then
				--    RETRIEVE CHOSEN DESTINATION BY NUMERIC INDEX
				set my text item delimiters to space
				return my theSplit(first item of varTargets, "/")
			end if
		end if
	end tell
end ProcessSelns

on GetNameList(lstSelns)
	-- BUILD BULLETED LIST OF SELECTION NAMES
	set strNames to ""
	repeat with i from 1 to count of lstSelns
		set strNames to strNames & "• " & name of (item i of lstSelns) & return
	end repeat
	return strNames
end GetNameList

-- GET A DIGIT STRING OF MINIMUM WIDTH (LEFT-PADDING WITH ZEROS WHERE NEEDED)
on PadNum(lngNum, lngDigits)
	set strNum to lngNum as string
	set lngGap to (lngDigits - (length of strNum))
	repeat while lngGap > 0
		set strNum to "0" & strNum
		set lngGap to lngGap - 1
	end repeat
	strNum
end PadNum

on sign_position_converter(sign, pos)
	if sign = ">" then
		if pos = 1 then
			"is less than"
		else
			"is greater than"
		end if
	else if sign = ">=" then
		if pos = 1 then
			"is less than or"
		else
			"is greater than or"
		end if
	else if sign = "<=" then
		if pos = 1 then
			"is greater than or"
		else
			"is less than or"
		end if
	else
		if pos = 1 then
			"is greater than"
		else
			"is less than"
		end if
	end if
end sign_position_converter

on set_date_filters(myArray, i, con, m, map_signs_to_options, next_index)
	set f to my get_associative_item({{the_key:"dm", the_value:"Date Mo"}, {the_key:"da", the_value:"Date ad"}, {the_key:"dc", the_value:"Date c"}, {the_key:"do", the_value:"Date o"}}, con)
	my setPopupButton(my last_popup(m), f)
	if item (i + 1) of myArray is "=" or next_index = 1 then
		my setPopupButton(my second_to_last_popup(m), my get_associative_item(my get_associative_item(map_signs_to_options, "Word Count"), item (i + 1) of myArray))
		my setPopupButton(my last_popup(m), my get_associative_item(my get_associative_item(map_signs_to_options, "dm"), item (i + 2) of myArray))
		return i + 3
	else
		if next_index = 3 then
			my setPopupButton(my second_to_last_popup(m), my sign_position_converter(item (i + 2) of myArray, 1))
			my set_last_datetime(item (i + 1) of myArray)
			my addm(m)
			my setPopupButton(my last_popup(m), f)
			my setPopupButton(my second_to_last_popup(m), my sign_position_converter(item (i + 2) of myArray, 2))
			my set_last_datetime(item (i + 3) of myArray)
			return i + 4
		else
			my setPopupButton(my second_to_last_popup(m), my get_associative_item(my get_associative_item(map_signs_to_options, "Word Count"), item (i + 1) of myArray))
			my set_last_datetime(item (i + 2) of myArray)
			return i + 3
		end if
	end if
end set_date_filters