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

2008-01-04 Thread tom
Hi,

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 ?

Thanks.
Tom


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


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

2008-01-04 Thread Vincent Snijders

[EMAIL PROTECTED] schreef:

Hi,

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.


Use an array.


Here is an example :

  var
pFSImage01, pFSImage02, pFSImage03 : PGtkWidget;
  ...


  var pFSImage : array[1..3] of PGtkWidget;

   For I:=1 to 3 do
   begin
pFSImage[I] := gtk_image_new_from_file('./mypix.jpg');
gtk_fixed_put(pGTKFIXED(pFSFixed), pGTKWIDGET(pFSImage[I]) , 100*I, 20);
gtk_widget_show(pFSImage[I]);
   end;

Vincent
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


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

2008-01-04 Thread bartek
On Friday 04 January 2008 14:26:50 [EMAIL PROTECTED] wrote:
> Hi,
> 
> 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 ?
> 
> Thanks.
> Tom
> 
What about fixed size arrays?

var
pFSImage: array[0..3] of pGTKWidget;
i: integer;
begin
for i:= 0 to 3 do
begin
pFSImage[i] := your code here
more code
end;
end;

You could also use dynamic arrays if you don't know the array size at compile 
time. There is more information in the reference manual of FPC.

bartek
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


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

2008-01-04 Thread Jonas Maebe


On 04 Jan 2008, at 14:26, <[EMAIL PROTECTED]> <[EMAIL PROTECTED]>  
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
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Maybe a new fpc book :)

2008-01-04 Thread Marco Ciampa
I work in a high school in Italy.
We are currently using fpc + gnuplot for math and phisics simulations. 
In one lab we are currently starting to use Linux as the _sole_ platform. 

On Wed, Jan 02, 2008 at 12:35:57PM -0500, Anthony W. Henry wrote:
> 1. What OS is most-used for Free Pascal? Windows? Linux?
80% windows and 20% Linux (this one growing)
 
> 2. What libraries do most people use for console (i.e.,
> "terminal" or text-mode) apps? I dislike ncurses; is
> there a better way?
console & graph unit (BGI drivers under windows and Linux (X _not_ VGAlib) )

> 3. Does anybody really use Free Pascal to write Win32
> apps?
yes

 
> 4. Do people make heavy use of Free Pascal objects?
not (for now) in our school

We are currently porting several astronomical turbo pascal programs for fpc
(win and Linux)

bye

-- 

Marco Ciampa

++
| Linux User  #78271 |
| FSFE fellow   #364 |
++
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal