T
T
TimCraft2018-09-09 07:19:57
Delphi
TimCraft, 2018-09-09 07:19:57

How to get the name of a variable as a string?

Pascal, Delphi
Any variable is given as input to a function, how can I get its name as a string at the output?
Example: filed Var1, received string 'Var1' as output
function fGetNameVar(x:variant): string;
start
???
end;

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Skusnov, 2018-09-09
@AlexSku

Didn't understand the assignment. If you call a function in a program, eg
f(vasya) why don't you write 'vasya'
instead ?

K
kalapanga, 2018-09-09
@kalapanga

Impossible. Variable names exist only in source code and do not exist in the compiled program. So if you need to write something to the log / journal, pass two values ​​​​to the function - the required text and the actual value of the variable.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question