Nested Repeat Loop and Popup Menu from Text File

I’m trying to populate a popup button’s menu with a list of parameters inside a list of xml files.

Here’s what I’m doing:

set theplugins to every paragraph of (do shell script "/usr/bin/less < /tmp/stripped.txt") as list
	set AppleScript's text item delimiters to ","
	repeat with i from 1 to (count of theplugins)
		set theplugindescriptions to do shell script "defaults read" & space & pluginpath & text item i of theplugins & space & "plugin"
		tell menu of popup button "plugins" of tab view item "marketing" of tab view "tabs" of window "mocktail"
			repeat with i from 1 to (count of theplugindescriptions)
				make new menu item at the end of menu items with properties {title:item i of theplugindescriptions as Unicode text}
			end repeat
		end tell
	end repeat

If I step through “theplugins” it seems to be just what I expect: a list of file names (minus the .plist stripped off).
However, when the list is passed to the “do shell script” that reads the property inside the item with the defaults command, the result is a vertical list with each letter of the item, instead of whole words, arranged vertically instead of in paragraphs.

How do I skin this cat?

Hi,

count counts the items of a list or characters of a string.
I guess, your variable theplugindescriptions is just a string, not a list of strings

Thanks,

that’s what I thought as well, but when trying this:

set theplugins to every paragraph of (do shell script "/usr/bin/less < /tmp/stripped.txt") as list
   set AppleScript's text item delimiters to ","
   repeat with i from 1 to (count of theplugins)
       set theplugindescriptions to do shell script "defaults read" & space & pluginpath & text item i of theplugins & space & "plugin" as list
       tell menu of popup button "plugins" of tab view item "marketing" of tab view "tabs" of window "mocktail"
           repeat with i from 1 to (count of theplugindescriptions)
               make new menu item at the end of menu items with properties {title:item i of theplugindescriptions as Unicode text}
           end repeat
       end tell
   end repeat

results in the following error:

AppleScript Error

Some data was the wrong type. (-1703)

Sorry, it’s rather impossible to help at this point without any information about the structures of the .txt file and the user defaults

OK, figured this one out myself after a bit of trial and error:

set theplugins to every paragraph of (do shell script "/usr/bin/less < /tmp/stripped.txt") as list
	repeat with i from 1 to (count of theplugins)
		set AppleScript's text item delimiters to ","
		set theplugindescriptions to {do shell script "defaults read" & space & pluginpath & text item i of theplugins & space & "plugin"} -- the curly braces here were the key to this
		tell menu of popup button "plugins" of tab view item "marketing" of tab view "tabs" of window "mocktail"
			repeat with i from 1 to (count of theplugindescriptions)
				make new menu item at the end of menu items with properties {title:item i of theplugindescriptions as Unicode text}
			end repeat
		end tell
	end repeat