PDA

View Full Version : prob getting table to combobox


Jonas DK
01-05-2007, 04:56 PM
Having some trouble populating a ComboBox with a Table, maybe someone can spot the error. I keep getting an error message saying "Attempt to call Global 'tEnhed' (a table value)"

This is the code I have:

On app Startup:
--********** Create constant Tables START **********--
tEnhed = {"Bæver", "Ulv-Toomai", "Ulv-Seeonee", "Junior", "Spejder", "Senior", "Rover", "Leder"};

On Page OnShow:
--********** Make sure all fields are empty START **********--
ComboBox.DeleteItem("cbEnhed", -1);
Input.SetText("ipAdresse", "");
Input.SetText("ipPostnr", "");
Input.SetText("ipCpr", "");
Input.SetText("ipIndmeldt", "");
Input.SetText("ipEfternavn", "");
Input.SetText("ipFornavn", "");
Label.SetText("lbCity", "By");
--********** Make sure all fields are empty END **********--
--Used dialog to make sure the data is in the table
-- result = Table.Concat(tEnhed, ";", 1, TABLE_ALL);
-- Dialog.Message("Notice", result, MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);

--********** Read Constant tables to fields START **********--

-- Prevent the ComboBox from updating
ComboBox.SetUpdate("cbEnhed", false);

-- Add Table to ComboBox
nEnhed = Table.Count(tEnhed);
min = 1; -- The number to start at
max = nEnhed; -- The number to stop at
for count = min, max do
local cEnhed = tEnhed(count);
Dialog.Message("Notice", cEnhed, MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
--ComboBox.AddItem("cbEnhed", cEnhed, count);
end
ComboBox.SetUpdate("cbEnhed", true);

I thourght it could have something to do with the table so I tried to take the data from the table and pass it to a string that would then be parsed to the combobox but I get the same error, now its just on the string in stead..

What am I doing wrong?

Cheers,
Jonas

Dermot
01-05-2007, 05:04 PM
Try this

local cEnhed = tEnhed[count];

Jonas DK
01-05-2007, 05:56 PM
of course... I have been looking at this for over an hour trying to get what the error was... and it is so simple...


Thanks



Jonas