|Bill Allombert on Fri, 07 Oct 2011 17:53:52 +0200|
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
|Re: How to get the name of a variable|
On Fri, Oct 07, 2011 at 03:18:13PM +0200, Jeroen Demeyer wrote: > This should be a basic libpari question: > > If I have a variable number (as a long), how can I get the variable name > (as a string)? I could of course use GENtostr(pol_x(v)) but there > should be more direct way. I looked at the libpari manual, but could > not find it. Variable names is GP language concept, while variable number is a libpari concept. A variable number need not be associated with a variable name. You can write libpari programs that allocated a variable number but never gives it a name. Technically, there is a global array varentries which returns the entree* associated to a named variable, or NULL, so you can do: entree *ep = varentries[v]; char *s = ep?(char*)ep->name:NULL; but probably GENtostr(pol_x(v)) is the best option, especially since we expect to remove the varentries array. Cheers, Bill.