problems with commands referencing objects in arrays

Hi all,
I am quite new to max script and after 2 days of problems I have decided to ask the experts for some help.

I keep getting runtime errors that say:

-- Unknown property: "ShapeName" in undefined
where shapename is a property of a structure, stored in an array.

when i ask maxscript to tell me what its pointing to with:


it does return the correct shape I originally stored.

But my problems start when I ask maxscript to perform:

splineops.fuse $
weldspline $ DistanceToWeld

$ being my "(vertsortarray[(loopnum)].shapename)"

It has fast become my opinon that any operator that alters the properties of objects or shapes stored or referenced in arrays does not work.
This is because when i run the code outside of my code body on its own the exact same lines work, and the vertex weld or fuse.
when i put the coe into my script, the entire coe runs with no erros but nothing gets welded or fused.

Can someone tell me if storing objects or shapes into an array protects them from being selected and used by weld or fuse ?

here is a sample of my script

shapegrab = ("select $" + ((vertsortarray[(thisvert)].shapename as string)))
execute (shapegrab)
subobjectLevel = 1
max select all
weldspline $ DistanceToWeld --(being set already to 3)
for removes = 1 to (vertsortarray.count) do
if (vertsortarray[(removes)].shapename) == (vertsortarray
[(thisvert)].shapename) then
deleteitem vertsortarray removes
max select all
max select invert
subobjectLevel = 0

when i run

subobjectLevel = 1
max select all
weldspline $ DistanceToWeld

on a selected object it works and welds them.
when run as part of my code I get no errors but it does not weld them.

Any help gratefully recieved.