[Gmsh] How to find if a variable exists

Christophe Geuzaine cgeuzaine at ulg.ac.be
Thu Sep 8 08:52:04 CEST 2016

> On 07 Sep 2016, at 22:30, Jim Monte <jim.gmsh at gmail.com> wrote:
> Hi All,
> I have written macros returning arrays of various items, such as point IDs. Depending on the arguments to the function, some arrays can be of different sizes. To ensure that there is no "junk" at the end of the arrays left from a previous call, I would like to Delete the arrays before building them. However, the first time the macro is called, the array does not exist, and that causes an error. One workaround is to force the array to exist by adding something like x[0] = 0; before the Delete command, but I was wondering if there is a more direct way to query if a specific variable exists. Thanks for any information.

Exists(name) will do the trick

> Jim Monte
> _______________________________________________
> gmsh mailing list
> gmsh at onelab.info
> http://onelab.info/mailman/listinfo/gmsh

Prof. Christophe Geuzaine
University of Liege, Electrical Engineering and Computer Science 

Free software: http://gmsh.info | http://getdp.info | http://onelab.info

More information about the gmsh mailing list