[Scilab-users] Getting the variable name used for a function input argument

2021-11-23 Thread Jens Simon Strom
Hi Scilab friends, Given a numeric variable like xNum as an input argument of a function call, how can I produce the variable name string "xNum" within the function? Example: function [name,y]=foo(x)    name=???    y=x^2 endfunction xNum=123. [name,y]=foo(xNum) The result for name should be

Re: [Scilab-users] Getting the variable name used for a function input argument

2021-11-23 Thread Federico Miyara
I'm not completely sure, but I think this is not possible since what is passed to the function isn't a variable but the value contained in the variable. The name is lost in the process. An alternative way (but I don't know if this would be acceptable for you) is that the function had as its

Re: [Scilab-users] Getting the variable name used for a function input argument

2021-11-24 Thread Stéphane Mottelet
Hi, Le 24/11/2021 à 01:42, Federico Miyara a écrit : I'm not completely sure, but I think this is not possible since what is passed to the function isn't a variable but the value contained in the variable. No. Internally, input arguments are passed as references to the true object. There is

Re: [Scilab-users] Getting the variable name used for a function input argument

2021-11-24 Thread Stéphane Mottelet
Jens, please do not use "Reply to:" on an old thread when this is irrelevant. You can create a new thread by directly mailing users@lists.scilab.org S. Le 23/11/2021 à 21:18, Jens Simon Strom a écrit : Hi Scilab friends, Given a numeric variable like xNum as an input argument of a function

Re: [Scilab-users] Getting the variable name used for a function input argument

2021-11-24 Thread Samuel Gougeon
Le 24/11/2021 à 09:51, Stéphane Mottelet a écrit : Hi, Le 24/11/2021 à 01:42, Federico Miyara a écrit : I'm not completely sure, but I think this is not possible since what is passed to the function isn't a variable but the value contained in the variable. No. Internally, input arguments ar

Re: [Scilab-users] Getting the variable name used for a function input argument

2021-11-24 Thread Stéphane Mottelet
Hi, Le 24/11/2021 à 18:07, Samuel Gougeon a écrit : Le 24/11/2021 à 09:51, Stéphane Mottelet a écrit : Hi, Le 24/11/2021 à 01:42, Federico Miyara a écrit : I'm not completely sure, but I think this is not possible since what is passed to the function isn't a variable but the value containe

Re: [Scilab-users] Getting the variable name used for a function input argument

2021-11-27 Thread Samuel Gougeon
Le 24/11/2021 à 19:34, Stéphane Mottelet a écrit : Hi, Le 24/11/2021 à 18:07, Samuel Gougeon a écrit : Le 24/11/2021 à 09:51, Stéphane Mottelet a écrit : Hi, Le 24/11/2021 à 01:42, Federico Miyara a écrit : I'm not completely sure, but I think this is not possible since what is passed to

Re: [Scilab-users] Getting the variable name used for a function input argument

2021-11-27 Thread Samuel Gougeon
Le 23/11/2021 à 21:18, Jens Simon Strom a écrit : Hi Scilab friends, Given a numeric variable like xNum as an input argument of a function call, how can I produce the variable name string "xNum" within the function? That is requested and commented as the still open report #5840

Re: [Scilab-users] Getting the variable name used for a function input argument

2021-12-04 Thread Jens Simon Strom
Hi, Thanks for all the responses and sorry for not beeing able to answer before now. The background of my question was to write a function for formatted output of complex variables in polar form with mprintf like function printc(c) which returns the name of c on calling level, |c|, and the

Re: [Scilab-users] Getting the variable name used for a function input argument

2021-12-04 Thread Samuel Gougeon
Hello Jens, Le 04/12/2021 à 20:39, Jens Simon Strom a écrit : Hi, Thanks for all the responses and sorry for not beeing able to answer before now. The background of my question was to write a function for formatted output of complex variables in polar form with mprintf like function printc(

Re: [Scilab-users] Getting the variable name used for a function input argument

2021-12-05 Thread Samuel Gougeon
Le 04/12/2021 à 20:59, Samuel Gougeon a écrit : So, /unless you need to know the name *inside* printc() for some unsaid purpose/, what would be the difference between in one hand [name, mag, arg] = printc(myvar, "myvar") and on the other hand name = "myvar"; [mag, arg] = printc(myvar) ?

Re: [Scilab-users] Getting the variable name used for a function input argument

2021-12-06 Thread Jens Simon Strom
Hi Samuel, Your solution is quite sophisticated. To me it was confusing to call a function without the input being bracketed. And on top of this, that a variable of type /constant/ is accepted as a /string/ within the function. Scilab seems to be more flexible than I would dare to imagine befo

Re: [Scilab-users] Getting the variable name used for a function input argument

2021-12-06 Thread Stéphane Mottelet
Hello Jens. Nothing sophisticated here. print myVar is considered by the parser as print("myVar") See "Calling function"/item 4. https://help.scilab.org/docs/6.1.1/en_US/functions.html S. Le 06/12/2021 à 10:40, Jens Simon Strom a écrit : Hi Samuel, Your solution is quite sophisticated. To

Re: [Scilab-users] Getting the variable name used for a function input argument

2021-12-06 Thread Samuel Gougeon
Hello Jens, Le 06/12/2021 à 10:40, Jens Simon Strom a écrit : Hi Samuel, Your solution is quite sophisticated. On the opposite, it aims to be simpler. To me it was confusing to call a function without the input being bracketed. And on top of this, that a variable of type /constant/ is ac