[fpc-pascal] TVision dynamic NewSItem for RadioButton

Marco van de Voort marcov at stack.nl
Wed Feb 3 22:18:41 CET 2010


In our previous episode, Zitt Zitterkopf said:
> 
> I have a list of strings inside a TStringList which contains the contents
> of my TurboVision RadioButton group.
> 
> This TStringList has a variable data payload... there may be 1 entry...
> there may be 10 entries.
> 
> I need to create a RadioButton Group with a variable number of entries; however, my documentation doesn't seem to give me a pointer to how this can be done. All of the RadioButton examples appear to be static.
> 
> 
>     Bruce := New(PRadioButtons, Init(R,
>       NewSItem('~1~ OS A',
>       NewSItem('~2~ OS B',
>       NewSItem('~3~ OS C',
>       nil)))
>     ));
>     Insert(Bruce);
> 
> 
> It looks like the second Init parameter is a linked list of sorts; I hope
> I don't have to get creative in recreating this list.

That is correct yes, it is a coded creation of a linked list.

To put a tstringlist in there, you'd go:

var p  : psitem;

p:=nil;
if strl.count>0 then
 for i :=strl.count-1 downto 0 do
    p:=newsitem(strl[i],p);
  
Note the reversion of the for loop.



More information about the fpc-pascal mailing list