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

Federico Miyara fmiyara at fceia.unr.edu.ar
Wed Nov 24 01:42:26 CET 2021


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 argument a variable name (hence, a 
string), so your x would be "xNum", instead of 123. Then you could use 
evstr() to get the value of the variable to proceed with the processing.

Regards,

Federico Miyara


On 23/11/2021 17:18, Jens Simon Strom wrote:
>
> 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 the string "xNum"
>
> Regards
> Jens
> _______________________________________________
> users mailing list
> users at lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users
>
>



-- 
El software de antivirus Avast ha analizado este correo electrónico en busca de virus.
https://www.avast.com/antivirus
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20211123/3100339f/attachment.htm>


More information about the users mailing list