Is variable name the name of the object type? I assume so if you are creating object by name array.value. And if so, do you really need it?
edit : oops I realised you are setting more than just this variable. You could set two global variables to curx and cury inside the loop and then using the 'Family on created' event assign using the global variable values instead of curx/cury, this may work.