My last rant on handles and addresses

Dear friends and loved ones,

It is with a heavy heart I must inform you that I just can’t get those stupid addresses and handles to work!

I have tried allocating memory using ARRAY CREATE and reading and writing to it using READ_CONTENT and WRITE_CONTENT. It sort of worked but turned out that WRITE_CONTENT reallocates the buffer and it only allocates up to the entry I am currently writing to. So if I have an array of 4 entries and I write to entry 3, the content of entry 4 will become garbage.

I have tried reading the address of an array allocated with ARRAY CREATE but I haven’t been successful. I did manage to read the content of the array by doing @myHandle, but reading was never the issue. Writing was.

I also tried to get the physical address of some memory by using the & operator, but what that does is take in the parameter, read the content of the parameter and use as address from which other content is read and used as pointer.

Result  =  (void*)*(DATA32*)Result;

I then went on to try and statically allocate some memory by doing this:

DATAS		MyMemory			100000
vmthread  MAIN
{
	DATA32 MyMemoryAddress
	MOVE32_32( &MyMemory, MyMemoryAddress )
}

But that didn’t work either. My best guess is that it reads the content of MyMemory, which is zero initialized, and then use 0 as address to read another address from.

So after all that, what is next?

I have NO clue how to work with memory in LMS2012. I can’t for my life figure out if it is possible to .. ARGH! It has happened AGAIN.

When writing up my blog post I often find myself going back to earlier things to investigate further. Something I did again today.

I looked through all existing code and found that only a small test LMS script actually used ARRAY READ_CONTENT and WRITE_CONTENT, and I wasn’t surprised as they don’t work very well.

What I did find though was these OP codes. ARRAY_WRITE and ARRAY_READ.

So I will read up on those and then come back, either with yet another blog post about how handles and arrays don’t work, or another “this is the last rant on arrays” blog post.

Either way I will return shortly!

Leave a Reply