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.
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
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