You can't check for a local variable outside it's block. You'd have to rename the global foo as something else and pass the data out to it.
Code:
function testfunction(frame)
if not arg1 then
local foo = "foo"
local bar = "bar"
arg1 = foo
arg2 = bar
end
text=arg1.. arg2
DEFAULT_CHAT_FRAME:AddMessage(text) -- test to make sure everything goes smoothly
local f = CreateFrame("FRAME", "Blah")
f:SetScript("OnUpdate", testfunction(self))
end
But that won't help your 60 upvalue any. For that, you're don't really have a choice but to condense it down via one of the previously mentioned methods.