[Gmsh] Print value of a list item

look mlook at me.com
Fri Aug 21 11:52:19 CEST 2015


Hi Dave and thank you for the very quick reply,

Of course I have consulted the gmsh User Guide. I still don’t get it. According to the guide the PrintF function has the following format:

Printf ( char-expression <, expression-list> );

So i replaced char-expression with %f like suggested in the despription and <, expression-list> with heights[5]. Hence I got:

Printf ( %f heights[5] );

The error message I got was:

syntax error (%)

So I guess either the user guide is wrong or I just don’t understand the way the function is described in the guide. Please note that I have no idea what %f means or what the ",“ before expression list stands for. I couldn’t find anything about it in the guide.

Would really appreciate some help!

Best regards,

Kate

> Am 21.08.2015 um 11:08 schrieb David Colignon <david.colignon at ulg.ac.be>:
> 
> 
> On 21/08/15 09:51, look wrote:
>> Dear gmsh list,
>> 
>> how can I get the value of a list item ( for example heights[5] ) printed in the output window of the gmsh GUI? I tried Printf ( heights[5] ); so far but it didn’t work.
>> 
>> Thank you in advance,
>> 
>> Kate
>> _______________________________________________
>> gmsh mailing list
>> gmsh at geuz.org
>> http://www.geuz.org/mailman/listinfo/gmsh
>> 
> 
> 
> Hi,
> 
> see http://www.geuz.org/gmsh/doc/texinfo/gmsh.html#General-commands
> 
> Printf ( char-expression <, expression-list> );
> 
>    Prints a character expression in the information window and/or on the terminal. Printf is equivalent to the printf C function: char-expression is a format string that can contain formatting characters (%f, %e, etc.). Note that all expressions are evaluated as floating point values in Gmsh (see Expressions), so that only valid floating point formatting characters make sense in char-expression. See t5.geo, for an example of the use of Printf.
> 
> 
> and http://www.geuz.org/gmsh/doc/texinfo/gmsh.html#t5_002egeo
> 
> ...
> ...
>  // We also print some variables on the terminal (note that, since all
>  // variables are treated internally as floating point numbers, the format
>  // string should only contain valid floating point format specifiers like
>  // `%g', `%f', '%e', etc.):
> 
> 
>  Printf("Hole %g (center = {%g,%g,%g}, radius = %g) has number %g!",
> 	 t, x, y, z, r, thehole) ;
> 
> Regards,
> 
> Dave
> 
> 
> -- 
> David Colignon, Ph.D.
> 1er Logisticien de Recherche
> Université de Liège
> ACE - Applied & Computational Electromagnetics
> Quartier POLYTECH 1 - Montefiore B28
> Allée de la découverte 10
> 4000 Liège - BELGIQUE
> Tél: +32 (0)4 366 37 32
> http://www.ulg.ac.be/nic4
> 
>