Hi, Guys
Thanks for all the help - I managed to find a coding fault relating to what I believe as the passing of a reference to an object and this reference was passed by value causing a problem which appeared to be lost data. Firstly, I must say that everybody's input was important and helped me to find this difficult (for me) to find fault.
Wil's and Lucams Suggestions -
Can you give us a small example project?
Well I tried this and could not duplicate the problem (so it must be my bad code!)
Agraham's
It should work fine if your 'object' is a non-primitive. Arrays, lists, maps, custom types should all work as expected
They did, as I found out when I tried to demonstrate with a simple example.
Finally, MicroDrie comments hit the nail on the head.
I see a great danger here that (perhaps depending on the sequence) when processing the information, updated information may be lost
What happened in my code When the test sub ran, it simply replaced the real data with test data and called classes to be tested.
Unfortunately, I am a great believer from my "C" language and Assembler days "don't move the data change the pointer". So that was how the test subs changed data. Unfortunately when a reference (pointer) to data is passed by value, then the caller is unaware of the change and its reference still points to the old data and the called sub points to the new data which is lost on the return. (I am fully aware of the C# "ref" keyword which is suppose to overcome this problem - but this is B4X)
I can only say that putting the main reference on the Left hand side of an expression can cause problems:
i.e. myMainReference = newReference the other way around appears to be ok i.e. newReference = myMainReference and is not effected if the reference is passed "by value" or "by reference".
I have never been a big advocate of global objects (suggested by MicroDrie) but if your code becomes complex this problem with references can be a lot harder to find than problems caused by using global objects.
Thanks again for the help
Dave Morris