Declare global variable in corona sdk

HI

How to declare global variable in corona sdk using lua .I am using _G.variable but getting nil value.

Example.

local function networkListener( event )

if ( event.isError ) then

print( “Network error!”)

else

local data = (event.response)

local str=(string.find(data, “<?xml”))

local str1 = (string.sub(data, 0,str-3))

_G.isOK=str1(varibale declare)

end

end

network.request(URL, “POST”, networkListener, params)

Printing value:

print(_G.isOK)- out put nil

You need to wait until the network request has completed before you print _G.isOK. If you print it straight after network.request, it probably won’t have had time to get and process the response.

You need to wait until the network request has completed before you print _G.isOK. If you print it straight after network.request, it probably won’t have had time to get and process the response.