For the record, this needs commas (or semicolons):
options = {
"New program",
"File Manager",
"Edit program"
}
And this needs an end to the if:
if #v > longest then longest = #v end
Also, AgentE's function only finds the longest string length, and not the longest string. If you want the longest string:
function longestString(tab)
local longest
for i=1, #tab do
local str = tab[i]
if not longest or #str > #longest then
longest = str
end
end
return longest
end
His solution would still solve your problem, though. Just wanted to throw this out there in case you actually need the longest string. A better name for his function would be "longestLength".
As a side note, I use a numeric loop instead of pairs in this code, simply because it can be a little faster.