Blitz (182/218)

From:David McMinn
Date:28 Aug 2001 at 12:14:50
Subject:Re: MUICycle

Hi Steve

> Has anyone managed to get MUICycle working with an array. I need to set
> up a cycle gadget, whose contents I don't know at initialisation (so
> I'm using
>
> MUIAddTags cyclegadget,#MUIA_Cycle_Entries,listarray()
>
> But all I get is garbage.

Well, looking at the autodoc, it's an array of STRPTRs, terminated by a
NULL. So you have to do this:

Dim strptr$(x)
Dim array.l(x+1)
; Put things in strings
For i.w=0 To x
array(i)=&strptr$(i)
Next
array(x+1)=0
MUIAddTags cyclegadget,#MUIA_Cycle_Entries,&array(0)

I guess instead of copying all the pointers, you could poke 0 into the
end of the string array, but you might get problems with string memory
not being freed until the end of the program.

> the contents of the cycle may change during the course of the program, so
> I need to be able to reset the list in the same way.

Can you add and remove items individually from a MUICycle, or does it
always have to be done with the array? If you can, use DLL to store items
and add and remove them as required.

If it always has to be the array, I guess you could allocate the arrays
like pooled memory. That is, allocate them in blocks of, say 50 items,
and then shuffle items around as you add/remove. When you need to display
it, just copy the pointers again, as shown above (although obviously it
would get slower the more items you have).

Oh, you could do this:

CopyMem_ &strptr(0),&array(0),Sizeof.l*x
array(x+1)=0

And it would be a bit quicker than using the For loop. But the quickest
way would obviously be to simply poke 0 into the strptr array and notdo
any copying, but you might get problems if Blitz assumes things about
strings.



|) /\ \/ ][ |) |\/| c |\/| ][ |\| |\| | dave@blitz-2000.co.uk
http://members.nbci.com/david_mcminn | ICQ=16827694
'I don't care how good you say they are. I ain't fightin' alongside
no f**k-ass teddy bears.' - Samuel L. Jackson, Jedi

---------------------------------------------------------------------
To unsubscribe, e-mail: blitz-list-unsubscribe@netsoc.ucd.ie
For additional commands, e-mail: blitz-list-help@netsoc.ucd.ie