Posted: 14th Jun 2007 20:59
The following line reports an 'Object number illegal' message:

Print STR$(Object Position X(tobjnum(2)))

where tobjnum(2)=1 and the object definitely exists.

However the following does work:

h=tobjnum(2)
If h=1 then print STR$(Object Position X(h))

or

h=tobjnum(2)
Print STR$(Object Position X(h))

So in effect all I'm doing is subsituting the tobjnum(2) for h.

Any ideas why? Because its bloody infuriating! I've been pulling my hair out for ages over this one!
Cheers
Lee
Posted: 16th Jun 2007 5:12
It depends where the code that falls over is located. The lines you posted are meaningless if we don't know where they have been pulled out from - or what other code is involved.

For all we know, the line causing the problem might be in a function where something else is setting the contents of the array to zero or maybe you are using a variable which hasn't been declared as global - and as such is defaulting to zero.

Post a complete, runnable, non-working code snippet so we have something to work on...

Oh, and by the way, Str$() isn't needed with Print - only with the Text command.

TDK_Man