Dynamic Popupbutton Item

Hi Folks,

I want to load the input of a textfield into a popupbutton Item and get the following
error: Can’t make <> “networks” into type reference (-1700)

my code:


if name of theObject is "test" then
delete every menu item of menu popub button "networks" of window "main"
set file_path to (((path to me) as string) & "Contents:Resources:networks.txt") as file specification
set read_data to paragraphs of ((read file_path) as Unicode text)

repeat with i from 1 to (length of read_data)
set current_item to (item i of read_data) as string
display dialog current_item
make new menu item at end of menu popup button "networks" of window "main" with properties {title:current_item, enabled:true}
end repeat
end if




Displaying the current_item shows the correct entry… What can I do to eliminate this error?

Thanks for your help!

Stefan

use the right syntax : menu item of menu of popup button…
the make new item part can be done easier

if name of theObject is "test" then
delete every menu item of menu of popup button "networks" of window "main"
set file_path to (((path to me) as string) & "Contents:Resources:networks.txt") as file specification
set read_data to paragraphs of ((read file_path) as Unicode text)

repeat with i in read_data
make new menu item at end of menu of popup button "networks" of window "main" with properties {title:i, enabled:true}
end repeat
end if

Hi Stefan,

thanks a lot - it works perfect…

Best Regards,

Stefan