PDA

View Full Version : Table.Concat not working with FileMenu?



SonG0han
11-10-2007, 03:53 PM
Hi! I tried to get the Menubar in a var(table) and then display the content as string in a textbox but I get this runtime error.

[3]: tblFileMenu = Application.GetMenu();
TRACE: LastError = 0 ("Success.")
[2]: result = Table.Concat(tblFileMenu, ";", 1, TABLE_ALL);
TRACE: LastError = 2901 ("A runtime error occurred while calling the function.")
[4]: Input.SetText("Input1", result);
TRACE: LastError = 0 ("Success.")

Does anyone know why it does not work? :huh

madsen
11-10-2007, 04:07 PM
This is basically from the help file :) I tested it and works on AMS7 here.



-- Output all top level menu items:
local strMenuData = "";

-- Store the contents of the menu in a table
tblMenu = Application.GetMenu();

-- Check that the table exists
if(tblMenu)then
local nNumItems = Table.Count(tblMenu);

-- Step through the table row by row
for index = 1, nNumItems do
local tblItemInfo = tblMenu[index];
if(tblItemInfo)then
-- Add the text to the string
strMenuData = strMenuData..tblItemInfo.Text.."\r\n";
end
end

-- Output the created string to the user
Input.SetText("Input1", strMenuData);
end


I added the Input field for the sake of this example.