There is no direct support for global arrays (and also for dynamic arrays) - but you can write simple set of functions to implement global (maybe - dynamic) arrays via global variables.
Smth like:
Code:
sub InitArray(name)
uo.setglobal("array" + name,"1")
end sub
sub SetArraySize(name,size)
if uo.getglobal("array"+name) then
safecall uo.setglobal("sizearray"+name,val(size))
if fatalerror then
uo.print("Exception in SetArraySize, FatalError: " + FatalError + ". Possible reason - invalid size")
endif
else
uo.print("Error: no such array: " + name)
endif
end sub
sub SetArrayElement(name,ind,val)
if uo.getglobal("array"+name) and uo.getglobal("sizearray" + name) then
if uo.getglobal("sizearray"+name) > ind then
safecall uo.setglobal("elementarray"+name + str(ind),str(val))
if fatalerror then
uo.print("Exception in SetArrayElement, FatalError: " + FatalError + ". Possible reason - invalid index or value")
endif
endif
else
uo.print("Error: no such array: " +name+", or size = 0")
endif
end sub
sub GetArrayElement(name,ind)
var result
if uo.getglobal("array"+name) and uo.getglobal("sizearray" + name) then
if uo.getglobal("sizearray"+name) > ind then
result = safecall uo.getglobal("elementarray"+name + str(ind),str(val))
if fatalerror then
uo.print("Exception in GetArrayElement, FatalError: " + FatalError + ". Possible reason - invalid index")
else
return result
endif
endif
else
uo.print("Error: no such array: " +name+", or size = 0")
endif
end sub
Of course there is need some dispose functions and some enchantments in SetArraySize (and, of course, bugfixes
)) ) - but this must work....