[fpc-pascal] FPC + GTK2 : Using variable into a Widget name ?

Jonas Maebe jonas.maebe at elis.ugent.be
Fri Jan 4 14:34:01 CET 2008


On 04 Jan 2008, at 14:26, <tom at guilleminot.org> <tom at guilleminot.org>  
wrote:

> I use FPC with GTK2 and I have the following problem :
> In a loop with I'd like to be able to use the indice (incremented  
> integer)
> on the name of widget to perform some actions.
> Here is an example :
>
>   var
>     pFSImage01, pFSImage02, pFSImage03 : PGtkWidget;
>   ...
>
>   For I:=1 to 3 do
>   begin
>   	pFSImage0#I# := gtk_image_new_from_file('./mypix.jpg');
>   	gtk_fixed_put(pGTKFIXED(pFSFixed), pGTKWIDGET(pFSImage0#I#) ,  
> 100*I,
> 20);
>   	gtk_widget_show(pFSImage0#I#);
>   end;
>
> So I'd like any #I# above are remplaced with the real I value. This  
> would
> considerably improve/reduce my code.
> But I'm able to achieve this. Does anyone know ?

Use an array?


Jonas



More information about the fpc-pascal mailing list